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
joint state controller with resource manager #109
Conversation
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. Just some changes regarding standard constants and shared test data.
@@ -68,6 +65,7 @@ class JointStateController : public controller_interface::ControllerInterface | |||
|
|||
protected: | |||
std::vector<std::string> joint_names_; | |||
std::unordered_map<std::string, std::unordered_map<std::string, double>> name_if_value_mapping_; |
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.
Can you a short comment about this map?
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.
Added comments, I've also grouped the joint-state-related stuff and the dynamic joint state-reltaed stuff together
const auto kPositionName = "position"; | ||
const auto kVelocityName = "velocity"; | ||
const auto kEffortName = "effort"; |
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.
I propose to use names from: hardware_interface/include/hardware_interface/types/hardware_interface_type_values.hpp
const auto kPositionName = "position"; | |
const auto kVelocityName = "velocity"; | |
const auto kEffortName = "effort"; |
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.
at the time of first doing this, these values were not available. Replaced with this constants now
#include <vector> | ||
|
||
#include "hardware_interface/joint_handle.hpp" | ||
#include "hardware_interface/robot_hardware.hpp" | ||
#include "hardware_interface/types/hardware_interface_return_values.hpp" |
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.
Header for standardized names...
#include "hardware_interface/types/hardware_interface_return_values.hpp" | |
#include "hardware_interface/types/hardware_interface_return_values.hpp" | |
#include "hardware_interface/types/hardware_interface_type_values.hpp" |
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.
thanks, added
// the rest will be ignored for this message | ||
for (const auto name_ifv : name_if_value_mapping_) { | ||
const auto & interfaces_and_values = name_ifv.second; | ||
if (has_any_key(interfaces_and_values, {kPositionName, kVelocityName, kEffortName})) { |
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.
if (has_any_key(interfaces_and_values, {kPositionName, kVelocityName, kEffortName})) { | |
if (has_any_key(interfaces_and_values, {hardware_interface::HW_IF_POSITION, | |
hardware_interface::HW_IF_VELOCITY, | |
hardware_interface::HW_IF_EFFORT})) { |
Maybe not the best formatting possible...
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.
when working around linters and code formatters, there's only so much you can discuss about code style :D
removing the hardware_interface namespace by a couple of using
s at the top of the file kept this a one-liner
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.
Yeah, I mean my proposal was not the best formating possible.
get_value(name_if_value_mapping_, joint_names_[i], kPositionName); | ||
joint_state_msg_.velocity[i] = | ||
get_value(name_if_value_mapping_, joint_names_[i], kVelocityName); | ||
joint_state_msg_.effort[i] = get_value(name_if_value_mapping_, joint_names_[i], kEffortName); |
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.
get_value(name_if_value_mapping_, joint_names_[i], kPositionName); | |
joint_state_msg_.velocity[i] = | |
get_value(name_if_value_mapping_, joint_names_[i], kVelocityName); | |
joint_state_msg_.effort[i] = get_value(name_if_value_mapping_, joint_names_[i], kEffortName); | |
get_value(name_if_value_mapping_, joint_names_[i], hardware_interface::HW_IF_POSITION); | |
joint_state_msg_.velocity[i] = | |
get_value(name_if_value_mapping_, joint_names_[i], hardware_interface::HW_IF_VELOCITY); | |
joint_state_msg_.effort[i] = get_value(name_if_value_mapping_, joint_names_[i], hardware_interface::HW_IF_EFFORT); |
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.
ja
|
||
namespace joint_state_controller_testing | ||
{ | ||
constexpr auto urdf = |
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.
I would propose to use descriptions.hpp header for this as proposed in #99 and ros-controls/ros2_control#247.
We should just move the file in test_robot_hardware
as @Karsten1987 proposed.
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.
#113 created follow-up issue
ASSERT_EQ(dynamic_joint_state_msg.interface_values[0].values[0], 1.1); | ||
ASSERT_EQ(dynamic_joint_state_msg.interface_values[1].values[0], 2.1); | ||
ASSERT_EQ(dynamic_joint_state_msg.interface_values[2].values[0], 3.1); | ||
const auto INTERFACE_NAMES = {"position", "velocity", "effort"}; |
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.
const auto INTERFACE_NAMES = {"position", "velocity", "effort"}; | |
const auto INTERFACE_NAMES = {hardware_interface::HW_IF_POSITION, | |
hardware_interface::HW_IF_VELOCITY, | |
hardware_interface::HW_IF_EFFORT}; |
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.
yup
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.
there was another one of these, done that too
|
||
#include "hardware_interface/loaned_state_interface.hpp" | ||
#include "hardware_interface/types/hardware_interface_return_values.hpp" |
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.
#include "hardware_interface/types/hardware_interface_return_values.hpp" | |
#include "hardware_interface/types/hardware_interface_return_values.hpp" | |
#include "hardware_interface/types/hardware_interface_type_values.hpp" |
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.
done
Looks good to me after @destogl suggestions are addressed. |
ok guys, I've addressed all your comments, please verify/resolve discussions (I'm not going to resolve your discussion points) |
I agree with how you addressed @destogl review, could be merged by me. |
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 wasn't my PR originally so I can still "review it"! After doing some major changes to it, the controller works and testing is mostly appropriate.
Patting myself on the shoulder in approval
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!
EDIT: My approvals are not counted anyway :)
e600d36
to
6197903
Compare
6197903
to
2ec6f9c
Compare
* Forward command controller almost using resource manager * Make forward command controller fully work and restore testing * Use node namespace for topics * Review fixes and linters * Move CallbackReturn using to header Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com>
* Use gmock * Add Bence as maintainer * Test invalid handles * Add handle validation to RobotHardware * Test proper handles and double registering handles * Test name and blanket handle getters * Test named handle getters * Refactor registering second handles in tests, add check for getting second name * Check that returned pointers are not null * Update ros2ci workflow versions
Needs ros-controls/ros2_control#236
The way to run it:
terminal1:
terminal2: