-
Notifications
You must be signed in to change notification settings - Fork 0
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
test(state-representation): add utility tests for Cartesian/JointState #202
Conversation
ba1707c
to
c51b74f
Compare
source/state_representation/include/state_representation/space/cartesian/CartesianState.hpp
Show resolved
Hide resolved
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.
Looks good, could you add
- multiply state variable for joint states
- add an assertion that it fails if you provide a vector of wrong size
python/test/state_representation/space/cartesian/test_cartesian_state.py
Outdated
Show resolved
Hide resolved
python/test/state_representation/space/joint/test_joint_state.py
Outdated
Show resolved
Hide resolved
source/state_representation/include/state_representation/space/cartesian/CartesianState.hpp
Show resolved
Hide resolved
source/state_representation/include/state_representation/space/cartesian/CartesianState.hpp
Show resolved
Hide resolved
source/state_representation/test/tests/space/cartesian/test_cartesian_state.cpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Dominic Reber <[email protected]>
Adding soon.
While writing the test for this I realized something somehting else that we might need to address in a follow up PR, which is a bit problematic when inputs are eigen vectors (C++). For example: auto state = CartesianState();
auto new_incompatible_values = Eigen::VectorXd(4);
new_incompatible_values << 1.0, 2.0, 3.0, 4.0;
EXPECT_THROW(state.set_state_variable(new_incompatible_values, state_variable_type), exceptions::IncompatibleSizeException); For the new methods that are exposed this is correct (as in, it throws our custom exception). However: auto state = CartesianState();
auto new_incompatible_values = Eigen::VectorXd(4);
new_incompatible_values << 1.0, 2.0, 3.0, 4.0;
EXPECT_THROW(state.set_position(new_incompatible_values), exceptions::IncompatibleSizeException); is problematic, because the signature for void CartesianState::set_position(const Eigen::Vector3d& position) {
this->set_state_variable(position, CartesianStateVariable::POSITION);
} which means that C++ will implicitly cast the |
Thanks for writing this up. Your suggestion was to add |
Well actually my bad. We can not use I think for now we can open a small backlog item, but we might just be ok with delegating responsibility downwards for this. |
Yeah these changes seem to be a bit too big for now, a backlog item with no immediate action taken seems fair for now |
For reference we could do something like: SFINAE template <typename T>
typename std::enable_if<std::is_same<T, Eigen::Vector3d>::value>::type
void CartesianState::set_position(const T& position) {
this->set_state_variable(position, CartesianStateVariable::POSITION);
} or C++20: template <typename T>
concept IsEigenVec3 = std::same_as<T, Eigen::Vector3d>;
void CartesianState::set_position(const IsEigenVec3& position) {
this->set_state_variable(position, CartesianStateVariable::POSITION);
} seems a bit too much boilerplate. Perhaps the simplest is to just: void CartesianState::set_position(const Eigen::VectorXd& position) {
this->set_state_variable(position, CartesianStateVariable::POSITION);
} and let the |
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.
The changes of this PR seem good to me, thanks!
Sure but that is even less correct to me IMO because the function signature tells the user that it requires a Vector3d which is the only logical choice for position |
I agree, yes. |
Description
This PR solves the issue by updating the corresponding tests to verify the bindings in python and the functionality in C++.
Review guidelines
Estimated Time of Review: 5 minutes
Checklist before merging: