You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 17, 2025. It is now read-only.
This is a ROS 2 package for integrating the `ros2_control` controller architecture with the [Gazebo](http://gazebosim.org/) simulator.
5
4
6
5
This package provides a Gazebo plugin which instantiates a `ros2_control` controller manager and connects it to a Gazebo model.
@@ -13,7 +12,7 @@ It is running Gazebo and some other ROS 2 nodes.
13
12
14
13
## Video + Pictures
15
14
16
-

15
+

17
16
18
17
## Running
19
18
@@ -61,47 +60,59 @@ ros2 run gazebo_ros2_control_demos example_position
61
60
```
62
61
63
62
64
-
## Add transmission elements to a URDF
63
+
## Add ros2_control tag to a URDF
65
64
66
-
To use `ros2_control` with your robot, you need to add some additional elements to your URDF. The `<transmission>` element is used to link actuators to joints, see the `<transmission>` spec for exact XML format.
65
+
To use `ros2_control` with your robot, you need to add some additional elements to your URDF.
66
+
You should include the tag `<ros2_control>` to access and control the robot interfaces. We should
67
+
include
67
68
68
-
For the purposes of `gazebo_ros2_control` in its current implementation, the only important information in these transmission tags are:
69
+
- a specific `<plugin>` for our robot
70
+
-`<joint>` tag including the robot controllers: commands and states.
69
71
70
-
-`<joint name="">` the name must correspond to a joint else where in your URDF
71
-
-`<type>` the type of transmission. Currently only `transmission_interface/SimpleTransmission` is implemented.
72
-
-`<hardwareInterface>` within the `<actuator>` and `<joint>` tags, this tells the `gazebo_ros2_control` plugin what hardware interface to load (position, velocity or effort interfaces).
72
+
```xml
73
+
<ros2_controlname="GazeboSystem"type="system">
74
+
<hardware>
75
+
<plugin>gazebo_ros2_control/GazeboSystem</plugin>
76
+
</hardware>
77
+
<jointname="slider_to_cart">
78
+
<command_interfacename="effort">
79
+
<paramname="min">-1000</param>
80
+
<paramname="max">1000</param>
81
+
</command_interface>
82
+
<state_interfacename="position"/>
83
+
<state_interfacename="velocity"/>
84
+
<state_interfacename="effort"/>
85
+
</joint>
86
+
</ros2_control>
87
+
```
73
88
74
89
## Add the gazebo_ros2_control plugin
75
90
76
-
In addition to the transmission tags, a Gazebo plugin needs to be added to your URDF that
77
-
actually parses the transmission tags and loads the appropriate hardware interfaces and
91
+
In addition to the `ros2_control` tags, a Gazebo plugin needs to be added to your URDF that
92
+
actually parses the `ros2_control` tags and loads the appropriate hardware interfaces and
78
93
controller manager. By default the `gazebo_ros2_control` plugin is very simple, though it is also
79
94
extensible via an additional plugin architecture to allow power users to create their own custom
80
95
robot hardware interfaces between `ros2_control` and Gazebo.
The `gazebo_ros2_control``<plugin>` tag also has the following optional child elements:
95
108
96
-
-`<control_period>`: The period of the controller update (in seconds), defaults to Gazebo's period
97
109
-`<robot_param>`: The location of the `robot_description` (URDF) on the parameter server, defaults to `robot_description`
98
110
-`<robot_param_node>`: Name of the node where the `robot_param` is located, defauls to `robot_state_publisher`
99
-
-`<robot_sim_type>`: The pluginlib name of a custom robot sim interface to be used, defaults to `gazebo_ros2_control/DefaultRobotHWSim`
100
111
-`<parameters>`: YAML file with the configuration of the controllers
101
112
102
113
#### Default gazebo_ros2_control Behavior
103
114
104
-
By default, without a `<robot_sim_type>` tag, `gazebo_ros2_control` will attempt to get all of the information it needs to interface with a ros2_control-based controller out of the URDF. This is sufficient for most cases, and good for at least getting started.
115
+
By default, without a `<plugin>` tag, `gazebo_ros2_control` will attempt to get all of the information it needs to interface with a ros2_control-based controller out of the URDF. This is sufficient for most cases, and good for at least getting started.
105
116
106
117
The default behavior provides the following ros2_control interfaces:
107
118
@@ -113,14 +124,21 @@ The default behavior provides the following ros2_control interfaces:
113
124
114
125
The `gazebo_ros2_control` Gazebo plugin also provides a pluginlib-based interface to implement custom interfaces between Gazebo and `ros2_control` for simulating more complex mechanisms (nonlinear springs, linkages, etc).
115
126
116
-
These plugins must inherit `gazebo_ros2_control::RobotHWSim` which implements a simulated `ros2_control``hardware_interface::RobotHW`. RobotHWSim provides API-level access to read and command joint properties in the Gazebo simulator.
117
-
118
-
The respective RobotHWSim sub-class is specified in a URDF model and is loaded when the robot model is loaded. For example, the following XML will load the default plugin (same behavior as when using no `<robot_sim_type>` tag):
127
+
These plugins must inherit `gazebo_ros2_control::GazeboSystemInterface` which implements a simulated `ros2_control`
128
+
`hardware_interface::SystemInterface`. SystemInterface provides API-level access to read and command joint properties.
119
129
130
+
The respective GazeboSystemInterface sub-class is specified in a URDF model and is loaded when the
131
+
robot model is loaded. For example, the following XML will load the default plugin:
@@ -138,13 +156,13 @@ Use the tag `<parameters>` inside `<plugin>` to set the YAML file with the contr
138
156
```
139
157
140
158
This controller publishes the state of all resources registered to a
141
-
`hardware_interface::JointStateInterface` to a topic of type `sensor_msgs/msg/JointState`. The following is a basic configuration of the controller.
159
+
`hardware_interface::StateInterface` to a topic of type `sensor_msgs/msg/JointState`.
160
+
The following is a basic configuration of the controller.
142
161
143
162
```yaml
144
163
joint_state_controller:
145
164
ros__parameters:
146
165
type: joint_state_controller/JointStateController
147
-
publish_rate: 50
148
166
```
149
167
150
168
This controller creates an action called `/cart_pole_controller/follow_joint_trajectory` of type `control_msgs::action::FollowJointTrajectory`.
@@ -157,37 +175,7 @@ cart_pole_controller:
157
175
- slider_to_cart
158
176
write_op_modes:
159
177
- slider_to_cart
160
-
state_publish_rate: 25
161
-
action_monitor_rate: 20
162
-
constraints:
163
-
stopped_velocity_tolerance: 0.05
164
-
goal_time: 5
165
-
```
166
-
167
-
#### Setting PID gains
168
-
169
-
To set the PID gains for a specific joint you need to define them inside `<plugin><ros></plugin></ros>`. Using the generic way of defining parameters with `gazebo_ros`. The name of the parameter correspond the name of the joint followed by a dot and the name of the parameter: `p`, `i`, `d`, `i_clamp_max`, `i_clamp_min` and `antiwindup`.
@@ -209,30 +197,18 @@ When the Gazebo world is launched you can run some of the following commads to m
209
197
```bash
210
198
ros2 run gazebo_ros2_control_demos example_position
211
199
ros2 run gazebo_ros2_control_demos example_velocity
200
+
ros2 run gazebo_ros2_control_demos example_effort
212
201
```
213
202
214
-
To get or modify the values of the PID controller you can run the following commands:
203
+
#### Gazebo + Moveit2 + ROS 2
215
204
216
-
```bash
217
-
ros2 param get /gazebo_ros2_control slider_to_cart.p
218
-
ros2 param get /gazebo_ros2_control slider_to_cart.i
219
-
ros2 param get /gazebo_ros2_control slider_to_cart.d
220
-
ros2 param get /gazebo_ros2_control slider_to_cart.i_clamp_max
221
-
ros2 param get /gazebo_ros2_control slider_to_cart.i_clamp_min
222
-
```
205
+
This example works with [ROS 2 Foxy](https://index.ros.org/doc/ros2/Installation/Foxy/).
206
+
You should install Moveit2 from sources, the instructions are available in this [link](https://moveit.ros.org/install-moveit2/source/).
207
+
208
+
The repository with all the required packages are in the [gazebo_ros_demos](https://github.com/ros-simulation/gazebo_ros_demos/tree/ahcorde/port/ros2).
223
209
224
210
```bash
225
-
ros2 param set /gazebo_ros2_control slider_to_cart.p 50.0
226
-
ros2 param set /gazebo_ros2_control slider_to_cart.i 10.0
227
-
ros2 param set /gazebo_ros2_control slider_to_cart.d 15.0
228
-
ros2 param set /gazebo_ros2_control slider_to_cart.i_clamp_max 3.0
229
-
ros2 param set /gazebo_ros2_control slider_to_cart.i_clamp_min -3.0
0 commit comments