ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to Implement twist_mux Properly?

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

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

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.)

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-11-19 07:00:38 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-11-18 16:07:49 -0500

dvy gravatar image

updated 2022-11-18 16:10:00 -0500

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.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-05-31 20:27:50 -0500

Seen: 599 times

Last updated: Nov 18 '22