Skip to content
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

Added controller manager xml argument #255

Merged
merged 4 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ robot hardware interfaces between *ros2_control* and Gazebo Classic.
<robot_param>robot_description</robot_param>
<robot_param_node>robot_state_publisher</robot_param_node>
<parameters>$(find gazebo_ros2_control_demos)/config/cart_controller.yaml</parameters>
<controller_manager_name>simulation_controller_manager</controller_manager_name>
</plugin>
</gazebo>

Expand All @@ -156,6 +157,7 @@ The *gazebo_ros2_control* ``<plugin>`` tag also has the following optional child
* ``<robot_param_node>``: Name of the node where the ``robot_param`` is located, defaults to ``robot_state_publisher``
* ``<parameters>``: YAML file with the configuration of the controllers
* ``<hold_joints>``: if set to true (default), it will hold the joints' position if their interface was not claimed, e.g., the controller hasn't been activated yet.
* ``<controller_manager_name>``: Set controller manager name (default: ``controller_manager``)

Default gazebo_ros2_control Behavior
-----------------------------------------------------------
Expand Down
9 changes: 8 additions & 1 deletion gazebo_ros2_control/src/gazebo_ros2_control_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ void GazeboRosControlPlugin::Load(gazebo::physics::ModelPtr parent, sdf::Element
sdf->GetElement("hold_joints")->Get<bool>();
}

// Get controller manager node name
std::string controllerManagerNodeName{"controller_manager"};

if (sdf->HasElement("controller_manager_name")) {
controllerManagerNodeName = sdf->GetElement("controller_manager_name")->Get<std::string>();
}

// There's currently no direct way to set parameters to the plugin's node
// So we have to parse the plugin file manually and set it to the node's context.
auto rcl_context = impl_->model_nh_->get_node_base_interface()->get_context()->get_rcl_context();
Expand Down Expand Up @@ -360,7 +367,7 @@ void GazeboRosControlPlugin::Load(gazebo::physics::ModelPtr parent, sdf::Element
new controller_manager::ControllerManager(
std::move(resource_manager_),
impl_->executor_,
"controller_manager",
controllerManagerNodeName,
impl_->model_nh_->get_namespace()));
impl_->executor_->add_node(impl_->controller_manager_);

Expand Down
Loading