There was a documentation page on the ORI wiki called 'Send 2D Nav Goals to HSR'. I think we can send nav goals in RViz without any problems. However, this should be properly checked before we remove this documentation. If it needs to be there, it should be added and updated in the ORIon Wiki. The page reads as follows:
Sending 2D Nav Goals through Rviz does not work and the robot cannot navigate to the specified goal because the 2D Nav Goal tool publishes goals on the /move_base_simple/goal topic with message type geometry_msgs/PoseStamped. To get Rviz to publish the 2D Nav Goal to the correct topic /move_base/move/goal with message type move_base_msgs/MoveBaseActionGoal I have written a node that subscribes to /move_base_simple/goal and publishes the goal to /move_base/move/goal in the correct message format. Follow the steps below to create and run this node that will allow you to send 2D Nav Goals through Rviz and have the robot navigate to them:
Create a catkin package:
mkdir catkin_ws && cd catkin_ws
mkdir src && cd src
catkin_create_pkg name_of_package std_msgs rospy roscpp
cd ~/catkin_ws
catkin_make
Write the script:
mkdir scripts && cd scripts
touch messagetranslater.py
Edit the message translater.py file to include the following script:
!/usr/bin/env python
import rospy
import roslib
import actionlib
import random
import string
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
stuff_to_publish.goal_id.id = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(15)])
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()
if name == 'main':
try:
listener()
except rospy.ROSInterruptException:
pass
Make the script executable:
chmod +x messagetranslater.py
Build your node:
cd ~/catkin_ws
catkin_make
Run the node:
source strands_ws/devel/setup.bash
rosrun name_of_package messagetranslater.py
In another terminal now run:
hsrb_mode
rosrun rviz rviz
You should now be able to successfully send 2D Nav Goals
There was a documentation page on the ORI wiki called 'Send 2D Nav Goals to HSR'. I think we can send nav goals in RViz without any problems. However, this should be properly checked before we remove this documentation. If it needs to be there, it should be added and updated in the ORIon Wiki. The page reads as follows:
Sending 2D Nav Goals through Rviz does not work and the robot cannot navigate to the specified goal because the 2D Nav Goal tool publishes goals on the /move_base_simple/goal topic with message type geometry_msgs/PoseStamped. To get Rviz to publish the 2D Nav Goal to the correct topic /move_base/move/goal with message type move_base_msgs/MoveBaseActionGoal I have written a node that subscribes to /move_base_simple/goal and publishes the goal to /move_base/move/goal in the correct message format. Follow the steps below to create and run this node that will allow you to send 2D Nav Goals through Rviz and have the robot navigate to them:
Create a catkin package: mkdir catkin_ws && cd catkin_ws mkdir src && cd src catkin_create_pkg name_of_package std_msgs rospy roscpp cd ~/catkin_ws catkin_make Write the script:
mkdir scripts && cd scripts touch messagetranslater.py Edit the message translater.py file to include the following script:
!/usr/bin/env python
import rospy import roslib import actionlib import random import string
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
pub = rospy.Publisher('move_base/move/goal', MoveBaseActionGoal, queue_size = 10)
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)
stuff_to_publish.goal_id.id = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(15)]) stuff_to_publish.goal.target_pose = data pub.publish(stuff_to_publish)
def listener():
if name == 'main': try: listener() except rospy.ROSInterruptException: pass
Make the script executable: chmod +x messagetranslater.py Build your node: cd ~/catkin_ws catkin_make Run the node:
source strands_ws/devel/setup.bash rosrun name_of_package messagetranslater.py In another terminal now run:
hsrb_mode
rosrun rviz rviz
You should now be able to successfully send 2D Nav Goals