-
Notifications
You must be signed in to change notification settings - Fork 348
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
Cartesian twist controller #300
base: master
Are you sure you want to change the base?
Conversation
if (command_interfaces_.size() != 6) | ||
{ | ||
RCLCPP_ERROR_THROTTLE( | ||
get_node()->get_logger(), *node_->get_clock(), 1000, | ||
"Twist controller needs does not match number of interfaces needed 6, given (%zu) interfaces", | ||
command_interfaces_.size()); | ||
return controller_interface::return_type::ERROR; | ||
} |
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.
(edit) should this should be checked in on_configure(..)
?
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 to me. someone else must approve.
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 mostly fine to me, but I've left a few nits in-line.
I think you need to rebase your branch on ros-controls:master for CI to pass, since your branch doesn't have ros2_controllers_test_nodes
(e7d0517) yet.
Also, looks like the linter is unhappy.
<maintainer email="[email protected]">Lovro Ivanov</maintainer> | ||
<license>Apache-2.0</license> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> |
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.
Since find_package(ament_cmake_ros REQUIRED)
was introduced in 1f1fefc:
<buildtool_depend>ament_cmake</buildtool_depend> | |
<buildtool_depend>ament_cmake</buildtool_depend> | |
<buildtool_depend>ament_cmake_ros</buildtool_depend> |
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.
It doesn't like this pacakge needs ament_cmake_ros
I'll remove from the CMakeLists.txt
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.
Don't add it, remove it from CMakeLists.txt
} | ||
catch (const std::exception & e) | ||
{ | ||
fprintf(stderr, "Exception thrown during init stage with message: %s \n", e.what()); |
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.
Pardon my ignorance here, but could this not be logged with RCLCPP_ERROR_*
instead?
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 actually quite often a pattern in these use-cases.
command_interfaces_[0].set_value((*twist_commands)->twist.linear.x); | ||
command_interfaces_[1].set_value((*twist_commands)->twist.linear.y); | ||
command_interfaces_[2].set_value((*twist_commands)->twist.linear.z); | ||
command_interfaces_[3].set_value((*twist_commands)->twist.angular.x); | ||
command_interfaces_[4].set_value((*twist_commands)->twist.angular.y); | ||
command_interfaces_[5].set_value((*twist_commands)->twist.angular.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.
Nit. Not that it matters, but purely for brevity. Feel free to ignore:
command_interfaces_[0].set_value((*twist_commands)->twist.linear.x); | |
command_interfaces_[1].set_value((*twist_commands)->twist.linear.y); | |
command_interfaces_[2].set_value((*twist_commands)->twist.linear.z); | |
command_interfaces_[3].set_value((*twist_commands)->twist.angular.x); | |
command_interfaces_[4].set_value((*twist_commands)->twist.angular.y); | |
command_interfaces_[5].set_value((*twist_commands)->twist.angular.z); | |
auto command = (*twist_commands)->twist; | |
command_interfaces_[0].set_value(command.linear.x); | |
command_interfaces_[1].set_value(command.linear.y); | |
command_interfaces_[2].set_value(command.linear.z); | |
command_interfaces_[3].set_value(command.angular.x); | |
command_interfaces_[4].set_value(command.angular.y); | |
command_interfaces_[5].set_value(command.angular.z); |
This Commit builds on a rebased PR ros-controls#300 The Original author @livanov93 was in 2022 open sourcing part of a PickNik package form 2021. This commit brings the internal picknik and previously open PR ros-controls#300 back in sync and rebases the open PR onto humble.
@livanov93 I've rebased this branch onto Humble and brought it in sync with the internal version from PickNik for open sourcing. Should we force push onto this PR or close this one out and open a new one? |
@moriarty Feel free to force-push here. |
This pull request is in conflict. Could you fix it @livanov93? |
I've forced pushed but the internal version was targeting humble so that's what I'd rebased on. |
This Commit builds on a rebased PR ros-controls#300 The Original author @livanov93 was in 2022 open sourcing part of a PickNik package form 2021. This commit brings the internal picknik and previously open PR ros-controls#300 back in sync and rebases the open PR onto humble.
Signed-off-by: Alex Moriarty <[email protected]>
Unclear what the state of these tests were from original PR and if they were finished because it was marked as Work in Progress. This change makes the tests pass Signed-off-by: Alex Moriarty <[email protected]>
@@ -43,7 +43,7 @@ TEST_F(TwistControllerTest, joint_names_parameter_not_set) | |||
ASSERT_TRUE(controller_->joint_name_.empty()); | |||
ASSERT_TRUE(controller_->interface_names_.empty()); | |||
|
|||
controller_->get_node()->set_parameter({"joint", joint_name_}); | |||
controller_->get_node()->set_parameter({"interface_names", interface_names_}); |
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 test was called joint_names_parameter_not_set
but was setting the joint param.
The following test was called interface_parameter_not_set
but was setting interface_name parameter.
These two tests just check to it isn't possible to configure the controller with missing mandatory parameters.
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.
That is correct, could be that additional work was required.
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.
We have to swith to generate_parameter_library
anyway and then those tests get partially obsolete.
ASSERT_EQ(wait_for(controller_->twist_command_subscriber_), rclcpp::WaitResultKind::Ready); | ||
|
||
// process callbacks | ||
rclcpp::spin_some(controller_->get_node()->get_node_base_interface()); | ||
ASSERT_TRUE(controller_->wait_for_commands(executor)); |
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 wait_for
resulted in rclcpp throwing an exception, there was a wait_for_commands
which looks like it was intended for this. A similar pattern exists in the other controller tests.
ros2_controllers/admittance_controller/test/test_admittance_controller.cpp
Lines 268 to 269 in 6793e02
publish_commands(); | |
ASSERT_TRUE(controller_->wait_for_commands(executor)); |
I've taken over this Branch & PR from @livanov93 and it's ready for another review. |
Signed-off-by: Alex Moriarty <[email protected]>
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.
@moriarty Looks fine, please take a look on the suggestions. Although I can't approve as PR owner
cartesian_controllers/CMakeLists.txt
Outdated
|
||
# find dependencies | ||
find_package(ament_cmake REQUIRED) | ||
find_package(ament_cmake_ros REQUIRED) |
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 not needed I think
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.
yes I removed in 87717e7
cartesian_controllers/CMakeLists.txt
Outdated
|
||
# find dependencies | ||
find_package(ament_cmake REQUIRED) | ||
find_package(ament_cmake_ros REQUIRED) |
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.
find_package(ament_cmake_ros REQUIRED) |
<maintainer email="[email protected]">Lovro Ivanov</maintainer> | ||
<license>Apache-2.0</license> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> |
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.
Don't add it, remove it from CMakeLists.txt
@@ -43,7 +43,7 @@ TEST_F(TwistControllerTest, joint_names_parameter_not_set) | |||
ASSERT_TRUE(controller_->joint_name_.empty()); | |||
ASSERT_TRUE(controller_->interface_names_.empty()); | |||
|
|||
controller_->get_node()->set_parameter({"joint", joint_name_}); | |||
controller_->get_node()->set_parameter({"interface_names", interface_names_}); |
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.
That is correct, could be that additional work was required.
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #300 +/- ##
==========================================
- Coverage 35.78% 32.43% -3.36%
==========================================
Files 189 7 -182
Lines 17570 666 -16904
Branches 11592 358 -11234
==========================================
- Hits 6287 216 -6071
+ Misses 994 157 -837
+ Partials 10289 293 -9996
Flags with carried forward coverage won't be shown. Click here to find out more.
|
👍 and as I am not PR owner I can't mark any comments as resolved 😆 I will run the fixup the formatting. The Rolling - ABI compatibility is known to be broken. I noticed it when testing locally and had to clone control_msgs to get ros-controls/control_msgs#86 and it is causing a lot of CI jobs to fail #565 (comment) |
Signed-off-by: Alex Moriarty <[email protected]>
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.
Recommend renaming the controller to ForwardTwistController
@bmagyar should we then add those into forwarding_controllers
package? We should probably create one then. Then we can also clean a bit of a mess with position_controllers
, velocity_controllers
and so on. Which are mostly forwarding controllers anyway. IMHO we have too many packages, and can reduce the amount of code by large putting all those controllers together.
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.
Please update file according to current standard of other controllers
@@ -0,0 +1,72 @@ | |||
// Copyright 2021, PickNik Inc. |
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.
// Copyright 2021, PickNik Inc. | |
// Copyright 2023, PickNik Inc. |
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.
2021 is correct, its the date this file was created.
realtime_tools::RealtimeBuffer<std::shared_ptr<CmdType>> rt_command_ptr_; | ||
rclcpp::Subscription<CmdType>::SharedPtr twist_command_subscriber_; | ||
|
||
std::string logger_name_; |
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.
We don't use this anymore. We rather use get_node()->get_logger()
to get an appropriate logger name. This is a pattern in other controllers.
@@ -0,0 +1,49 @@ | |||
// Copyright 2021, PickNik Inc. |
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.
// Copyright 2021, PickNik Inc. | |
// Copyright 2023, PickNik Inc. |
@@ -0,0 +1,149 @@ | |||
// Copyright 2021, PickNik Inc. |
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.
// Copyright 2021, PickNik Inc. | |
// Copyright 2023, PickNik Inc. |
{ | ||
try | ||
{ | ||
auto_declare<std::vector<std::string>>("interface_names", std::vector<std::string>()); |
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.
Please convert this to use generate_parameter_library
} | ||
catch (const std::exception & e) | ||
{ | ||
fprintf(stderr, "Exception thrown during init stage with message: %s \n", e.what()); |
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 actually quite often a pattern in these use-cases.
} | ||
|
||
twist_command_subscriber_ = get_node()->create_subscription<CmdType>( | ||
"~/commands", rclcpp::SystemDefaultsQoS(), |
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.
We use reference
now. See this file
"~/commands", rclcpp::SystemDefaultsQoS(), | |
"~/reference", rclcpp::SystemDefaultsQoS(), |
@@ -43,7 +43,7 @@ TEST_F(TwistControllerTest, joint_names_parameter_not_set) | |||
ASSERT_TRUE(controller_->joint_name_.empty()); | |||
ASSERT_TRUE(controller_->interface_names_.empty()); | |||
|
|||
controller_->get_node()->set_parameter({"joint", joint_name_}); | |||
controller_->get_node()->set_parameter({"interface_names", interface_names_}); |
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.
We have to swith to generate_parameter_library
anyway and then those tests get partially obsolete.
* Add picknik_controllers The purpose of picknik_controllers repository is hold controllers that we are in the process of open sourcing and upstreaming. The controllers in this repository have been prefixed with `picknik_` so that if they are accepted upstream we will drop the prefix and release the prefixed versions with deprication warnings. - picknik_reset_fault_controller has been discussed here https://roscontrol.slack.com/archives/C01HA09KDLH/p1686332900429009 - picknik_twist_controller ros-controls/ros2_controllers#300 These do not have a gbp-release package and have not been release they are currently source only. Following the steps outlined here: https://docs.ros.org/en/rolling/How-To-Guides/Releasing/First-Time-Release.html This PR is for step 2 1. Be part of a release team: ros2-gbp/ros2-gbp-github-org#281 2. https://docs.ros.org/en/rolling/How-To-Guides/Releasing/Release-Team-Repository.html#create-a-new-release-repository Signed-off-by: Alex Moriarty <[email protected]> * fixup: remove the release Signed-off-by: Alex Moriarty <[email protected]> * fixup repo typo - PickNikRobots -> PickNikRobotics Signed-off-by: Alex Moriarty <[email protected]> --------- Signed-off-by: Alex Moriarty <[email protected]>
Increasing version of package(s) in repository `picknik_controllers` to `0.0.1-1`: - upstream repository: https://github.com/PickNikRobotics/picknik_controllers.git - release repository: https://github.com/ros2-gbp/picknik_controllers-release.git - distro file: `rolling/distribution.yaml` - bloom version: `0.11.2` - previous version for package: `null` ``` * Initial Release of picknik_reset_fault_controller * Originally this was used internally and there was an attempt to release it to ros2_controllers * After discussion with the ros2 controllers WG over slack we have decided to open source it here first * The goal is to still move this upstream but it can be worked on here first and moved in the future * fault_controller -> picknik_reset_fault_controller (ros#2 <PickNikRobotics/picknik_controllers#2>) * fault_controller -> picknik_reset_fault_controller This commit does two things: 1) renames fault_controller to reset_fault_controller 2) prefixes with picknik_ The first change, is to be more specific what this controller is used for. The second change is because we want to move this controller into ros2_controllers and when that is complete we can drop the picknik_ and depricate this version allowing for a transition period. --------- * Contributors: Alexander Moriarty @moriarty, Anthony Baker @abake48, @livanov93, @destogl, @MarqRazz, @Abishalini, @JafarAbdi ``` ``` * Initial Release of picknik_twist_controller * Originally this was used internally and there was an attempt to release it to ros2_controllers here: ros-controls/ros2_controllers#300 * The goal is to still move this upstream but it needs to be refactored before going upstream. * twist_controller -> picknik_twist_controller (ros#3 <PickNikRobotics/picknik_controllers#3>) * twist_controller -> picknik_twist_controller 1. prefix twist_controller with picknik_twist_controller When we merge twist_controller into ros2_controllers we can depricate this one and not have naming conflicts as users migrate * cmake: 3.8 -> 3.16 bump to oldest version used on Ubuntu Focal + ROS 2 Humble https://www.ros.org/reps/rep-2000.html#humble-hawksbill-may-2022-may-2027 --------- * Contributors: Alexander Moriarty @moriarty, Anthony Baker @abake48, @livanov93, @destogl, @MarqRazz, @Abishalini, @JafarAbdi ``` Signed-off-by: Alexander Moriarty <[email protected]>
PR info:
geometry_msgs/TwistStamped
TODOs: