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

Navigation cmd_vel and TwistStamped

asked 2014-09-14 19:38:38 -0500

ROSCMBOT gravatar image

updated 2014-09-14 23:46:51 -0500


I've set up the navigation stack on my robot. The issue is move_base is publishing the velocity commands on cmd_vel whose message is of type Twist, but my robot is subscribing to a topic called base_velocity whose message is of type TwistStamped. So as I understand, only remapping wouldn't do the work. What can I do to remap topics of different message types.


Answer: So I wrote the node below that converts cmd_vel messages to base_velocity,

   #!/usr/bin/env python
    import rospy
    from geometry_msgs.msg import Twist, TwistStamped

    import time

    def callback(cmdVelocity):

        baseVelocity = TwistStamped()

        baseVelocity.twist = cmdVelocity

        now = rospy.get_rostime()
        baseVelocity.header.stamp.secs = now.secs
        baseVelocity.header.stamp.nsecs = now.nsecs

        baseVelocityPub = rospy.Publisher('base_velocity', TwistStamped, queue_size=10)

    def cmd_vel_listener():

        rospy.Subscriber("cmd_vel", Twist, callback)


    if __name__ == '__main__':
        rospy.init_node('cmd_vel_listener', anonymous=True)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-09-14 20:58:40 -0500

You can create a simple node that subscribes to the /cmd_vel topic, creates a TwistStamped message with the /cmd_vel info + the stamp and publishes to the /base_velocity topic.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-09-14 19:38:38 -0500

Seen: 3,265 times

Last updated: Sep 14 '14