Browse Source

Publish tf frame of dock to tf tree

autodock/aruco
hello-chintan 1 year ago
parent
commit
421714ea30
3 changed files with 28 additions and 1 deletions
  1. +3
    -0
      stretch_core/action/ArucoHeadScan.action
  2. +1
    -0
      stretch_core/nodes/aruco_head_scan_client.py
  3. +24
    -1
      stretch_core/nodes/detect_aruco_markers.py

+ 3
- 0
stretch_core/action/ArucoHeadScan.action View File

@ -6,6 +6,9 @@ uint32 aruco_id
# Specify the camera tilt_angle at which to scan # Specify the camera tilt_angle at which to scan
float32 tilt_angle float32 tilt_angle
# Publish tf relative to the map frame
bool publish_to_map
# If robot should rotate to cover the blind spot generated by the mast # If robot should rotate to cover the blind spot generated by the mast
bool fill_in_blindspot_with_second_scan bool fill_in_blindspot_with_second_scan

+ 1
- 0
stretch_core/nodes/aruco_head_scan_client.py View File

@ -14,6 +14,7 @@ def main():
goal = ArucoHeadScanGoal() goal = ArucoHeadScanGoal()
goal.aruco_id = 245 goal.aruco_id = 245
goal.tilt_angle = -0.68 goal.tilt_angle = -0.68
goal.publish_to_map = True
goal.fill_in_blindspot_with_second_scan = False goal.fill_in_blindspot_with_second_scan = False
goal.fast_scan = False goal.fast_scan = False

+ 24
- 1
stretch_core/nodes/detect_aruco_markers.py View File

@ -528,6 +528,8 @@ class ArucoHeadScan(hm.HelloNode):
self.aruco_found = False self.aruco_found = False
self.markers = MarkerArray().markers self.markers = MarkerArray().markers
self.joint_state = JointState() self.joint_state = JointState()
self.listener = tf.TransformListener()
self.tf_broadcaster = tf.TransformBroadcaster()
def execute_cb(self, goal): def execute_cb(self, goal):
self.goal = goal self.goal = goal
@ -535,6 +537,7 @@ class ArucoHeadScan(hm.HelloNode):
self.tilt_angle = self.goal.tilt_angle self.tilt_angle = self.goal.tilt_angle
self.fill_in_blindspot_with_second_scan = self.goal.fill_in_blindspot_with_second_scan self.fill_in_blindspot_with_second_scan = self.goal.fill_in_blindspot_with_second_scan
self.fast_scan = self.goal.fast_scan self.fast_scan = self.goal.fast_scan
self.publish_to_map = self.goal.publish_to_map
pan_angle = 0.0 pan_angle = 0.0
scan_point = JointTrajectoryPoint() scan_point = JointTrajectoryPoint()
@ -555,13 +558,26 @@ class ArucoHeadScan(hm.HelloNode):
# TODO: check distance of aruco to base_link < 2m # TODO: check distance of aruco to base_link < 2m
for pan_angle in np.arange(-3.69, 1.66, 0.35): for pan_angle in np.arange(-3.69, 1.66, 0.35):
time.sleep(1.0)
time.sleep(2.0)
markers = self.markers markers = self.markers
rospy.loginfo("Markers found: {}".format(markers)) rospy.loginfo("Markers found: {}".format(markers))
if markers != []: if markers != []:
for marker in markers: for marker in markers:
if marker.id == self.aruco_id: if marker.id == self.aruco_id:
self.aruco_found = True self.aruco_found = True
self.aruco_name = marker.text
if self.publish_to_map:
(trans,rot) = self.listener.lookupTransform('map', self.aruco_name, rospy.Time(0))
rospy.loginfo("trans: {}".format(trans))
rospy.loginfo("rot: {}".format(rot))
self.broadcast_tf(trans, rot, self.aruco_name, 'map')
if self.aruco_name == 'docking_station':
rospy.loginfo("Publishing predock pose")
self.broadcast_tf([0.0, -0.249, 1.0], [0.0, 0.0, 0.0, 1.0], 'predock_pose', 'docking_station')
rospy.loginfo("Publishing dock pose")
self.broadcast_tf([0.0, -0.249, 0.25], [0.0, 0.0, 0.0, 1.0], 'dock_pose', 'docking_station')
if not self.aruco_found: if not self.aruco_found:
self.feedback.pan_angle = pan_angle self.feedback.pan_angle = pan_angle
self.server.publish_feedback(self.feedback) self.server.publish_feedback(self.feedback)
@ -588,6 +604,13 @@ class ArucoHeadScan(hm.HelloNode):
rospy.loginfo("Could not find aruco marker {}".format(str)) rospy.loginfo("Could not find aruco marker {}".format(str))
self.server.set_aborted(self.result) self.server.set_aborted(self.result)
def broadcast_tf(self, pos, rot, name, ref):
self.tf_broadcaster.sendTransform(pos,
rot,
rospy.Time.now(),
name,
ref)
def aruco_callback(self, msg): def aruco_callback(self, msg):
self.markers = msg.markers self.markers = msg.markers

Loading…
Cancel
Save