|
1 | 1 | # gazebo_ros2_control |
2 | 2 |
|
3 | | -This is a ROS 2 package for integrating the `ros2_control` controller architecture with the [Gazebo](http://gazebosim.org/) simulator. |
| 3 | +This is a ROS 2 package for integrating the `ros2_control` controller architecture with the [Gazebo Classic](http://gazebosim.org/) simulator. |
4 | 4 |
|
5 | 5 | This package provides a Gazebo plugin which instantiates a `ros2_control` controller manager and connects it to a Gazebo model. |
6 | 6 |
|
7 | | -# Usage |
| 7 | +## Documentation |
| 8 | +See the [documentation file](doc/index.rst) or [control.ros.org](https://control.ros.org/master/doc/simulators/gazebo_ros2_control/doc/index.html) |
8 | 9 |
|
9 | | -This repository contains the contents for testing gazebo_ros2_control |
| 10 | +## Build status |
10 | 11 |
|
11 | | -It is running Gazebo and some other ROS 2 nodes. |
12 | | - |
13 | | -## Video + Pictures |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | -## Running |
20 | | - |
21 | | -### Modifying or building your own |
22 | | - |
23 | | -```bash |
24 | | -cd Docker |
25 | | -docker build -t gazebo_ros2_control . |
26 | | -``` |
27 | | - |
28 | | -### To run the demo |
29 | | - |
30 | | -#### Using Docker |
31 | | - |
32 | | -Docker allows us to run the demo without GUI if we don't configure it properly. The following command runs the demo without GUI: |
33 | | - |
34 | | -```bash |
35 | | -docker run -it --rm --name gazebo_ros2_control_demo --net host gazebo_ros2_control ros2 launch gazebo_ros2_control_demos cart_example_position.launch.py gui:=false |
36 | | -``` |
37 | | - |
38 | | -The in your local machine you can run the Gazebo client: |
39 | | - |
40 | | -```bash |
41 | | -gzclient |
42 | | -``` |
43 | | - |
44 | | -#### Using Rocker |
45 | | - |
46 | | -To run the demo with GUI we are going to use [rocker](https://github.com/osrf/rocker/) which is a tool to run docker |
47 | | -images with customized local support injected for things like nvidia support. And user id specific files for cleaner |
48 | | -mounting file permissions. You can install this tool with the following [instructions](https://github.com/osrf/rocker/#installation). |
49 | | - |
50 | | -The following command will launch Gazebo: |
51 | | - |
52 | | -```bash |
53 | | -rocker --x11 --nvidia --name gazebo_ros2_control_demo gazebo_ros2_control:latest |
54 | | -``` |
55 | | - |
56 | | -The following commands allow to move the cart in the rail: |
57 | | - |
58 | | -```bash |
59 | | -docker exec -it gazebo_ros2_control_demo bash |
60 | | -source /home/ros2_ws/install/setup.bash |
61 | | -ros2 run gazebo_ros2_control_demos example_position |
62 | | -``` |
63 | | - |
64 | | - |
65 | | -## Add ros2_control tag to a URDF |
66 | | - |
67 | | -To use `ros2_control` with your robot, you need to add some additional elements to your URDF. |
68 | | -You should include the tag `<ros2_control>` to access and control the robot interfaces. We should |
69 | | -include |
70 | | - |
71 | | - - a specific `<plugin>` for our robot |
72 | | - - `<joint>` tag including the robot controllers: commands and states. |
73 | | - |
74 | | -```xml |
75 | | -<ros2_control name="GazeboSystem" type="system"> |
76 | | - <hardware> |
77 | | - <plugin>gazebo_ros2_control/GazeboSystem</plugin> |
78 | | - </hardware> |
79 | | - <joint name="slider_to_cart"> |
80 | | - <command_interface name="effort"> |
81 | | - <param name="min">-1000</param> |
82 | | - <param name="max">1000</param> |
83 | | - </command_interface> |
84 | | - <state_interface name="position"> |
85 | | - <param name="initial_value">1.0</param> |
86 | | - </state_interface> |
87 | | - <state_interface name="velocity"/> |
88 | | - <state_interface name="effort"/> |
89 | | - </joint> |
90 | | -</ros2_control> |
91 | | -``` |
92 | | - |
93 | | -### Using mimic joints in simulation |
94 | | - |
95 | | -To use `mimic` joints in `gazebo_ros2_control` you should define its parameters to your URDF. |
96 | | -We should include: |
97 | | - |
98 | | -- `<mimic>` tag to the mimicked joint ([detailed manual(https://wiki.ros.org/urdf/XML/joint)) |
99 | | -- `mimic` and `multiplier` parameters to joint definition in `<ros2_control>` tag |
100 | | - |
101 | | -```xml |
102 | | -<joint name="left_finger_joint" type="prismatic"> |
103 | | - <mimic joint="right_finger_joint"/> |
104 | | - <axis xyz="0 1 0"/> |
105 | | - <origin xyz="0.0 0.48 1" rpy="0.0 0.0 3.1415926535"/> |
106 | | - <parent link="base"/> |
107 | | - <child link="finger_left"/> |
108 | | - <limit effort="1000.0" lower="0" upper="0.38" velocity="10"/> |
109 | | -</joint> |
110 | | -``` |
111 | | - |
112 | | -```xml |
113 | | -<joint name="left_finger_joint"> |
114 | | - <param name="mimic">right_finger_joint</param> |
115 | | - <param name="multiplier">1</param> |
116 | | - <command_interface name="position"/> |
117 | | - <state_interface name="position"/> |
118 | | - <state_interface name="velocity"/> |
119 | | - <state_interface name="effort"/> |
120 | | -</joint> |
121 | | -``` |
122 | | - |
123 | | - |
124 | | -## Add the gazebo_ros2_control plugin |
125 | | - |
126 | | -In addition to the `ros2_control` tags, a Gazebo plugin needs to be added to your URDF that |
127 | | -actually parses the `ros2_control` tags and loads the appropriate hardware interfaces and |
128 | | -controller manager. By default the `gazebo_ros2_control` plugin is very simple, though it is also |
129 | | -extensible via an additional plugin architecture to allow power users to create their own custom |
130 | | -robot hardware interfaces between `ros2_control` and Gazebo. |
131 | | - |
132 | | -```xml |
133 | | -<gazebo> |
134 | | - <plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control"> |
135 | | - <robot_param>robot_description</robot_param> |
136 | | - <robot_param_node>robot_state_publisher</robot_param_node> |
137 | | - <parameters>$(find gazebo_ros2_control_demos)/config/cartpole_controller.yaml</parameters> |
138 | | - </plugin> |
139 | | -</gazebo> |
140 | | -``` |
141 | | - |
142 | | -The `gazebo_ros2_control` `<plugin>` tag also has the following optional child elements: |
143 | | - |
144 | | - - `<robot_param>`: The location of the `robot_description` (URDF) on the parameter server, defaults to `robot_description` |
145 | | - - `<robot_param_node>`: Name of the node where the `robot_param` is located, defaults to `robot_state_publisher` |
146 | | - - `<parameters>`: YAML file with the configuration of the controllers |
147 | | - |
148 | | -#### Default gazebo_ros2_control Behavior |
149 | | - |
150 | | -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. |
151 | | - |
152 | | -The default behavior provides the following ros2_control interfaces: |
153 | | - |
154 | | - - hardware_interface::JointStateInterface |
155 | | - - hardware_interface::EffortJointInterface |
156 | | - - hardware_interface::VelocityJointInterface |
157 | | - |
158 | | -#### Advanced: custom gazebo_ros2_control Simulation Plugins |
159 | | - |
160 | | -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). |
161 | | - |
162 | | -These plugins must inherit `gazebo_ros2_control::GazeboSystemInterface` which implements a simulated `ros2_control` |
163 | | -`hardware_interface::SystemInterface`. SystemInterface provides API-level access to read and command joint properties. |
164 | | - |
165 | | -The respective GazeboSystemInterface sub-class is specified in a URDF model and is loaded when the |
166 | | -robot model is loaded. For example, the following XML will load the default plugin: |
167 | | -```xml |
168 | | -<ros2_control name="GazeboSystem" type="system"> |
169 | | - <hardware> |
170 | | - <plugin>gazebo_ros2_control/GazeboSystem</plugin> |
171 | | - </hardware> |
172 | | - ... |
173 | | -<ros2_control> |
174 | | -<gazebo> |
175 | | - <plugin name="gazebo_ros2_control" filename="libgazebo_ros2_control.so"> |
176 | | - ... |
177 | | - </plugin> |
178 | | -</gazebo> |
179 | | -``` |
180 | | - |
181 | | -#### Set up controllers |
182 | | - |
183 | | -Use the tag `<parameters>` inside `<plugin>` to set the YAML file with the controller configuration. |
184 | | - |
185 | | -```xml |
186 | | -<gazebo> |
187 | | - <plugin name="gazebo_ros2_control" filename="libgazebo_ros2_control.so"> |
188 | | - <parameters>$(find gazebo_ros2_control_demos)/config/cartpole_controller.yaml</parameters> |
189 | | - </plugin> |
190 | | -<gazebo> |
191 | | -``` |
192 | | - |
193 | | -This controller publishes the state of all resources registered to a |
194 | | -`hardware_interface::StateInterface` to a topic of type `sensor_msgs/msg/JointState`. |
195 | | -The following is a basic configuration of the controller. |
196 | | - |
197 | | -```yaml |
198 | | -joint_state_controller: |
199 | | - ros__parameters: |
200 | | - type: joint_state_controller/JointStateController |
201 | | -``` |
202 | | -
|
203 | | -This controller creates an action called `/cart_pole_controller/follow_joint_trajectory` of type `control_msgs::action::FollowJointTrajectory`. |
204 | | - |
205 | | -```yaml |
206 | | -cart_pole_controller: |
207 | | - ros__parameters: |
208 | | - type: joint_trajectory_controller/JointTrajectoryController |
209 | | - joints: |
210 | | - - slider_to_cart |
211 | | - write_op_modes: |
212 | | - - slider_to_cart |
213 | | -``` |
214 | | -#### Executing the examples |
215 | | - |
216 | | -There are some examples in the `gazebo_ros2_control_demos` package. These examples allow to launch a cart in a 30 meter rail. |
217 | | - |
218 | | - |
219 | | - |
220 | | -You can run some of the configuration running the following commands: |
221 | | - |
222 | | -```bash |
223 | | -ros2 launch gazebo_ros2_control_demos cart_example_position.launch.py |
224 | | -ros2 launch gazebo_ros2_control_demos cart_example_velocity.launch.py |
225 | | -ros2 launch gazebo_ros2_control_demos cart_example_effort.launch.py |
226 | | -ros2 launch gazebo_ros2_control_demos diff_drive.launch.py |
227 | | -ros2 launch gazebo_ros2_control_demos tricycle_drive.launch.py |
228 | | -``` |
229 | | - |
230 | | -Send example commands: |
231 | | - |
232 | | -When the Gazebo world is launched you can run some of the following commands to move the cart. |
233 | | - |
234 | | -```bash |
235 | | -ros2 run gazebo_ros2_control_demos example_position |
236 | | -ros2 run gazebo_ros2_control_demos example_velocity |
237 | | -ros2 run gazebo_ros2_control_demos example_effort |
238 | | -ros2 run gazebo_ros2_control_demos example_diff_drive |
239 | | -ros2 run gazebo_ros2_control_demos example_tricycle_drive |
240 | | -``` |
241 | | - |
242 | | -The following example shows parallel gripper with mimic joint: |
243 | | - |
244 | | - |
245 | | - |
246 | | - |
247 | | -```bash |
248 | | -ros2 launch gazebo_ros2_control_demos gripper_mimic_joint_example.launch.py |
249 | | -``` |
250 | | - |
251 | | -Send example commands: |
252 | | - |
253 | | -```bash |
254 | | -ros2 run gazebo_ros2_control_demos example_gripper |
255 | | -``` |
256 | | - |
257 | | -#### Gazebo + Moveit2 + ROS 2 |
258 | | - |
259 | | -This example works with [ROS 2 Foxy](https://index.ros.org/doc/ros2/Installation/Foxy/). |
260 | | -You should install Moveit2 from sources, the instructions are available in this [link](https://moveit.ros.org/install-moveit2/source/). |
261 | | - |
262 | | -The repository with all the required packages are in the [gazebo_ros_demos](https://github.com/ros-controls/gazebo_ros_demos/tree/ahcorde/port/ros2). |
263 | | - |
264 | | -```bash |
265 | | -ros2 launch rrbot_moveit_demo_nodes rrbot_demo.launch.py |
266 | | -``` |
267 | | - |
268 | | - |
| 12 | +ROS 2 Distro | Branch | Build status | Documentation |
| 13 | +:----------: | :----: | :----------: | :-----------: |
| 14 | +**Rolling** | [`master`](https://github.com/ros-controls/gazebo_ros2_control/tree/master) | [](https://github.com/ros-controls/gazebo_ros2_control/actions/workflows/ci.yaml) | [Documentation](https://control.ros.org/master/index.html) <br /> [API Reference](https://control.ros.org/master/doc/api/index.html) |
| 15 | +**Iron** | [`master`](https://github.com/ros-controls/gazebo_ros2_control/tree/master) | [](https://github.com/ros-controls/gazebo_ros2_control/actions/workflows/ci.yaml) | [Documentation](https://control.ros.org/master/index.html) <br /> [API Reference](https://control.ros.org/master/doc/api/index.html) |
| 16 | +**Humble** | [`humble`](https://github.com/ros-controls/gazebo_ros2_control/tree/humble) | [](https://github.com/ros-controls/gazebo_ros2_control/actions/workflows/ci.yaml) | [Documentation](https://control.ros.org/humble/index.html) <br /> [API Reference](https://control.ros.org/humble/doc/api/index.html) |
0 commit comments