Base Teleoperation
Teleoperation allows 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.
There are different ways to teleoperate your robot, maybe through different ROS 2 topics, their coordintation and priority management is entrusted to the twist_mux package. This guarantees that only a single topic :topic:/mobile_base_controller/cmd_vel is actually sent to the controller that is in charge of the base motion.
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_relaynode 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 node, its configuration and how to use it, you can refer to its official documentation.
Move the Robot¶
It is encouraged to use any of the methods described in teleop-tutorial to move the robot base 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 teleoperation paragraph.
If you want to create a custom Node that sends velocity commands to the robot, the suggested topic where to publish is /cmd_vel. If you do so 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 move the robot continuously, the velocity command has be published on the 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, make sure that no other velocity topic is publishing at the same time, and that the lock inputs are set to False. This is the one with lowest priority in the twist_mux node.
Configuration¶
In addition to the available PAL configurations for the twist_mux node, you can create new configurations for your robot. To create such a new configuration, you first need to create a new directory in the .pal folder of your robot.
mkdir -p ~/.pal/config
Then create a new twist_mux configuration file in this folder:
touch ~/.pal/config/99_my_twist_mux_config.yaml
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.
You can insert your custom twist_mux parameters in the newly created 99_my_twist_mux_config.yaml file. The list of available parameters, their meaning and how they affect the twist_mux node, can be found in 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, you need to restart the joystick module with the command to start using your custom twist_mux configuration
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.