Skip to content

Commit

Permalink
Update Setting-up a Robot Simulation (Webots) tutorial to 2023.0.2 (#…
Browse files Browse the repository at this point in the history
…3317) (#3331)

* Update intro to WSL

* Revert "Update intro to WSL"

This reverts commit 52a52d0.

* Update intro to wsl

* Remove windows tabs

* Add windows WSL tab for extern controller code

* Clean tutorial

* Update world with declarations

* Add supervisor node and environment var

* Add ros2supervisorlauncher node creation in launch files

* add env variable for linux

* Update tutorial with explanations

* Update source/Tutorials/Advanced/Simulators/Webots.rst

Co-authored-by: ad-daniel <44834743+ad-daniel@users.noreply.github.com>

* include correct file for supervisor part

* Add WEBOTS_CONTROLLER_URL wsl infos

* cleanup

* Update source/Tutorials/Advanced/Simulators/Webots.rst

Co-authored-by: Olivier Michel <Olivier.Michel@cyberbotics.com>

* Remove confusing sentence

* Update source/Tutorials/Advanced/Simulators/Webots.rst

Co-authored-by: Olivier Michel <Olivier.Michel@cyberbotics.com>

* Squashed commit of the following:

commit 72effa7
Author: Luke Schmitt <85308904+LSinterbotix@users.noreply.github.com>
Date:   Tue Nov 1 17:26:25 2022 -0500

    Fix list formatting on Contact page (#3153)

commit dcd066f
Author: Dan Zimmerman <dan@danzimmerman.com>
Date:   Tue Nov 1 16:29:34 2022 -0400

    Update throttle logging docs with units and data type hints (re: rclcpp/issues/1929) (#3143)

    * Note milliseconds on API Concepts page

    * Add units and types to About Logging page

    Co-authored-by: dan <dan@polarworks.no>
    Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>

commit 375b6cf
Author: definitelyuncertain <saikirann94@gmail.com>
Date:   Fri Oct 28 14:30:22 2022 -0500

    Change to mention explicit requirement for folder names for .msg and .srv files (#3144)

    * Change to mention explicit requirement for folder names for msg and srv files

    From ros2/tutorials#29

    * fix typo

    Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

    * fix rst formatting

    Co-authored-by: Chris Lalancette <clalancette@gmail.com>

    Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
    Co-authored-by: Chris Lalancette <clalancette@gmail.com>

commit da871ef
Author: Sergei Sergienko <divelix1@gmail.com>
Date:   Thu Oct 27 17:20:06 2022 +0300

    fix link to Gazebo-ROS2 bridge + CLI examples (#3139)

    * fix link to Gazebo-ROS2 bridge + CLI examples

    Co-authored-by: Chris Lalancette <clalancette@gmail.com>

commit e19c9b5
Author: Chris Lalancette <clalancette@openrobotics.org>
Date:   Wed Oct 26 16:31:21 2022 -0400

    Update the language to match the source code. (#3135)

    Fallout from #2865

    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

commit a5910a1
Author: Chris Lalancette <clalancette@openrobotics.org>
Date:   Wed Oct 26 08:38:36 2022 -0400

    Shorten the Windows build-from-source path. (#3130)

    * Shorten the Windows build-from-source path.

    This is to keep the total length down below the 260 character
    limit imposed by Windows by default.

    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

commit 8225686
Author: Chris Lalancette <clalancette@openrobotics.org>
Date:   Mon Oct 24 08:30:37 2022 -0400

    Fix up the variable name in the traveling in time (C++) tutorial. (#3115)

    This is just to match what is in the code in the upstream
    repository.

    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

commit 87ab121
Author: Ian Colwell <48106342+icolwell-as@users.noreply.github.com>
Date:   Fri Oct 21 11:07:30 2022 -0400

    Update default WORKING_DIRECTORY for ament_add_gtest() (#3117)

commit 87bf20a
Author: chianfern <chianfern@gmail.com>
Date:   Tue Oct 18 21:36:57 2022 +0800

    Add ParameterDescriptor to 'Using parameters in a class (C++)' (#2865)

    * Rename node name in "Using parameters" C++ tutorial to be consistent with Python tutorial.

    Signed-off-by: Tan Chian Fern <chianfern@gmail.com>
    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

commit 77646ce
Author: George Stavrinos <gstavrinos@protonmail.com>
Date:   Tue Oct 18 15:29:37 2022 +0300

    Fixed Intel's robot SDK repo with the new devkit name + reference to MoveIt2 instead of 1. (#3107)

commit 1d24955
Author: Chris Lalancette <clalancette@openrobotics.org>
Date:   Mon Oct 17 14:06:52 2022 -0400

    Monitor parameter changes: Add note to save callback handle (#3102)

    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

commit 8910a80
Author: David V. Lu!! <davidvlu@gmail.com>
Date:   Fri Oct 14 09:56:14 2022 -0400

    Some testing basics (#3084)

    * Some testing basics

    Signed-off-by: David V. Lu <davidvlu@gmail.com>
    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

commit 8771452
Author: Tomoya Fujita <Tomoya.Fujita@sony.com>
Date:   Fri Oct 14 05:34:20 2022 -0700

    Sony's task for Iron Release. (#3089)

    * Sony's task for Iron Release.

    Signed-off-by: Tomoya.Fujita <Tomoya.Fujita@sony.com>

    * Rearrange and add in links.

    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

    Signed-off-by: Tomoya.Fujita <Tomoya.Fujita@sony.com>
    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
    Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>

commit 2ea9e7d
Author: Yannick Goumaz <61198661+ygoumaz@users.noreply.github.com>
Date:   Fri Oct 14 14:23:13 2022 +0200

    Update Setting-up a Robot Simulation (Webots) tutorial (#3090)

    * Update intro to WSL

    * Update world with declarations

    * Add supervisor node and environment var

    * Update tutorial with explanations

    Co-authored-by: ad-daniel <44834743+ad-daniel@users.noreply.github.com>

commit 0390a50
Author: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Date:   Thu Oct 13 13:42:30 2022 -0400

    fix unresolved package requirement to install Humble on Ubuntu 20.04 (#3086) (#3088)

    * fix command to install humble on Ubuntu 20.04

    Co-authored-by: paolo.dimasi <paodimasi@outlook.com>
    Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>
    (cherry picked from commit 5626af9)

    Co-authored-by: Paolo Dimasi <46300254+Pamasi@users.noreply.github.com>

* Update Webots.rst

* Update intro to wsl

* Remove windows tabs

* Add windows WSL tab for extern controller code

* Clean tutorial

* Add ros2supervisorlauncher node creation in launch files

* Update intro to WSL

* Update tutorial with explanations

* include correct file for supervisor part

* Add WEBOTS_CONTROLLER_URL wsl infos

* cleanup

* Remove confusing sentence

* Update source/Tutorials/Advanced/Simulators/Webots.rst

Co-authored-by: Olivier Michel <Olivier.Michel@cyberbotics.com>

* Update source/Tutorials/Advanced/Simulators/Webots.rst

Co-authored-by: Olivier Michel <Olivier.Michel@cyberbotics.com>

* Squashed commit of the following:

commit 72effa7
Author: Luke Schmitt <85308904+LSinterbotix@users.noreply.github.com>
Date:   Tue Nov 1 17:26:25 2022 -0500

    Fix list formatting on Contact page (#3153)

commit dcd066f
Author: Dan Zimmerman <dan@danzimmerman.com>
Date:   Tue Nov 1 16:29:34 2022 -0400

    Update throttle logging docs with units and data type hints (re: rclcpp/issues/1929) (#3143)

    * Note milliseconds on API Concepts page

    * Add units and types to About Logging page

    Co-authored-by: dan <dan@polarworks.no>
    Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>

commit 375b6cf
Author: definitelyuncertain <saikirann94@gmail.com>
Date:   Fri Oct 28 14:30:22 2022 -0500

    Change to mention explicit requirement for folder names for .msg and .srv files (#3144)

    * Change to mention explicit requirement for folder names for msg and srv files

    From ros2/tutorials#29

    * fix typo

    Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

    * fix rst formatting

    Co-authored-by: Chris Lalancette <clalancette@gmail.com>

    Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
    Co-authored-by: Chris Lalancette <clalancette@gmail.com>

commit da871ef
Author: Sergei Sergienko <divelix1@gmail.com>
Date:   Thu Oct 27 17:20:06 2022 +0300

    fix link to Gazebo-ROS2 bridge + CLI examples (#3139)

    * fix link to Gazebo-ROS2 bridge + CLI examples

    Co-authored-by: Chris Lalancette <clalancette@gmail.com>

commit e19c9b5
Author: Chris Lalancette <clalancette@openrobotics.org>
Date:   Wed Oct 26 16:31:21 2022 -0400

    Update the language to match the source code. (#3135)

    Fallout from #2865

    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

commit a5910a1
Author: Chris Lalancette <clalancette@openrobotics.org>
Date:   Wed Oct 26 08:38:36 2022 -0400

    Shorten the Windows build-from-source path. (#3130)

    * Shorten the Windows build-from-source path.

    This is to keep the total length down below the 260 character
    limit imposed by Windows by default.

    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

commit 8225686
Author: Chris Lalancette <clalancette@openrobotics.org>
Date:   Mon Oct 24 08:30:37 2022 -0400

    Fix up the variable name in the traveling in time (C++) tutorial. (#3115)

    This is just to match what is in the code in the upstream
    repository.

    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

commit 87ab121
Author: Ian Colwell <48106342+icolwell-as@users.noreply.github.com>
Date:   Fri Oct 21 11:07:30 2022 -0400

    Update default WORKING_DIRECTORY for ament_add_gtest() (#3117)

commit 87bf20a
Author: chianfern <chianfern@gmail.com>
Date:   Tue Oct 18 21:36:57 2022 +0800

    Add ParameterDescriptor to 'Using parameters in a class (C++)' (#2865)

    * Rename node name in "Using parameters" C++ tutorial to be consistent with Python tutorial.

    Signed-off-by: Tan Chian Fern <chianfern@gmail.com>
    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

commit 77646ce
Author: George Stavrinos <gstavrinos@protonmail.com>
Date:   Tue Oct 18 15:29:37 2022 +0300

    Fixed Intel's robot SDK repo with the new devkit name + reference to MoveIt2 instead of 1. (#3107)

commit 1d24955
Author: Chris Lalancette <clalancette@openrobotics.org>
Date:   Mon Oct 17 14:06:52 2022 -0400

    Monitor parameter changes: Add note to save callback handle (#3102)

    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

commit 8910a80
Author: David V. Lu!! <davidvlu@gmail.com>
Date:   Fri Oct 14 09:56:14 2022 -0400

    Some testing basics (#3084)

    * Some testing basics

    Signed-off-by: David V. Lu <davidvlu@gmail.com>
    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

commit 8771452
Author: Tomoya Fujita <Tomoya.Fujita@sony.com>
Date:   Fri Oct 14 05:34:20 2022 -0700

    Sony's task for Iron Release. (#3089)

    * Sony's task for Iron Release.

    Signed-off-by: Tomoya.Fujita <Tomoya.Fujita@sony.com>

    * Rearrange and add in links.

    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>

    Signed-off-by: Tomoya.Fujita <Tomoya.Fujita@sony.com>
    Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
    Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>

commit 2ea9e7d
Author: Yannick Goumaz <61198661+ygoumaz@users.noreply.github.com>
Date:   Fri Oct 14 14:23:13 2022 +0200

    Update Setting-up a Robot Simulation (Webots) tutorial (#3090)

    * Update intro to WSL

    * Update world with declarations

    * Add supervisor node and environment var

    * Update tutorial with explanations

    Co-authored-by: ad-daniel <44834743+ad-daniel@users.noreply.github.com>

commit 0390a50
Author: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Date:   Thu Oct 13 13:42:30 2022 -0400

    fix unresolved package requirement to install Humble on Ubuntu 20.04 (#3086) (#3088)

    * fix command to install humble on Ubuntu 20.04

    Co-authored-by: paolo.dimasi <paodimasi@outlook.com>
    Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>
    (cherry picked from commit 5626af9)

    Co-authored-by: Paolo Dimasi <46300254+Pamasi@users.noreply.github.com>

* Update Webots.rst

* Update Webots.rst

* Remove trailing white spaces

* Update to VM and no supervisor

* Remove wrong text

* Update source/Tutorials/Advanced/Simulators/Webots.rst

Co-authored-by: Olivier Michel <Olivier.Michel@cyberbotics.com>

---------

Co-authored-by: ad-daniel <44834743+ad-daniel@users.noreply.github.com>
Co-authored-by: Olivier Michel <Olivier.Michel@cyberbotics.com>
(cherry picked from commit 588b10a)

Co-authored-by: Yannick Goumaz <61198661+ygoumaz@users.noreply.github.com>
  • Loading branch information
mergify[bot] and ygoumaz authored Feb 13, 2023
1 parent ec1cd20 commit 5e8e837
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 28 deletions.
3 changes: 0 additions & 3 deletions source/Tutorials/Advanced/Simulators/Code/robot_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def generate_launch_description():
world=os.path.join(package_dir, 'worlds', 'my_world.wbt')
)

ros2_supervisor = Ros2SupervisorLauncher()

my_robot_driver = Node(
package='webots_ros2_driver',
executable='driver',
Expand All @@ -31,7 +29,6 @@ def generate_launch_description():
return LaunchDescription([
webots,
my_robot_driver,
ros2_supervisor,
launch.actions.RegisterEventHandler(
event_handler=launch.event_handlers.OnProcessExit(
target_action=webots,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def generate_launch_description():
world=os.path.join(package_dir, 'worlds', 'my_world.wbt')
)

ros2_supervisor = Ros2SupervisorLauncher()

my_robot_driver = Node(
package='webots_ros2_driver',
executable='driver',
Expand All @@ -36,7 +34,6 @@ def generate_launch_description():
return LaunchDescription([
webots,
my_robot_driver,
ros2_supervisor,
obstacle_avoider,
launch.actions.RegisterEventHandler(
event_handler=launch.event_handlers.OnProcessExit(
Expand Down
33 changes: 11 additions & 22 deletions source/Tutorials/Advanced/Simulators/Webots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ In particular, :doc:`../../Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-

.. group-tab:: macOS

The Linux and ROS commands of this tutorial must be run in a custom Docker container configured with the ``webots_ros2_driver`` package.
The Linux and ROS commands of this tutorial must be run in a pre-configured Linux Virtual Machine (VM).
See the `Webots ROS 2 macOS installation instructions <https://github.com/cyberbotics/webots_ros2/wiki/macOS-Installation-Guide>`_.

To install ``webots_ros2_driver`` from a terminal, proceed with the following commands.
Expand Down Expand Up @@ -203,15 +203,6 @@ You have to specify in the constructor which world file the simulator will open.
:dedent: 4
:lines: 15-17

A supervisor Robot is always automatically added to the world file by ``WebotsLauncher``.
This robot is controlled by the custom node ``Ros2Supervisor``, which must also be started using the ``Ros2SupervisorLauncher``.
This node allows to spawn URDF robots directly into the world, and it also publishes useful topics like ``/clock``.

.. literalinclude:: Code/robot_launch.py
:language: python
:dedent: 4
:lines: 19

Then, the ROS node interacting with the simulated robot is created.
This node, named ``driver``, is located in the ``webots_ros2_driver`` package.

Expand All @@ -223,11 +214,11 @@ This node, named ``driver``, is located in the ``webots_ros2_driver`` package.

.. group-tab:: Windows

The node (in WSL) will be able to communicate with the simulated robot (in Webots on Windows) through a TCP connection.
The node (in WSL) will be able to communicate with the simulated robot (in Webots on native Windows) through a TCP connection.

.. group-tab:: macOS

The node (in the docker container) will be able to communicate with the simulated robot (in Webots on macOS) through a TCP connection.
The node (in the docker container) will be able to communicate with the simulated robot (in Webots on native macOS) through a TCP connection.


In your case, you need to run a single instance of this node, because you have a single robot in the simulation.
Expand All @@ -239,21 +230,21 @@ The ``robot_description`` parameter holds the contents of the URDF file which re
.. literalinclude:: Code/robot_launch.py
:language: python
:dedent: 4
:lines: 21-29
:lines: 19-27

After that, the three nodes are set to be launched in the ``LaunchDescription`` constructor:

.. literalinclude:: Code/robot_launch.py
:language: python
:dedent: 4
:lines: 31-34
:lines: 29-31

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).

.. literalinclude:: Code/robot_launch.py
:language: python
:dedent: 8
:lines: 35-40
:lines: 32-37

6 Modify the setup.py file
^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -269,7 +260,6 @@ This sets-up the package and adds in the ``data_files`` variable the newly added
7 Test the code
^^^^^^^^^^^^^^^


.. tabs::

.. group-tab:: Linux
Expand Down Expand Up @@ -306,18 +296,17 @@ This sets-up the package and adds in the ``data_files`` variable the newly added
On macOS, a local server must be started on the host to start Webots from the Docker container.
The local server can be downloaded `on the webots-server repository <https://github.com/cyberbotics/webots-server/blob/main/local_simulation_server.py>`_.

In a terminal of the host machine (not in the container), specify the Webots installation folder (e.g. ``/Applications/Webots.app``) and start the server using the following commands:
In a terminal of the host machine (not in the VM), specify the Webots installation folder (e.g. ``/Applications/Webots.app``) and start the server using the following commands:

.. code-block:: console
export WEBOTS_HOME=/Applications/Webots.app
python3 local_simulation_server.py
From the terminal of the Docker container, build and launch your custom package with:
From a terminal in the Linux VM in your ROS 2 workspace, build and launch your custom package with:

.. code-block:: console
cd ~/ros2_ws
colcon build
source install/local_setup.bash
ros2 launch my_package robot_launch.py
Expand Down Expand Up @@ -407,7 +396,7 @@ Go to the file ``robot_launch.py`` and replace ``def generate_launch_description

.. literalinclude:: Code/robot_launch_sensor.py
:language: python
:lines: 11-47
:lines: 11-44

This will create an ``obstacle_avoider`` node that will be included in the ``LaunchDescription``.

Expand Down Expand Up @@ -443,7 +432,7 @@ As in task ``7``, launch the simulation from a terminal in your ROS 2 workspace:

.. group-tab:: macOS

In a terminal of the host machine (not in the container), if not done already, specify the Webots installation folder (e.g. ``/Applications/Webots.app``) and start the server using the following commands:
In a terminal of the host machine (not in the VM), if not done already, specify the Webots installation folder (e.g. ``/Applications/Webots.app``) and start the server using the following commands:

.. code-block:: console
Expand All @@ -452,7 +441,7 @@ As in task ``7``, launch the simulation from a terminal in your ROS 2 workspace:
Note that the server keeps running once the ROS 2 nodes are ended.
You don't need to restart it every time you want to launch a new simulation.
From the terminal of the Docker container, build and launch your custom package with:
From a terminal in the Linux VM in your ROS 2 workspace, build and launch your custom package with:

.. code-block:: console
Expand Down

0 comments on commit 5e8e837

Please sign in to comment.