check all directions
This commit is contained in:
@@ -82,7 +82,7 @@ class TestPositionChanger(unittest.TestCase):
|
|||||||
def validate_output(self, output):
|
def validate_output(self, output):
|
||||||
assert len(output) > 0, 'Output is empty'
|
assert len(output) > 0, 'Output is empty'
|
||||||
|
|
||||||
def test_positionchanger_lidar_moves_away_front(self, px4_controller_node, proc_output):
|
def test_positionchanger_lidar_moves_away_all(self, px4_controller_node, proc_output):
|
||||||
self.node.get_logger().info("STARTING TEST test_positionchanger_lidar_moves_away")
|
self.node.get_logger().info("STARTING TEST test_positionchanger_lidar_moves_away")
|
||||||
self.request.front_back = 1.0
|
self.request.front_back = 1.0
|
||||||
self.request.left_right = 0.0
|
self.request.left_right = 0.0
|
||||||
@@ -107,33 +107,14 @@ class TestPositionChanger(unittest.TestCase):
|
|||||||
lidar_msgs_sent += 1
|
lidar_msgs_sent += 1
|
||||||
if (lidar_msgs_sent == 10):
|
if (lidar_msgs_sent == 10):
|
||||||
lidar_msg.sensor_2 = 0.3
|
lidar_msg.sensor_2 = 0.3
|
||||||
|
elif (lidar_msgs_sent == 20):
|
||||||
|
lidar_msg.sensor_4 = 0.66
|
||||||
|
elif (lidar_msgs_sent == 30):
|
||||||
|
lidar_msg.sensor_3 = 0.79
|
||||||
if not self.called_positionchanger_service:
|
if not self.called_positionchanger_service:
|
||||||
future = self.move_position_client.call_async(self.request)
|
future = self.move_position_client.call_async(self.request)
|
||||||
future.add_done_callback(self.move_position_callback)
|
future.add_done_callback(self.move_position_callback)
|
||||||
launch_testing.asserts.assertInStderr(proc_output, "Collision prevention front: -0.5", 'position_changer-1')
|
launch_testing.asserts.assertInStderr(proc_output, "Collision prevention front: -0.5", 'position_changer-1')
|
||||||
launch_testing.asserts.assertInStderr(proc_output, "Collision prevention left: -0.7", 'position_changer-1')
|
launch_testing.asserts.assertInStderr(proc_output, "Collision prevention left: 0.7", 'position_changer-1')
|
||||||
|
launch_testing.asserts.assertInStderr(proc_output, "Collision prevention right: -0.34", 'position_changer-1')
|
||||||
def test_positionchanger_lidar_moves_away_back(self, px4_controller_node, proc_output):
|
launch_testing.asserts.assertInStderr(proc_output, "Collision prevention back: 0.21", 'position_changer-1')
|
||||||
self.node.get_logger().info("STARTING TEST test_positionchanger_lidar_moves_away")
|
|
||||||
self.request.front_back = -1.0
|
|
||||||
self.request.left_right = 0.0
|
|
||||||
self.request.up_down = 0.0
|
|
||||||
self.request.angle = 0.0
|
|
||||||
|
|
||||||
lidar_msg = LidarReading()
|
|
||||||
lidar_msg.sensor_1 = 2.0
|
|
||||||
lidar_msg.sensor_2 = 2.0
|
|
||||||
lidar_msg.sensor_3 = 0.5
|
|
||||||
lidar_msg.sensor_4 = 2.0
|
|
||||||
lidar_msg.imu_data = [1.0, 1.0, 1.0, 1.0]
|
|
||||||
end_time = time.time() + 10.0
|
|
||||||
|
|
||||||
self.node.get_logger().info("STARTING while loop test")
|
|
||||||
|
|
||||||
while time.time() < end_time:
|
|
||||||
rclpy.spin_once(self.node, timeout_sec=0.1)
|
|
||||||
self.lidar_publisher.publish(lidar_msg)
|
|
||||||
if not self.called_positionchanger_service:
|
|
||||||
future = self.move_position_client.call_async(self.request)
|
|
||||||
future.add_done_callback(self.move_position_callback)
|
|
||||||
launch_testing.asserts.assertInStderr(proc_output, "Collision prevention back: 0.5", 'position_changer-1')
|
|
||||||
Reference in New Issue
Block a user