def test_waypoint_setting(state, start, target, expected): # (self,i, Swarm_Size, start_x, start_y, start_z, start_yaw) AUV = Vehicle(0, 1, start[0], start[1], start[2], 0) config = sim_config('config/sim_config.csv') AUV.state = state AUV.set_waypoint(target, config) assert (abs(AUV.waypoints[0][0] - expected[0]) < 0.0000001 and abs(AUV.waypoints[0][1] - expected[1]) < 0.0000001 and abs(AUV.waypoints[0][2] - expected[2]) < 0.0000001)
def test_set_state(curr_state, desired_state, z, expected): AUV = Vehicle(0, 1, 50, 50, -10, 0) AUV.state = curr_state AUV.z = z if expected == 1: with pytest.raises(Exception) as e_info: AUV.set_state(desired_state) else: AUV.set_state(desired_state) assert AUV.state == desired_state
def test_time_checks(elps_time, state, expected): # (self,i, Swarm_Size, start_x, start_y, start_z, start_yaw) AUV = Vehicle(0, 1, 0, 0, -50, 0) config = sim_config('config/sim_config.csv') AUV.state = state #t_uw set to 1200 AUV.time_checks(elps_time, config) assert AUV.state == expected
def test_surfacing(z, state, expected): # (self,i, Swarm_Size, start_x, start_y, start_z, start_yaw) AUV = Vehicle(0, 1, 0, 0, z, 0) config = sim_config('config/sim_config.csv') base = Base_Station(config.swarm_size) # AUV at 1m depth and surfacing AUV.state = state # Try to sat comm (this triggers state change to diving # should remain surfacing as deeper than conditional depth for sat (0.5m) AUV.sat_comms(base, config.swarm_size, 0) assert AUV.state == expected
def test_reached_waypoint(): # (self,i, Swarm_Size, start_x, start_y, start_z, start_yaw) AUV = Vehicle(0, 1, 50, 50,-10 , 0) config = sim_config('config/sim_config.csv') AUV.state = 0 # AUV at 1m depth and surfacing AUV.waypoints = [[50,50,-20]] AUV.move_to_waypoint() assert AUV.state == 0 AUV.z = -19 AUV.move_to_waypoint() assert AUV.state == 1
def test_reached_waypoint(): # (self,i, Swarm_Size, start_x, start_y, start_z, start_yaw) AUV = Vehicle(0, 1, 50, 50, -10, 0) config = sim_config('config/sim_config.csv') AUV.state = 0 # AUV at 1m depth and surfacing AUV.waypoints = [[50, 50, -20]] AUV.move_to_waypoint() assert AUV.state == 0 AUV.z = -19 AUV.move_to_waypoint() assert AUV.state == 1