$\color{white}\colorbox{FE9227}{Reaching advanced proficiency and preparing for mastery!}$

▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░ 85.8%


The Gazebo ros2_control package is a ROS 2 package for integrating the ros2_control controller architecture with the Gazebo simulator. This package provides a Gazebo plugin that instantiates a ros2_control controller manager and connects it to a Gazebo model.

The ros2_control library plugin has to be first added to your Gazebo plugin imports within your robot XACRO, so that your simulation environment knows how to interpret your ros2_control tags.

Table of Contents

1. Plugin import

The Gazebo plugin needs to be added to your URDF that actually parses the ros2_control tags and loads the appropriate hardware interfaces and controller manager. When importing the plugin, there are some parameters that must be set to properly configure parsing.

<gazebo>
		<plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control" >
				<namespace>${robot_namespace}</namespace>
				<robot_param>robot_description</robot_param>
				<robot_param_node>robot_state_publisher</robot_param_node>
				<parameters>$(find robot_control)/config/controllers.yaml</parameters>
		</plugin>
</gazebo>

The namespace argument is useful when you are planning to run multiple robots within the same simulation environment from the same machine. This allows the plugins and controllers to subscribe to their appropriate robot.

The robot_param and robot_param_node declare the location of the robot_description (URDF) on the parameter server and the name of the node where the robot_param is located.

The parameters defines the location of the YAML file that configures the controllers.

2. Add ros2_control tag

To use ros2_control with your robot, you need to add some additional elements to your URDF. You should include the tag <ros2_control> to access and control the robot interfaces. We should include:

<ros2_control name="GazeboSystem" type="system">
		<hardware>
				<plugin>gazebo_ros2_control/GazeboSystem</plugin>
		</hardware>
		<joint>
				<command_interface name="effort">
						<param name="min">-1000</param>
						<param name="max">1000</param>
				</command_interface>
				<state_interface>
						<param name="initial_value">1.0</param>
				</state_interface>
				<state_interface name="velocity" />
				<state_interface name="effort" />
		</joint>
</ros2_control>

a. Using mimic joints in simulation

To use mimic joints in gazebo_ros2_control you should define its parameters to your URDF. We should include: