How to remap from geometry_msgs/PoseStamped to move_base_msgs/MoveBaseActionGoal in ROS node
I am writing a node where I subscribe to the topic /move_base_simple/goal which is of message tip geometry_msgs/PoseStamped and I am wanting to publish this information to the topic /move_base/move/goal which is of message type move_base_msgs/MoveBaseActionGoal. I have the following script to try to do what I have described:
#!/usr/bin/env python
import rospy
import roslib
import actionlib
from std_msgs.msg import String, Empty
from geometry_msgs.msg import PoseStamped
from move_base_msgs.msg import MoveBaseActionGoal
def callback(data):
rospy.loginfo(rospy.get_caller_id() + 'I HEARD %s', data.pose.position)
rospy.loginfo(rospy.get_caller_id() + 'I heard %s', data.pose.orientation)
pub = rospy.Publisher('move_base/move/goal', MoveBaseActionGoal, queue_size = 10)
stuff_to_publish = data
pub.publish(stuff_to_publish)
def listener():
# In ROS, nodes are uniquely named. If two nodes with the same
# name are launched, the previous one is kicked off. The
# anonymous=True flag means that rospy will choose a unique
# name for our 'listener' node so that multiple listeners can
# run simultaneously.
rospy.init_node('navgoallistener', anonymous=True)
rospy.Subscriber('move_base_simple/goal', PoseStamped, callback)
#message = rospy.Subscriber('move_base_simple/goal', PoseStamped, callback)
#print message.pose.orientation
# spin() simply keeps python from exiting until this node is stopped
rospy.spin()
"""def talker():
pub = rospy.Publisher('move_base/move/goal', MoveBaseActionGoal, queue_size = 10)
rospy.init_node('navgoalsetter', anonymous = True)"""
if __name__ == '__main__':
listener()
However I am having a problem because the messages are of different type. The relevant documentation for the message types can be found here http://docs.ros.org/diamondback/api/g... and here http://docs.ros.org/diamondback/api/m... . Basically I am wondering how to populate the header and goal_id section of the move_base_msgs message.