41 from geometry_msgs.msg
import Pose
44 from tf.transformations
import quaternion_from_euler
48 Tests are based on http://download.ros.org/data/ar_track_alvar/ar_track_alvar_4markers_tork_2017-01-30-15-03-19.bag 52 rospy.init_node(
'test_armarker_ros_detect')
60 DEPRECATED: This does not return meaningful values for some reason. 61 @param origin: lookupTransform's 1st argument. 62 @param target: lookupTransform's 2nd argument. 63 @rtype: ([str], [str]) 64 @return: Translation and rotation. 66 while not rospy.is_shutdown():
68 (trans,rot) = self.tflistener.lookupTransform(origin, target, rospy.Time(0))
71 rospy.logerr(str(e) +
' target={}'.format(target))
77 Aiming the real output taken from a bag file. 80 tf_expected = [[[0.04464459977845401, 0.05341412598745035, 0.26796900627543024], [0.6726999185589797, 0.7391474391806558, -0.01739267319701629, -0.028868280906256056]],
81 [[-0.04805772245624329, 0.039528315926071665, 0.26775882622136327], [0.48207151562664247, 0.8758763282975102, -0.016363763970395625, -0.013414118615296202]],
82 [[0.007233278235745441, 0.015615692018491452, 0.26619586686955365], [0.08546919545682985, 0.9959809257461487, 0.00424040439, -0.02677659572186436]],
83 [[0.06223014382428272, 0.014613815037010106, 0.26226145707174475], [-0.46400320825216246, 0.8850390875261293, 0.032644264656690035, -0.018471282241381157]]]
84 for i
in range (0, len(tf_expected)):
85 while not rospy.is_shutdown():
87 target_frame =
'/ar_marker_{}'.format(i)
88 (trans, rot) = self.tflistener.lookupTransform(
'/camera', target_frame, rospy.Time(0))
91 rospy.logerr(str(e) +
' target_frame={}'.format(target_frame))
94 for v_ret, v_expected
in zip(trans, tf_expected[i][0]):
96 numpy.testing.assert_approx_equal(
97 v_ret, v_expected, significant=1)
99 for v_ret, v_expected
in zip(rot, tf_expected[i][1]):
100 numpy.testing.assert_approx_equal(
101 v_ret, v_expected, significant=1)
103 if __name__ ==
'__main__':
105 rostest.rosrun(
'ar_track_alvar',
'test_ar_alvar_ros', TestArAlvarRos)
def _lookup_tf(self, origin, target)