Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state_representation::Parameters to clproto #180

Merged
merged 12 commits into from
Aug 25, 2021

Conversation

eeberhard
Copy link
Member

@eeberhard eeberhard commented Aug 24, 2021

Ok, this was a little bit more work / more lines of change than I originally anticipated.

I added support for the Parameter class to contain the following types:

  • double
  • std::vector<double>
  • bool
  • std::vector<bool>
  • std::string
  • std::vector<std::string>
  • Eigen::VectorXd
  • Eigen::MatrixXd

Because state_representation::Parameter is templated as a container, I had to bind each template explicitly. 250 lines of change in clproto.cpp is just that, copied binding for each type. The test file adds another 160 lines alone.

The significant implementations are done in the decoder / encoder helper functions that are templated for the parameter type. There are a few other cleanups that had to occur in these files make all the overloads and templates work nicely together.

I tried to contain meaningful chunks of change with each commit, but the tests obviously only pass when everything comes together. So, I recommend you go through one commit at a time in your review. Still, I can also split this into multiple PRs if desired, just let me know.

On the bright side, I feel the tests are comprehensive and they all pass :)

* Add parameter type based on proto::State
in protobuf

* Use parameter namespace to define
parameter value messages in protobuf
* Add new Parameter field to the
StateMessage oneof message,
and update the clproto MessageType
enum accordingly

(No clproto bindings for parameter
are currently implemented)
* Fix typo in proto ParameterValue matrix
type to have "value" instead of "double"

* Fix typo in CMakeLists for generated
bindings path

* Remove uneeded headers

* Mark clproto source with comments
for each state type

* Reformat
* Function to check contained value
type of a parameter message
* Add template specialisations for binding
Parameter state messages of the various
supported types, using a local templated
helper function to call (as yet un-
implemented) encoders / decoders
* Add templated encoder helper functions
for the supported parameter value types

* Revise helper functions for repeated fields
* Add templated decoder helper functions
for the supported parameter value types

* Revise and add helper functions for
decoding RepeatedField types

* Update clproto.cpp with revised
decoder syntax
* Commit clproto parameter tests to
cover encode / decode of all supported
parameter types
* Remove debug string

* Use string decoder method for
Jacobian joint name decoding
Copy link
Contributor

@buschbapti buschbapti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good I have to try it. Please check regarding Quaterniond I sense the order might be swapped

}

template<>
Eigen::Quaterniond decoder(const proto::Quaterniond& message) {
return Eigen::Quaterniond(message.w(), message.vec().x(), message.vec().y(), message.vec().z());
return {message.w(), message.vec().x(), message.vec().y(), message.vec().z()};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you change here? Also I guess this would translate to Quaterniond(std::vector<double>) right? I am almost certain then that the order on this is {x, y, z, w} as Eigen stores the coeffs in this order.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is list initialisation of the return type. Calling return {a, b, c} for a return type Foo is the same as return Foo(a, b, c). It simply avoids repeating the type in the function body, which is tidier in some cases (like using auto when the type is explicitly given on the right hand side).

The coefficient order therefore is correct, and the tests for CartesianPose etc show that to be true.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok my bad never used that. Gosh so many new stuff to learn...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats very cool

Copy link
Contributor

@domire8 domire8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find any obvious errors, nice work! 👍
I would appreciate a little note or at least the PR number in the changelog and don't forget to change the commit title when squashing :)

@@ -27,6 +40,7 @@ enum MessageType {
JOINT_TORQUES_MESSAGE = 13,
SHAPE_MESSAGE = 14,
ELLIPSOID_MESSAGE = 15,
PARAMETER_MESSAGE = 16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No comma at the end?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not that is the last one of the enum

@eeberhard eeberhard changed the title Feature/clproto parameters Add state_representation::Parameters to clproto Aug 24, 2021
eeberhard and others added 3 commits August 24, 2021 17:25
* Remove templated encoder and
decoder helper methods (of the
form `MsgT encode(ObjT)` and
`ObjT decode(MsgT)` in favor
of explicilty declared and
overloaded methods. This is
because in release build, the
templated function definitions
get lost without additional
forward declaration / special
instantiation. This would make
template usage far more verbose
than necessary, and so it is easier
just to declare the overloaded
methods in the respective helper
header files.

* CI workflow to test in release build
@eeberhard eeberhard merged commit b329c6b into develop Aug 25, 2021
@eeberhard eeberhard deleted the feature/clproto-parameters branch August 25, 2021 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants