Ejemplo n.º 1
0
    def test_straightline_distance_using_radius_and_turn_angle(self):
        vehicle = SimulatedVehicle(self.reliable_gps,self.globe,self.mock_logger)

        self.assertLess(percentage_diff(vehicle._straightline_distance(1,90),sqrt(2)),0.0001)
        self.assertLess(percentage_diff(vehicle._straightline_distance(1,180),2),0.0001)
        self.assertLess(percentage_diff(vehicle._straightline_distance(1,-180),2),0.0001)
        self.assertLess(percentage_diff(vehicle._straightline_distance(1,60),1),0.0001)
Ejemplo n.º 2
0
    def test_straightline_distance_using_radius_and_turn_angle(self):
        vehicle = SimulatedVehicle(self.reliable_gps, self.globe,
                                   self.mock_logger)

        self.assertLess(
            percentage_diff(vehicle._straightline_distance(1, 90), sqrt(2)),
            0.0001)
        self.assertLess(
            percentage_diff(vehicle._straightline_distance(1, 180), 2), 0.0001)
        self.assertLess(
            percentage_diff(vehicle._straightline_distance(1, -180), 2),
            0.0001)
        self.assertLess(
            percentage_diff(vehicle._straightline_distance(1, 60), 1), 0.0001)
Ejemplo n.º 3
0
    def test_should_turn_a_corner_if_the_rudder_is_deflected(self):
        bearing, time_s = 30, 2
        starting_position = Position(53, -2)
        rudder_deflection = 10
        gps = SimulatedGPS(starting_position, bearing, INITIAL_SPEED_IN_MS,
                           True)
        vehicle = SimulatedVehicle(gps, self.globe, self.mock_logger)
        turn_radius = vehicle._turn_radius(rudder_deflection)
        bearing_change = -vehicle._track_delta(INITIAL_SPEED_IN_MS * time_s,
                                               turn_radius)
        expected_track = to_360(bearing + bearing_change)
        expected_position = self.globe.new_position(
            starting_position, bearing + (0.5 * bearing_change),
            vehicle._straightline_distance(turn_radius, bearing_change))

        vehicle.rudder.set_position(rudder_deflection)
        vehicle.timer.wait_for(time_s)
        new_position = vehicle.gps.position

        self.assertEqual(new_position.longitude, expected_position.longitude)
        self.assertEqual(new_position.latitude, expected_position.latitude)
        self.assertEqual(round(expected_track, 5), round(vehicle.gps.track, 5))
        self.assertEqual(round(expected_track, 5),
                         round(vehicle.compass.bearing, 5))
Ejemplo n.º 4
0
    def test_should_turn_a_corner_if_the_rudder_is_deflected(self):
        bearing,time_s = 30,2
        starting_position = Position(53,-2)
        rudder_deflection = 10
        gps = SimulatedGPS(starting_position,bearing,INITIAL_SPEED_IN_MS,True)
        vehicle = SimulatedVehicle(gps,self.globe,self.mock_logger)
        turn_radius = vehicle._turn_radius(rudder_deflection)
        bearing_change = - vehicle._track_delta(INITIAL_SPEED_IN_MS*time_s,turn_radius)
        expected_track = to_360(bearing + bearing_change)
        expected_position = self.globe.new_position(starting_position,bearing + (0.5 * bearing_change),vehicle._straightline_distance(turn_radius,bearing_change))

        vehicle.rudder.set_position(rudder_deflection)
        vehicle.timer.wait_for(time_s)
        new_position = vehicle.gps.position

        self.assertEqual(new_position.longitude, expected_position.longitude)
        self.assertEqual(new_position.latitude, expected_position.latitude)
        self.assertEqual(round(expected_track,5),round(vehicle.gps.track,5))
        self.assertEqual(round(expected_track,5), round(vehicle.compass.bearing,5))