Retrieve velocity data from twist messages
Hello I would like to inspect and pass on the individual velocities from Twist messages, are there methods to do this? Thanks.
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
Hello I would like to inspect and pass on the individual velocities from Twist messages, are there methods to do this? Thanks.
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.init_node('TwistToTurtle',anonymous=False)
rospy.Subscriber('cmd_vel',Twist,gotTwistCB) #subscribe to cmd_vel topic which publishes Twist messages
pub = rospy.Publisher('turtle1/command_velocity',Velocity)
rospy.spin()
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
pub.publish(outdata)
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
Asked: 2013-08-03 13:43:38 -0500
Seen: 1,819 times
Last updated: Aug 03 '13
Creating a Subscriber in python
Subscribe and publish velocity [closed]
Using ROS subscribers in Unreal Engine
Custom Nodes not publishing or subscribing, why?
subscribe and publish in the same class
Subscribe to a Gazebo topic and publish in a ROS node
What is the preferable way to share states among multiple nodes in ROS?
Best practices to use subscriber inside a class
Visualising positions of a detected object in Rviz using find-object-2d [closed]