ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
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)
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
2 | No.2 Revision |
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)
rospy.Subscriber('cmd_vel',Twist,gotTwistCB) #subscribe for 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
3 | No.3 Revision |
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 for 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