Robotics StackExchange | Archived questions

How to Implement twist_mux Properly?

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 twistmux 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 navcmdvel topic, and twistmux is passing that to cmdvel to move the robot. Now, I press on the joystick and I want the joystick to take over the velocity control. Which means the twistmux should pass joycmdvel to cmdvel instead even though the navcmdvel is still being published on. Later, if I provide another goal location, I want the navcmdvel to be passed to cmdvel 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.

Asked by sradmard on 2017-05-31 20:27:50 UTC

Comments

The standard twist_mux has the ability to disable an input ("lock" it), so you can disable all other inputs. It seems cleaner to me to just write your own custom node, and use some mechanism to select which input you want to use (e.g. a topic msg or dynamic rosparam.)

Asked by Mike Scheutzow on 2022-11-19 08:00:38 UTC

Answers

You may set the joystick's joy_cmd topic to be higher priority than rest. That way, if you press button on joystick, robot will follow your command even though other sources are also publishing velocities. You need to provide this information in a yaml file.

Asked by dvy on 2022-11-18 17:07:49 UTC

Comments