How to Implement twist_mux Properly?

asked 2017-05-31 20:27:50 -0600

sradmard gravatar image

Hi there,

I am trying to provide velocity commands to control my robot, but these velocity commands can be generated from different sources. I have keyboard controller, Joystick, voice commands that generates velocity, and navigation package that also creates velocity command. I am publishing each of these velocities on a separate topic and would like to use twist_mux to combine all of them and choose one source at a time depending on the activation order. However, it is not very clear to me how to switch between these sources. I need to switch back and forth between sources, therefore, they all have the same priority. For example, assume I have given my robot a goal location, and the navigation package is publishing velocity into nav_cmd_vel topic, and twist_mux is passing that to cmd_vel to move the robot. Now, I press on the joystick and I want the joystick to take over the velocity control. Which means the twist_mux should pass joy_cmd_vel to cmd_vel instead even though the nav_cmd_vel is still being published on. Later, if I provide another goal location, I want the nav_cmd_vel to be passed to cmd_vel again. I do not know how to activate the switch for twist_mux in my codes so that it is automatically applied when new inputs come in.

I would really appreciate any hint.

edit retag flag offensive close merge delete