twist_mux is a ROS package that handles multiplexing multiple geometry_msgs/Twist messages into a single output stream. This is particularly useful in robotic systems where multiple nodes or sources may try to control a robot’s movement simultaneously, such as:

  1. Autonomous Navigation Nodes: Commands from an autonomous navigation stack.
  2. Teleoperation Nodes: Commands from a joystick or remote control interface.
  3. Safety Controllers: Commands to stop or override movement in critical situations.

The twist_mux package allows these multiple command sources to be prioritized, ensuring that only the highest-priority commands are sent to the robot’s actuators.


Core Features:

  1. Input Prioritization: Defines a priority system for input topics so that higher-priority commands override lower-priority ones.
  2. Topic Subscription: Listens to multiple cmd_vel (velocity command) topics as inputs.
  3. Output Publishing: Publishes the selected cmd_vel message to the robot’s motor controller.

Example Use Case:

Suppose a robot is controlled both manually using a joystick (cmd_vel_teleop) and autonomously through a navigation stack (cmd_vel_nav). To ensure smooth operation:

  • If the joystick is in use, it overrides the navigation commands.
  • If no joystick input is detected, the robot switches back to the navigation stack.

With twist_mux, you can configure this behavior using a YAML configuration file specifying priorities and timeouts.


Typical Configuration:

A YAML file might look like this:

subscribers:
  - name: teleop
    topic: cmd_vel_teleop
    timeout: 0.5
    priority: 2
  - name: navigation
    topic: cmd_vel_nav
    timeout: 1.0
    priority: 1
publisher:
  topic: cmd_vel

Here:

  • teleop has a higher priority (2) and a timeout of 0.5 seconds.
  • navigation has a lower priority (1) and a timeout of 1 second.
  • The selected command is published on the cmd_vel topic.

Why is it Needed?

Without twist_mux, multiple nodes publishing to the same cmd_vel topic could create conflicts, causing erratic robot behavior. By multiplexing, twist_mux ensures orderly control transitions and prevents command conflicts.