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

Retrieve velocity data from twist messages

asked 2013-08-03 13:43:38 -0500

boog gravatar image

updated 2014-01-28 17:17:32 -0500

ngrennan gravatar image

Hello I would like to inspect and pass on the individual velocities from Twist messages, are there methods to do this? Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-08-03 21:10:44 -0500

vonovak gravatar image

updated 2013-08-03 21:14:13 -0500

hi, you probably want to do something like this (this is an example that converts geometry_msgs/Twist message to turtlesim/Velocity message):

def TwistToTurtle(): #initialization
rospy.Subscriber('cmd_vel',Twist,gotTwistCB) #subscribe to cmd_vel topic which publishes Twist messages 
pub = rospy.Publisher('turtle1/command_velocity',Velocity)

def gotTwistCB(data): #when Twist msg is received
#take values from data and do your job, for example:
outdata = Velocity()
outdata.linear = data.linear.x
outdata.angular = data.angular.z

SO data.linear.x/y/z and data.angular.x/y/z are the ones that you care about

more on subsribing tutorial here. Also, you may want to check out rosmsg or just run

rosmsg -h
edit flag offensive delete link more


Hey @vonovak one quick question - Are the velocity commands in m/s and angular velocity in rads/sec? or is there any other scaling?

parzival gravatar image parzival  ( 2019-08-14 07:24:50 -0500 )edit

Question Tools

1 follower


Asked: 2013-08-03 13:43:38 -0500

Seen: 1,819 times

Last updated: Aug 03 '13