../_images/tiagopro-icon.png ../_images/tiago-icon.png ../_images/triago-icon.png ../_images/mobile-bases-icon.png

🎮 Teleop#

Teleoperation enables users to remotely control the robot’s movements and actions in real-time. Various methods are available for teleoperation, including a physical joystick, keyboard, or virtual joystick. Using any of these control options, the robot can navigate through its environment with precision.

../_images/teleop_pipeline.svg

Given that there might be different ways to teleoperate your robot, connected to different ROS 2 topics, their coordintation and priority management is entrusted to the twist_mux package. This guarantees that only a single topic /mobile_base_controller/cmd_vel is actually send to the controller that actuates the base.

Attention

The /mobile_base_controller/cmd_vel topic requires TwistStamped messages as it validates the message timestamp to ensure that the robot is not executing outdated commands. For this reason, is not possible (and higly discouraged) to directly publish velocity messages on this topic.

The main features implemented by the twist_mux and that are used for PAL robots are:

  • Priority Management: manages the priority of different velocity topics. At each moment in time, if more than one input topic is publishing, the one with the highest priority is selected.

  • Turbo: it is an action interface offered by the joystick_relay node to increase or decrease the velocity of the robot from the joystick.

Warning

The turbo interface is NOT available for all velocity sources. It only allows to adjust the velocity command that the joystick is sending to the robot.

  • Lock Inputs: it is a topic interface that accepts std_msgs/msg/Bool messages capable of locking or unlocking the twist_mux inputs. When any of the lock topics is set to True, the corresponding input is locked and all the input velocity topics whose priority is lower than the locked one are ignored.

For more information abou the twist_mux, its configuration and how to use it, you can refer to the official documentation.

Move the Robot#

To move the robot, it is advisable to use any of the methods described in How to teleoperate your robot as they provide a built-in safety mechanism that prevents the robot from colliding with obstacles. You can learn more about this safety mechanism in the 🕹️ Assisted Teleop.

If you want to create a custom Node that sends velocity commands to the robot, the suggested topic where to publish is the /cmd_vel.

Using this topic, you can also use the ROS 2 CLI to send velocity commands to the robot. For example, to make the robot rotate with a velocity of 0.5rad/s, you can use the command:

ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "linear:
  x: 0.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 0.5" -r 10

Attention

When publishing a velocity command on the /cmd_vel topic, NO Obstacle Avoidance is applied. This means that the robot will move in the direction and with the velocity you specify, without taking into account the presence of obstacles in the environment.

To continuously actute the robot, the velocity command has to constantly be published on th velocity topic with a suggested rate of 10Hz. Each command, in fact, is considered valid for a limited period of time (0.5s) and if not updated, the robot will stop after this time.

Note

When publishing on the /cmd_vel topic, being the one with lowest priority in the twist_mux node, make sure that no other velocity topic is publishing at the same time, and that the lock inputs are set to False.

Configuration#

In addition to the available PAL configurations for the twist_mux node, you can create new configurations for your robot. To do so, you first need to create a new directory in the .pal folder of your robot.

mkdir -p ~/.pal/config

And then, within this folder, you can create a new twist_mux configuration file.

touch ~/.pal/config/99_my_twist_mux_config.yaml

Attention

The name of the file should start with a number to ensure that it is loaded last and overrides the default PAL configurations.

Within the newly created 99_my_twist_mux_config.yaml file, you can insert your custom twist_mux parameters. For the list of available parameters, their meaning and how they affect the twist_mux node, you can refer to the twist_mux official documentation. When creating a new Navigation configuration file, you need to specify the node name it refers to, in this case, twist_mux.

/twist_mux:
   ros__parameters:
      # Your twist_mux parameters

Once created, to start using your custom twist_mux configuration, you need to restart the joystick module with the command:

pal module restart joystick

Note

This change is is persistent and will be loaded every time you start the joystick module. If you want to revert to the default PAL configuration, you can simply delete the custom configuration file you created in the ~/.pal/config folder.

You can follow a similar approach to the one described above to create custom configurations for the joystick_relay node.

ROS 2 API#

To interact with the twist_mux node and in general with the Teleoperation functionalities, you can refer to the following ROS 2 interfaces:

See also#

To continue learning about Teleoperation and how to move your robot using different tools, you can refer to the following tutorials: