Go to the documentation of this file.00001
00002
00003 import rospy
00004 import actionlib
00005 import argparse
00006
00007 from locomotor_msgs.msg import NavigateToPoseAction, NavigateToPoseGoal
00008
00009 def print_feedback(feedback):
00010 pose = feedback.state.global_pose.pose
00011 vel = feedback.state.current_velocity.velocity
00012 print('%.2f %.2f %.2f | %.2f %.2f' % (pose.x, pose.y, pose.theta,
00013 vel.x, vel.theta))
00014 print('Global plan: %d poses' % len(feedback.state.global_plan.poses))
00015 print('%.2f %.2f %.2f' % (feedback.percent_complete,
00016 feedback.distance_traveled,
00017 feedback.estimated_distance_remaining))
00018
00019
00020 parser = argparse.ArgumentParser()
00021 parser.add_argument('x', nargs='?', type=float, default=0.0)
00022 parser.add_argument('y', nargs='?', type=float, default=0.0)
00023 parser.add_argument('theta', nargs='?', type=float, default=0.0)
00024 parser.add_argument('-f', '--frame_id', default='map')
00025 parser.add_argument('-n', '--namespace', default='/locomotor/')
00026 args = parser.parse_args()
00027
00028 rospy.init_node('send_action', anonymous=True)
00029 client = actionlib.SimpleActionClient(args.namespace + '/navigate', NavigateToPoseAction)
00030 client.wait_for_server()
00031 goal = NavigateToPoseGoal()
00032 goal.goal.pose.x = args.x
00033 goal.goal.pose.y = args.y
00034 goal.goal.pose.theta = args.theta
00035 goal.goal.header.frame_id = args.frame_id
00036 client.send_goal(goal, feedback_cb = print_feedback)
00037 client.wait_for_result()
00038 print(client.get_result())