A simple ROS node that multiplexes multiple geometry_msgs/msg/Twist topics onto a single cmd_vel output, picking the active source by priority with per-source timeouts.
Subscribers and the publisher are configured from a YAML file. The three subscriber lists are aligned by index:
/**:
ros__parameters:
subscribers:
priorities: [0, 1, 2]
topics:
- /joy_controller/cmd_vel
- /navigation/cmd_vel
- /other/cmd_vel
time_outs: [3.0, 3.0, 3.0]
publisher:
topic: /cmd_vel
rate: 30.0
stop_publishing_on_timeout: true-
time_outsare in seconds. After this much silence on a topic, that source is marked inactive. -
rateis the output publish rate in Hz. -
prioritiesare integers; lower wins. Values do not have to be dense (e.g.[0, 5, 10]is fine) but must be non-negative and unique. -
stop_publishing_on_timeout(optional, defaultfalse): whentrue, the mux publishes a single zeroTwiston the transition from active to inactive and then stops publishing until a source becomes active again. Whenfalse, zeroTwists are published continuously atratewhile no source is active.
cd docker
docker compose build
docker compose upEnvironment variables (COLCON_WORKSPACE_DIR, ROS_DOMAIN_ID, RMW_IMPLEMENTATION) are read from docker/.env.
Alternatively clone the repo into your local workspace, build and...
ros2 launch simple_cmd_vel_mux init.launch.py...optionally override the namespace or config file:
ros2 launch simple_cmd_vel_mux init.launch.py name_space:=my_mux configuration:=my.yaml