test_parser_pass.py
Go to the documentation of this file.
1 import rospy
2 import pytest
3 
4 from sensor_msgs.msg import Image
5 from aruco_pose.msg import MarkerArray
6 from visualization_msgs.msg import MarkerArray as VisMarkerArray
7 
8 
9 @pytest.fixture
10 def node():
11  return rospy.init_node('aruco_pose_test', anonymous=True)
12 
13 def approx(expected):
14  return pytest.approx(expected, abs=1e-4) # compare floats more roughly
15 
16 def test_markers(node):
17  markers = rospy.wait_for_message('aruco_map/visualization', VisMarkerArray, timeout=5)
18  assert len(markers.markers) == 6
19 
20  assert markers.markers[0].pose.position.x == approx(0)
21  assert markers.markers[0].pose.position.y == approx(0)
22  assert markers.markers[0].pose.position.z == approx(0)
23 
24  assert markers.markers[1].pose.position.x == approx(1)
25  assert markers.markers[1].pose.position.y == approx(1)
26  assert markers.markers[1].pose.position.z == approx(1)
27 
28  assert markers.markers[2].pose.position.x == approx(1)
29  assert markers.markers[2].pose.position.y == approx(0)
30  assert markers.markers[2].pose.position.z == approx(0.5)
31 
32  assert markers.markers[3].pose.position.x == approx(0)
33  assert markers.markers[3].pose.position.y == approx(1)
34  assert markers.markers[3].pose.position.z == approx(0)
35 
36  assert markers.markers[4].pose.position.x == approx(1)
37  assert markers.markers[4].pose.position.y == approx(0.5)
38  assert markers.markers[4].pose.position.z == approx(0)
39 
40  assert markers.markers[5].pose.position.x == approx(2.2)
41  assert markers.markers[5].pose.position.y == approx(0.2)
42  assert markers.markers[5].pose.position.z == approx(0)
43 
44  assert markers.markers[0].scale.x == approx(0.33)
45  assert markers.markers[0].scale.y == approx(0.33)
46  assert markers.markers[1].scale.x == approx(0.225)
47  assert markers.markers[1].scale.y == approx(0.225)
48  assert markers.markers[2].scale.x == approx(0.45)
49  assert markers.markers[2].scale.y == approx(0.45)
50  assert markers.markers[3].scale.x == approx(0.15)
51  assert markers.markers[3].scale.y == approx(0.15)
52  assert markers.markers[4].scale.x == approx(0.25)
53  assert markers.markers[4].scale.y == approx(0.25)
54  assert markers.markers[5].scale.x == approx(0.35)
55  assert markers.markers[5].scale.y == approx(0.35)
56 
57 def test_map_image(node):
58  img = rospy.wait_for_message('aruco_map/image', Image, timeout=5)
59  assert img.width == 2000
60  assert img.height == 2000
61  assert img.encoding in ('mono8', 'rgb8')
def test_markers(node)
def test_map_image(node)
def approx(expected)


aruco_pose
Author(s): Oleg Kalachev
autogenerated on Mon Feb 28 2022 22:08:24