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

Navigation cmd_vel and TwistStamped

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

ROSCMBOT gravatar image

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

Hello,

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.

Thanks

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)
        baseVelocityPub.publish(baseVelocity)


    def cmd_vel_listener():

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

        rospy.spin()

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

1 Answer

Sort by ยป oldest newest most voted
2

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

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

Stats

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

Seen: 3,411 times

Last updated: Sep 14 '14