10 import std_msgs.msg
as std_msgs
11 import geometry_msgs.msg
as geometry_msgs
14 import dynamic_reconfigure.client
18 from .rotate
import Rotate
23 Manages connectivity information provided by services and provides this 24 for human interactive agent (aka remocon) connections. 43 '_controller_finished',
45 '_dynamic_reconfigure_client' 49 SPOTTED_RIGHT =
'right' 73 parameters[
'search_only'] = rospy.get_param(
'~search_only',
False)
74 parameters[
'base_postfix'] = rospy.get_param(
'~base_postfix',
'base')
75 parameters[
'base_frame'] = rospy.get_param(
'~base_frame',
'base_footprint')
76 parameters[
'odom_frame'] = rospy.get_param(
'~odom_frame',
'odom')
81 These are all public topics. Typically that will drop them into the /concert 85 publishers[
'result'] = rospy.Publisher(
'~result', std_msgs.Bool, queue_size=5)
86 publishers[
'initial_pose_trigger'] = rospy.Publisher(
'~initialise', std_msgs.Empty, queue_size=5)
87 publishers[
'enable_approach_controller'] = rospy.Publisher(
'~enable_approach_controller', std_msgs.String, queue_size=5)
88 publishers[
'disable_approach_controller'] = rospy.Publisher(
'~disable_approach_controller', std_msgs.Empty, queue_size=5)
91 subscribers[
'spotted_markers'] = rospy.Subscriber(
'~spotted_markers', std_msgs.String, self.
_ros_spotted_subscriber)
95 return (publishers, subscribers)
106 rospy.loginfo(
'enable ar pair approach')
111 self._tf_thread.start()
115 rospy.loginfo(
'disable ar pair approach')
117 self._publishers[
'result'].publish(std_msgs.Bool(
False))
129 if self.
_spotted_markers == Node.SPOTTED_BOTH
and self._rotate.is_running():
133 rospy.loginfo(
"AR Pair Approach : received result from the approach controller.")
135 rospy.loginfo(
"AR Pair Approach : Controller reached the goal.")
138 rospy.loginfo(
"AR Pair Approach : Controller failed to reach the goal.")
146 if not self._rotate.is_stopped():
152 if not rospy.is_shutdown():
153 self._dynamic_reconfigure_client.update_configuration({
'enabled':
'False'})
154 self._publishers[
'result'].publish(std_msgs.Bool(result))
156 self._tf_thread.join()
159 self._dynamic_reconfigure_client.update_configuration({
'enabled':
'True'})
161 if not found_markers:
162 result = self._rotate.execute()
166 rospy.loginfo(
"AR Pair Approach : found both ar pair markers.")
168 rospy.loginfo(
"AR Pair Approach : aborting initialisation and approach as requested.")
170 rospy.loginfo(
"AR Pair Approach : setting an initial pose from the global ar pair reference.")
171 self._publishers[
'initial_pose_trigger'].publish(std_msgs.Empty())
172 rospy.loginfo(
"AR Pair Approach : enabling the approach controller")
176 self._publishers[
'enable_approach_controller'].publish(base_target_frame)
182 rospy.loginfo(
"AR Pair Approach : disabling the approach controller")
183 self._publishers[
'disable_approach_controller'].publish(std_msgs.Empty())
194 (t, o) = self._listener.lookupTransform(self.
_parameters[
'odom_frame'], target_frame, rospy.Time(0))
196 self.
logwarn(
"couldn't get transfrom between %s and %s"%(self.
_parameters[
'odom_frame'], target_frame))
201 q = tf.transformations.quaternion_from_euler(1.57, -1.57, 0.0)
214 while self.
_running and not rospy.is_shutdown():
228 Do not call this if already running, you will cause self._rotate to become volatile. 230 @return : True or false depending on if we can skip this step or not. 232 direction = Rotate.CLOCKWISE
235 rospy.loginfo(
"AR Pair Approach : received an enable command, both spotted markers already in view!")
238 rospy.loginfo(
"AR Pair Approach : received an enable command, only left in view.")
240 rospy.loginfo(
"AR Pair Approach : received an enable command, only right in view.")
241 direction = Rotate.COUNTER_CLOCKWISE
244 rospy.logerr(
"AR Pair Approach : this should not happen")
246 (unused_t, orientation) = self._listener.lookupTransform(self.
_target_frame, self.
_parameters[
'base_frame'], rospy.Time(0))
247 unused_roll, unused_pitch, yaw = tf.transformations.euler_from_quaternion(orientation)
248 rospy.loginfo(
"AR Pair Search : current yaw = %s" % str(yaw))
249 direction = Rotate.COUNTER_CLOCKWISE
if yaw > 0
else Rotate.CLOCKWISE
251 direction = Rotate.COUNTER_CLOCKWISE
252 rospy.loginfo(
"AR Pair Search: received an enable command, none in view.")
253 self._rotate.init(yaw_absolute_rate=self.
_rate, yaw_direction=direction)
257 rospy.logwarn(
'AR Pair Approach : %s'%msg)
261 Parse the set of /remocons/<name>_<uuid> connections.
def __init__(self)
Initialisation.
def _set_target_base_transform(self, target_frame)
def _ros_relative_target_pose_subscriber(self, msg)
_dynamic_reconfigure_client
def _initialise_rotation(self)
Runtime.
def _ros_controller_result_callback(self, msg)
def _ros_spotted_subscriber(self, msg)
def _ros_enable_subscriber(self, msg)
Ros Api Functions.
def _post_execute(self, result)
def _setup_parameters(self)