예제 #1
0
 def test_get_way_points_distance(self):
     params_test = get_test_params()
     rf = AwsDeepRacerReward(params_test)
     self.assertEqual(rf.get_way_points_distance((0, 0), (2, 0)), 2)
     self.assertEqual(rf.get_way_points_distance((0, 0), (2, 2)),
                      math.sqrt(8))
     self.assertEqual(rf.get_way_points_distance((-2, 4), (-4, 2)),
                      math.sqrt(8))
     self.assertEqual(rf.get_way_points_distance((0, 0), (1, 0)), 1)
예제 #2
0
 def test_get_optimum_speed_ratio(self):
     params_test = get_test_params()
     params_test['heading'] = 0
     params_test['distance_from_center'] = 0
     params_test['steering_angle'] = 0
     params_test['closest_waypoints'] = (0, 1)
     params_test['x'] = params_test['waypoints'][
         params_test['closest_waypoints'][0]][0]
     params_test['y'] = params_test['waypoints'][
         params_test['closest_waypoints'][0]][1]
     rf = AwsDeepRacerReward(params_test)
     self.assertEqual(rf.get_optimum_speed_ratio(), 1.0)
예제 #3
0
    def test_get_expected_turn_direction(self):
        params_test = get_test_params()
        params_test['heading'] = 0
        params_test['waypoints'] = [(0, 0), (1, 0), (2, 0), (3, 1), (4, 1),
                                    (5, 1), (6, -6), (-1, -6), (-1, 0)]

        params_test['closest_waypoints'] = [0, 1]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_expected_turn_direction(), 'LEFT')

        params_test['closest_waypoints'] = [3, 4]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_expected_turn_direction(), 'RIGHT')

        params_test['closest_waypoints'] = [8, 0]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_expected_turn_direction(), 'STRAIGHT')
예제 #4
0
 def test_get_waypoint(self):
     params_test = get_test_params()
     params_test['waypoints'] = [(0, 0), (1, 0), (2, 0), (3, 3)]
     rf = AwsDeepRacerReward(params_test)
     self.assertEqual(rf.get_way_point(0), (0, 0))
     self.assertEqual(rf.get_way_point(1), (1, 0))
     self.assertEqual(rf.get_way_point(2), (2, 0))
     self.assertEqual(rf.get_way_point(3), (3, 3))
     self.assertEqual(rf.get_way_point(4), (0, 0))
     self.assertEqual(rf.get_way_point(5), (1, 0))
     self.assertEqual(rf.get_way_point(-1), (3, 3))
     self.assertEqual(rf.get_way_point(-2), (2, 0))
     self.assertEqual(rf.get_way_point(-3), (1, 0))
예제 #5
0
 def test_get_heading_beetween_waypoints(self):
     params_test = get_test_params()
     rf = AwsDeepRacerReward(params_test)
     self.assertEqual(rf.get_heading_between_waypoints((0, 0), (2, 0)), 0)
     self.assertEqual(rf.get_heading_between_waypoints((0, 0), (0, 2)), 90)
     self.assertEqual(rf.get_heading_between_waypoints((0, 0), (0, -2)),
                      -90)
     self.assertEqual(rf.get_heading_between_waypoints((0, 0), (2, 2)), 45)
     self.assertEqual(rf.get_heading_between_waypoints((0, 0), (-2, -2)),
                      -135)
예제 #6
0
    def test_get_turn_angle(self):
        params_test = get_test_params()
        params_test['heading'] = 0
        params_test['waypoints'] = [(0, 0), (1, 0), (2, 0), (3, 1), (4, 1),
                                    (5, 1), (6, -6), (-1, -6), (-1, 0)]

        params_test['closest_waypoints'] = [0, 1]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_turn_angle(), 0)

        params_test['closest_waypoints'] = [1, 2]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_turn_angle(), 0)

        params_test['closest_waypoints'] = [2, 3]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_turn_angle(), 45)

        params_test['closest_waypoints'] = [5, 6]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_turn_angle(), -81.86989764584403)
예제 #7
0
    def test_get_car_heading_error(self):
        params_test = get_test_params()
        params_test['heading'] = 0
        params_test['waypoints'] = [(0, 0), (2, 0), (2, 2), (0, 2), (0, 0),
                                    (2, 2), (4, 0)]

        params_test['closest_waypoints'] = [0, 1]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_car_heading_error(), 0)

        params_test['closest_waypoints'] = [1, 2]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_car_heading_error(), 90)

        params_test['closest_waypoints'] = [2, 3]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_car_heading_error(), 180)

        params_test['closest_waypoints'] = [3, 4]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_car_heading_error(), -90)

        params_test['closest_waypoints'] = [4, 5]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_car_heading_error(), 45)

        params_test['closest_waypoints'] = [5, 6]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_car_heading_error(), -45)
예제 #8
0
    def test_is_in_turn(self):
        params_test = get_test_params()
        params_test['heading'] = 0
        params_test['waypoints'] = [(0, 0), (1, 0), (2, 0), (3, 1), (4, 1),
                                    (5, 1), (6, -6), (-1, -6), (-1, 0)]

        params_test['closest_waypoints'] = [0, 1]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.is_in_turn(), False)

        params_test['closest_waypoints'] = [1, 2]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.is_in_turn(), False)

        params_test['closest_waypoints'] = [2, 3]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.is_in_turn(), True)

        params_test['closest_waypoints'] = [5, 6]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.is_in_turn(), True)