-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
* 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)
* 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
There was a problem hiding this 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()}; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats very cool
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
* 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
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 :)