2import numpy.testing
as npt
4from custom_interfaces.msg
import ConeArray, VehicleState, PathPointArray, Cone, PathPoint, Point2d
5from eufs_msgs.msg
import ConeArrayWithCovariance, CarState, ConeWithCovariance
6from geometry_msgs.msg
import TransformStamped, TwistWithCovarianceStamped
7from visualization_msgs.msg
import MarkerArray, Marker
8from nav_msgs.msg
import Odometry
10 format_vehicle_state_msg,
11 format_cone_array_msg,
12 format_marker_array_msg,
13 format_transform_stamped_msg,
14 format_twist_with_covariance_stamped_msg,
16 format_eufs_cone_array_with_covariance_msg,
17 format_nav_odometry_msg,
18 format_path_point_array_msg,
25 Test case for the format methods of the Evaluator class.
30 Set up the test environment by initializing expected value
86 Test case to check the formatting of a VehicleState message
93 msg.linear_velocity = 1.0
94 msg.angular_velocity = 2.0
96 format_position, format_velocities = format_vehicle_state_msg(msg)
98 npt.assert_array_almost_equal(format_position, self.
expected_position[0], decimal=6)
103 Test case to check the formatting of a ConeArray message
107 cone_msg.position.x = 1.0
108 cone_msg.position.y = 2.0
109 cone_msg.color =
'blue'
110 cone_msg.confidence = 73.0
112 msg.cone_array.append(cone_msg)
114 formated_position = format_cone_array_msg(msg)
120 Test case to check the formatting of a MarkerArray message
124 marker.pose.position.x = 1.0
125 marker.pose.position.y = 2.0
127 msg.markers.append(marker)
129 formated_msg = format_marker_array_msg(msg)
130 formated_msg[0][3] = 73
131 formated_msg[0][2] = 0.0
137 Test case to check the formatting of a TransformStamped message
140 msg = TransformStamped()
141 msg.transform.translation.x = 1.0
142 msg.transform.translation.y = 2.0
143 msg.transform.translation.z = 0.0
144 msg.transform.rotation.x = 0.0
145 msg.transform.rotation.y = 0.0
146 msg.transform.rotation.z = 0.7071
147 msg.transform.rotation.w = 0.7071
149 formated_msg = format_transform_stamped_msg(msg)
156 Test case to check the formatting of a TwistWithCovarianceStamped message
159 msg = TwistWithCovarianceStamped()
160 msg.twist.twist.linear.x = 1.0
161 msg.twist.twist.linear.y = 1.0
162 msg.twist.twist.angular.z = 2.0
164 formated_msg = format_twist_with_covariance_stamped_msg(msg)
170 Test case to check the formatting of a CarState message
174 msg.pose.pose.position.x = 1.0
175 msg.pose.pose.position.y = 2.0
176 msg.pose.pose.orientation.x = 0.0
177 msg.pose.pose.orientation.y = 0.0
178 msg.pose.pose.orientation.z = 0.7071
179 msg.pose.pose.orientation.w = 0.7071
180 msg.twist.twist.linear.x = 1.0
181 msg.twist.twist.linear.y = 1.0
182 msg.twist.twist.angular.z = 2.0
184 formated_msg1, formated_msg2 = format_car_state_msg(msg)
191 Test case to check the formatting of a ConeArrayWithCovariance message
194 msg = ConeArrayWithCovariance()
195 cone = ConeWithCovariance()
198 msg.blue_cones.append(cone)
200 formated_msg = format_eufs_cone_array_with_covariance_msg(msg)
201 formated_msg[0][3] = 73
207 Test case to check the formatting of a Odometry message
211 msg.pose.pose.position.x = 1.0
212 msg.pose.pose.position.y = 2.0
213 msg.pose.pose.orientation.x = 0.0
214 msg.pose.pose.orientation.y = 0.0
215 msg.pose.pose.orientation.z = 0.7071
216 msg.pose.pose.orientation.w = 0.7071
217 msg.twist.twist.linear.x = 1.0
218 msg.twist.twist.linear.y = 1.0
219 msg.twist.twist.angular.z = 2.0
221 formated_msg1, formated_msg2 = format_nav_odometry_msg(msg)
228 Test case to check the formatting of a PathPointArray message
231 msg = PathPointArray()
232 path_point = PathPoint()
236 msg.pathpoint_array.append(path_point)
238 formated_msg = format_path_point_array_msg(msg)
244 Test case to check the formatting of a Point2d message
251 formated_msg = format_point2d_msg(msg)
253 npt.assert_array_almost_equal(formated_msg, [2, 1], decimal=6)