Navigation cmd_vel and TwistStamped
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()