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
Copy file name to clipboardExpand all lines: source/Tutorials/Advanced/Simulators/Webots.rst
+15-5
Original file line number
Diff line number
Diff line change
@@ -204,31 +204,41 @@ You have to specify in the constructor which world file the simulator will open.
204
204
:dedent: 4
205
205
:lines: 14-16
206
206
207
+
A supervisor Robot is always automatically added to the world file by ``WebotsLauncher``.
208
+
This robot is controlled by the custom node ``Ros2Supervisor``, which must also be started using the ``Ros2SupervisorLauncher``.
209
+
This node allows to spawn URDF robots directly into the world, and it also publishes useful topics like ``/clock``.
210
+
211
+
.. literalinclude:: Code/robot_launch.py
212
+
:language: python
213
+
:dedent: 4
214
+
:lines: 18
215
+
207
216
Then, the ROS node interacting with the simulated robot is created.
208
217
This node, named ``driver``, is located in the ``webots_ros2_driver`` package.
209
218
The node will be able to communicate with the simulated robot by using a custom protocol based on IPC and shared memory.
210
219
In your case, you need to run a single instance of this node, because you have a single robot in the simulation.
211
220
But if you had more robots in the simulation, you would have to run one instance of this node per robot.
221
+
``WEBOTS_CONTROLLER_URL`` is used to define the name of the robot the driver should connect to.
212
222
The ``robot_description`` parameter holds the contents of the URDF file which refers to the ``my_robot_driver.py`` Python plugin.
213
223
214
224
.. literalinclude:: Code/robot_launch.py
215
225
:language: python
216
226
:dedent: 4
217
-
:lines:18-25
227
+
:lines:20-28
218
228
219
-
After that, the two nodes are set to be launched in the ``LaunchDescription`` constructor:
229
+
After that, the three nodes are set to be launched in the ``LaunchDescription`` constructor:
220
230
221
231
.. literalinclude:: Code/robot_launch.py
222
232
:language: python
223
233
:dedent: 4
224
-
:lines:27-29
234
+
:lines:30-33
225
235
226
236
Finally, an optional part is added in order to shutdown all the nodes once Webots terminates (e.g., when it gets closed from the graphical user interface).
227
237
228
238
.. literalinclude:: Code/robot_launch.py
229
239
:language: python
230
240
:dedent: 8
231
-
:lines:30-35
241
+
:lines:34-39
232
242
233
243
6 Modify the setup.py file
234
244
^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -351,7 +361,7 @@ Go to the file ``robot_launch.py`` and replace ``def generate_launch_description
351
361
352
362
.. literalinclude:: Code/robot_launch_sensor.py
353
363
:language: python
354
-
:lines: 10-42
364
+
:lines: 10-46
355
365
356
366
This will create an ``obstacle_avoider`` node that will be included in the ``LaunchDescription``.
0 commit comments