-
Notifications
You must be signed in to change notification settings - Fork 124
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 hold_joints
parameter
#251
Add hold_joints
parameter
#251
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.
Thanks for the change! LGTM!
After discussion with @christophfroehlich
We can add a new option for now, as we are limited to one control mode per run of the simulation. Ultimately, I think it will make sense to be able to switch the control modes dynamically once the simulation starts. We can try to aim this for Jazzy. If we can get this switching done, then we can remove this option, as we can achieve the same by switching the control mode to effort.
Ideally, the behavior would be at startup we will have the robot maintaining the position, and then when you switch from position or velocity active controllers to inactive mode, they maintain the old reference, and for the effort based controller, the reference will be set to zero.
What do you think about this new approach for future?
@@ -128,6 +131,18 @@ bool GazeboSystem::initSim( | |||
return false; | |||
} | |||
|
|||
try { | |||
this->dataPtr->hold_joints_ = this->nh_->get_parameter("hold_joints").as_bool(); | |||
} catch (const std::exception & e) { |
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 exception
@@ -306,6 +312,11 @@ void GazeboRosControlPlugin::Load(gazebo::physics::ModelPtr parent, sdf::Element | |||
RCLCPP_DEBUG( | |||
impl_->model_nh_->get_logger(), "Loaded hardware interface %s!", | |||
robot_hw_sim_type_str_.c_str()); | |||
try { | |||
node_ros2->declare_parameter("hold_joints", rclcpp::ParameterValue(hold_joints)); | |||
} catch (const std::exception & e) { |
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 exception
@ahcorde not exactly sure what you requested, I added now explicit catch statements for the exceptions written in the docstring of the rclcpp functions. Or do you have another resource on how to write that properly? |
My suggestion was about #include <exception> But this change is also fine |
Ah 😁 I thought too complicated. Thx! |
@ahcorde Could we backport this please? rolling won't be released any more. |
@Mergifyio backport humble iron |
✅ Backports have been created
|
(cherry picked from commit 7682dce) # Conflicts: # gazebo_ros2_control/src/gazebo_system.cpp
(cherry picked from commit 7682dce) # Conflicts: # gazebo_ros2_control/src/gazebo_system.cpp
Co-authored-by: Christoph Froehlich <[email protected]>
Co-authored-by: Christoph Froehlich <[email protected]>
@HPCLOL posted a use case of gazebo in ros-controls/ros2_controllers#875:
If the simulation is started with an inactive controller, the robot should move with gravity as if the joints were passive.
As discussed with #250 this is currently not possible. This PR adds an parameter to enable this behavior (again).
GazeboSystem
this parameter parsed from the gazebo plugin without changing API. Therefore, I used a ROS parameter of the gazebo_ros2_control node to pass the information.The result looks like this if no controller was spawned:
passive_rrbot.mp4