send_action.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 import rospy
4 import actionlib
5 import argparse
6 
7 from locomotor_msgs.msg import NavigateToPoseAction, NavigateToPoseGoal
8 
9 def print_feedback(feedback):
10  pose = feedback.state.global_pose.pose
11  vel = feedback.state.current_velocity.velocity
12  print('%.2f %.2f %.2f | %.2f %.2f' % (pose.x, pose.y, pose.theta,
13  vel.x, vel.theta))
14  print('Global plan: %d poses' % len(feedback.state.global_plan.poses))
15  print('%.2f %.2f %.2f' % (feedback.percent_complete,
16  feedback.distance_traveled,
17  feedback.estimated_distance_remaining))
18 
19 
20 parser = argparse.ArgumentParser()
21 parser.add_argument('x', nargs='?', type=float, default=0.0)
22 parser.add_argument('y', nargs='?', type=float, default=0.0)
23 parser.add_argument('theta', nargs='?', type=float, default=0.0)
24 parser.add_argument('-f', '--frame_id', default='map')
25 parser.add_argument('-n', '--namespace', default='/locomotor/')
26 args = parser.parse_args()
27 
28 rospy.init_node('send_action', anonymous=True)
29 client = actionlib.SimpleActionClient(args.namespace + '/navigate', NavigateToPoseAction)
30 client.wait_for_server()
31 goal = NavigateToPoseGoal()
32 goal.goal.pose.x = args.x
33 goal.goal.pose.y = args.y
34 goal.goal.pose.theta = args.theta
35 goal.goal.header.frame_id = args.frame_id
36 client.send_goal(goal, feedback_cb = print_feedback)
37 client.wait_for_result()
38 print(client.get_result())
def print_feedback(feedback)
Definition: send_action.py:9


locomotor
Author(s):
autogenerated on Sun Jan 10 2021 04:08:39