References Nodes - cyberbotics/webots_ros2 GitHub Wiki

It might happen that you want to parametrize how Webots is launched with the WebotsLauncher process or parametrize the WebotsController node.

Here is a list of all arguments you can use with some further explanations on this process and these nodes.

WebotsLauncher

Most of the arguments of the WebotsLauncher will start Webots with different command line arguments.

You can find below the list of arguments of WebotsLauncher and their impact on the command line arguments:

  • gui (bool): If False, set the --no-rendering, --stdout, --stderr and --minimize flags. Default is True.
  • mode (string): Set the --mode flag with the same value. Default is 'realtime'.
  • stream (bool): If True, set the --stream flag. Default is False.
  • port (integer): Set the Webots instance port. Default is 1234.
  • world (string): Specifies the path to the world to be used. It can be a literal string or a Substitution, like in the Examples of this repository.
  • output (string): (by default set to 'screen') and extra arguments will be used by the init function of launch.actions.ExecuteProcess.
  • ros2_supervisor (bool): If True, spawns the Ros2Supervisor custom node that communicates with a Supervisor robot in the simulation. The Ros2Supervisor node is a special node interacting with the simulation. For example, it publishes the /clock topic of the simulation or permits to spawn robots from URDF files and PROTO strings.

WebotsController

Since version 2023.1.0 of the package, declaring the driver node in the launch file is deprecated. It is replaced by the WebotsController node (derived from ExecuteProcess). This node is responsible for starting the interface between your ROS controller and Webots.

You can find below the list of arguments introduced by WebotsController:

  • robot_name (string): Set the robot to which the controller must connect.
  • port (integer): Set the port of the Webots instance to which the controller must connect. Default is 1234.
  • namespace (string): Set the namespace for the involved resources, including topics, etc.
  • parameters (list of dictionaries): Set the parameters for the driver node. Here is the list of parameters that can be used:
    • use_sim_time (bool): Use the /clock topic to synchronize the ROS controller with the simulation.
    • robot_description (string): Set the path to the URDF configuration file. If set, the webots_ros2_driver node will parse the URDF string contained in the file to configure the ROS 2 interface. For example, this includes using plugins (premade or custom ones), activating devices or overriding sensor topic names. For more information, check how to setup a basic Webots simulation with ROS 2.
    • set_robot_state_publisher (bool): If True, the robot_description parameter of a (potentially existing) robot_state_publisher node will be overridden by the content the URDF string generated by Webots based on the PROTO of the robot in the simulation. This URDF may not be as complete as a URDF made by yourself. Default is False.
    • components_remapping (string): Set the path to a YAML file containing key->value pairs. In combination with set_robot_state_publisher set to True, the names of components of the generated URDF from the robot PROTO file are replaced by values contained in the YAML file. This allows to rename them to more conventional URDF terms and improve the sim2real conversion.
    • In addition, a YAML configuration file (e.g. for ros_control) can be passed entirely in the parameters array.

WaitForControllerConnection

Webots simulations can take some time to start and the console is already full of connection messages from the driver nodes. Some other nodes may produce logs at the same time but cannot be used until the simulation is ready, creating a mess in the console. The WaitForControllerConnection is a custom handler that allows to start given nodes as soon as the simulation is ready and the corresponding driver is connected to the target robot.

It takes two arguments:

  • target_driver (node): Set the reference driver. When this driver is connected, selected nodes are started.
  • nodes_to_start (array of nodes): Defines the nodes to start whenever the target driver is connected.