27 roll, pitch, yaw = tf.transformations.euler_from_quaternion(
28 [mbg.target_pose.pose.orientation.x, mbg.target_pose.pose.orientation.y, mbg.target_pose.pose.orientation.z,
29 mbg.target_pose.pose.orientation.w])
30 return "MoveBase to: (x={x}, y={y}, yaw={yaw})".format(
31 x=mbg.target_pose.pose.position.x,
32 y=mbg.target_pose.pose.position.y,
37 def __init__(self, name, action_type, goal_formatter=format, result_formatter=format, default_result=None, default_result_delay=0, pub_transform=True):
38 ScriptableActionServer.__init__(self,
40 action_type=action_type,
41 goal_formatter=goal_formatter,
42 result_formatter=result_formatter,
43 default_result=default_result,
44 default_result_delay=default_result_delay)
52 self._base_link_timer.shutdown()
53 super(ScriptableMoveBase, self).
stop()
57 Called when the underlying action server receives a goal. 58 If the default_result is None, it will wait for a custom result to be set via reply* otherwise 59 return the default_result after the given default_result_delay 61 In the reply-case,it then notifies self.reply* (which should be called by a test script outside this class), 62 after which self.reply* determines the result to the goal. 63 Then it notifies _execute_cb that the result has been determined so that _execute_cb can send it 65 print(
'\n######## {}.execute ###########'.format(self.
_name))
72 except Exception
as e:
73 rospy.logerr(
"goal_formatter of {} raised an exception: {}".format(self.
_name, e))
75 print(
'{}.execute: From {} to Goal: {}'.format(self.
_name, self.
pose_bl, goal_str))
98 except Exception
as e:
100 print(
"{}.execute: Result: {}".format(self.
_name, result_str))
102 self._as.set_succeeded(result)
104 print(
"{}.execute: Result: {}".format(self.
_name, result))
105 self._as.set_aborted()
107 print(
"{}.execute: Result: {}".format(self.
_name, result))
113 Publish the transform from /map to /base_link 114 :param event: timer event 117 tf.transformations.quaternion_from_euler(0, 0, self.
pose_bl[2]),
124 Calculate the distance between two x, y, theta arrays 126 :param pose1: Position to calculate distance from 127 :type pose1: [x, y, theta] 128 :param pose2: Position to calculate distance to 129 :type pose2: [x, y, theta] 130 :return: cartesian distance between the positions 133 if (len(pose1) == len(pose2)
and len(pose1) == 3):
134 dist = math.sqrt(pow(pose2[0] - pose1[0], 2) + pow(pose2[1] - pose1[1], 2))
142 Convert a MoveBaseGoal to a much condensed representation: a list of [x, y, theta] 144 :param goal: A moveBaseGoal 145 :return: a compact representation of the goal 148 roll, pitch, yaw = tf.transformations.euler_from_quaternion(
149 [goal.target_pose.pose.orientation.x,
150 goal.target_pose.pose.orientation.y,
151 goal.target_pose.pose.orientation.z,
152 goal.target_pose.pose.orientation.w])
153 return round_tuple((goal.target_pose.pose.position.x,
154 goal.target_pose.pose.position.y,