2D Nav Goal not working in Rviz
I am using a Toyota HSR robot running ubuntu 16.04 and ROS kinetic. I am having issues getting the move_base node to work by sending nav goals in Rviz. When I do rostopic list | grep move
I see the following topic: /move_base/move/goal. However when I run Rviz, Rviz sends its 2D nav goals to the topic /move_base_simple/goal. I thought about just switching the topic that the 2D Nav goal publishes to but unfortunately the two topics do not have the same message types. /move_base/move/goal is of type move_base_msgs/MoveBaseActionGoal whilst /move_base_simple/goal is of type geometry_msgs/PostStamped. Currently I am thinking of writing a node that subscribes to /move_base_simple/goal and publishes to /move_base/move/goal but I am wondering if there is an easier way to go about this. Thanks for all the help!
#!/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, MoveBaseGoal
from actionlib_msgs.msg import GoalID
'''def goal_client():
client = actionlib.SimpleActionClient('send_goal', GoalID)
client.wait_for_server()'''
def callback(data):
rospy.loginfo(rospy.get_caller_id() + ' I Heard %s', data.header.stamp)
rospy.loginfo(rospy.get_caller_id() + ' I Heard %s', 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)
#rospy.loginfo(rospy.get_caller_id() + ' I heard %s', data.header)
pub = rospy.Publisher('move_base/move/goal', MoveBaseActionGoal, queue_size = 10)
stuff_to_publish = MoveBaseActionGoal()
stuff_to_publish.header = data.header
stuff_to_publish.goal_id.stamp = data.header.stamp
stuff_to_publish.goal_id.id = 'random_string'
stuff_to_publish.goal.target_pose = 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__':
try:
listener()
except rospy.ROSInterruptException:
pass
I think you're on the right track, I can't think of an easier way to do this myself. Making such a node should be straightforward at least.
Thank you very much! I have begun writing the node although I am encountering issues because I do not know how to populate the header and goal_id sections of the move_base_msgs/MoveBaseActionGoal message