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

How can I scale cmd_vel

asked 2022-02-18 11:15:30 -0600

amro2500 gravatar image

I have a robot that for some weird reason only takes scaled twisted message to control its motion (I have limited-access and I can only do it from my end). Is there a way for move_base to scale the result cmd_vel (just like teleop_twist_joy based on the max-min velocity values)? If not, then I think I need to take the output from cmd_vel scale it accordingly and then publish to a topic that is remapped to the motor command topic or basically just make a filter node. If that is true how can I do it in c++?

edit retag flag offensive close merge delete


I don't believe this is something move_base can do itself.

re: scaling node: you wouldn't need to write something yourself. You can use topic_tools/transform for this. See #q326794 and #q261935 for previous Q&As about this (and #q349655 (avoid race condition)).

You would need to know the minimum and maximum values though (I guess you know those).

gvdhoorn gravatar image gvdhoorn  ( 2022-02-19 09:47:53 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2022-02-19 11:34:42 -0600

Mike Scheutzow gravatar image

If you are accurately describing the problem, then the robot's ros-interface code was written by someone who is clueless. The units of /cmd_vel are standardized to meters/sec and radians/sec for very good compatibility reasons.

This scaling should happen in the layer that writes to the motor controller. A good ros-interface implementation will do this scaling in the hardware_interface::RobotHW layer, which is responsible for writing values to the proprietary API of your motor controller.

There is an overview of the architecture here:

edit flag offensive delete link more


While I agree it's not as it should be, I would not judge so harshly.

There is quite a bit of ambiguity and a lot of these interfaces are undocumented and de facto standards only.

geometry_msgs/Twist may be clear in its documentation, but that doesn't mean the complete pipeline is clear for someone who is not familiar with how things work.

There are various Q&As on ROS Answers asking the exact question, but from the consumer side: "what are the units of Twist?" and "What units do incoming cmd_vel messages have?".

gvdhoorn gravatar image gvdhoorn  ( 2022-02-19 11:42:16 -0600 )edit

@gvdhoorn This post itself has a pretty major red flag: I have never seen a case where cmd_vel is written directly to a motor controller API.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-02-19 11:54:30 -0600 )edit

I don't believe

I have a robot that for some weird reason only takes scaled twisted message to control its motion

means the twist is forwarded to the controller API directly.

I took it to mean the robot (as a whole) accepts Twist as input and for some reason (probably misunderstanding of cmd_vel semantics) that accepts only normalised Twists.

But let's wait on OP to clarify things.

gvdhoorn gravatar image gvdhoorn  ( 2022-02-19 12:07:10 -0600 )edit

Question Tools

1 follower


Asked: 2022-02-18 11:02:36 -0600

Seen: 257 times

Last updated: Feb 19 '22