123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- import rospy
- from hinge_car_nav_msgs.msg import hinge_car_nav_msgs
- import geometry_msgs.msg
- import actionlib
- def callback(data):
-
- rospy.loginfo('received move base action goal')
-
- def done_cb(data, data1):
- print("action done cb:%d,%s" % (data, data1))
- def active_cb():
- print("active_cb")
- def feedback_cb(data):
- pass
-
-
- if __name__ == '__main__':
-
-
-
-
-
- rospy.init_node('action_client', anonymous=True)
-
-
-
- client = actionlib.SimpleActionClient(
- 'hinge_car_nav', hinge_car_nav_msgs.msg.HingeCarNavAction)
-
-
- p0 = geometry_msgs.msg.Point()
- p00 = geometry_msgs.msg.Point()
- p1 = geometry_msgs.msg.Point()
- p2 = geometry_msgs.msg.Point()
- p3 = geometry_msgs.msg.Point()
- p4 = geometry_msgs.msg.Point()
-
-
-
-
-
-
-
-
-
- p0.x = 132.64
- p0.y = 197.3
- p00.x = p0.x + 5.0
- p00.y = p0.y
- p1.x = 180.0
- p1.y = 195.7
- p2.x = 19.45
- p2.y = 199.64
- p3.x = 19.81
- p3.y = 172.2
- p4.x = 180.0
- p4.y = 168.3
- print("before client connected")
- client.wait_for_server()
- print("client connected")
- goal = hinge_car_nav_msgs.msg.HingeCarNavGoal()
- path = hinge_car_nav_msgs.msg.HingeCarPath()
- tp = []
- goal.goal_type = goal.BACKWARD
-
-
-
-
-
-
-
-
-
-
-
-
-
- s = hinge_car_nav_msgs.msg.Segment()
- s.segment_type = s.LINE
- s.start_point = p0
- s.end_point = p2
- s.max_vel = -0.45
- path.target_path.append(s)
- s = hinge_car_nav_msgs.msg.Segment()
- s.segment_type = s.CIRCLE
- s.start_point = p2
- s.end_point = p3
- s.center_point.x = 0.5 * (p2.x + p3.x)
- s.center_point.y = 0.5 * (p2.y + p3.y)
- s.max_vel = -0.45
- path.target_path.append(s)
- s = hinge_car_nav_msgs.msg.Segment()
- s.segment_type = s.LINE
- s.start_point = p3
- s.end_point = p4
- s.max_vel = -0.45
- path.target_path.append(s)
- s = hinge_car_nav_msgs.msg.Segment()
- s.segment_type = s.CIRCLE
- s.start_point = p4
- s.end_point = p1
- s.center_point.x = 0.5 * (p1.x + p4.x)
- s.center_point.y = 0.5 * (p1.y + p4.y)
- s.max_vel = -0.45
- path.target_path.append(s)
- s = hinge_car_nav_msgs.msg.Segment()
- s.segment_type = s.LINE
- s.start_point = p1
- s.end_point = p00
- s.max_vel = -0.45
- path.target_path.append(s)
- goal.path = path
-
- client.send_goal(goal, done_cb, active_cb, feedback_cb)
-
-
- client.wait_for_result()
- client.get_result()
- try:
-
-
- result = client.get_result()
- except rospy.ROSInterruptException:
- print("program interrupted before completion")
- rospy.sleep(5.0)
|