Exemple #1
0
 def test_bad_trust_at_start(self, part: AngleRoadPart):
     assert part.run(road_ellipse=Ellipse((70, 71), (100, 200), 135.0, trust=0.1)) == 0.0, \
         'Angle should be ignored when no previous value and bad trust value'
     assert part.run(road_ellipse=Ellipse((70, 71), (100, 200), 135.0, trust=0.1)) == 0.0, \
         'No previous angle value'
     assert part.run(road_ellipse=Ellipse((70, 71), (100, 200), 135.0, trust=0.5)) == -0.5, \
         'At startup, use average between angle and straight ahead'
Exemple #2
0
    def test_straight_ahead(self, part: AngleRoadPart):
        assert 0 < part.run(
            road_ellipse=Ellipse((70, 71), (100, 200), 89.0, 1.0)) < 0.1
        assert -0.1 < part.run(
            road_ellipse=Ellipse((70, 71), (100, 200), 91.0, 1.0)) < 0.0

        assert 0 < part.run(
            road_ellipse=Ellipse((70, 71), (100, 200), 269.0, 1.0)) < 0.1
        assert -0.1 < part.run(
            road_ellipse=Ellipse((70, 71), (100, 200), 271.0, 1.0)) < 0.0
Exemple #3
0
 def test_turn(self, part: ThrottleEllipsePart,
               throttle_config_controller: ThrottleConfigController):
     ellipse = Ellipse(center=(12, 13), axes=(10, 50), angle=90, trust=1.0)
     assert part.run(road_ellipse=ellipse) < 0.5
     ellipse = Ellipse(center=(12, 13), axes=(50, 10), angle=90, trust=1.0)
     assert part.run(road_ellipse=ellipse) < 0.5
     ellipse = Ellipse(center=(12, 13),
                       axes=(10, 50000),
                       angle=90,
                       trust=1.0)
     assert part.run(
         road_ellipse=ellipse) == throttle_config_controller.min_speed
Exemple #4
0
 def test_trust_ellipse(
         self, part: ThrottleEllipsePart,
         throttle_config_controller: ThrottleConfigController):
     ellipse = Ellipse(center=(12, 13), axes=(50, 50), angle=90, trust=0.0)
     assert part.run(
         road_ellipse=ellipse) == throttle_config_controller.min_speed
     ellipse = Ellipse(center=(12, 13), axes=(50, 50), angle=90, trust=0.5)
     assert throttle_config_controller.min_speed < part.run(
         ellipse) < throttle_config_controller.max_speed
     ellipse = Ellipse(center=(12, 13), axes=(50, 50), angle=90, trust=1.0)
     assert part.run(
         road_ellipse=ellipse) == throttle_config_controller.max_speed
Exemple #5
0
 def test_straight_line(
         self, part: ThrottleEllipsePart,
         throttle_config_controller: ThrottleConfigController):
     ellipse = Ellipse(center=(12, 13), axes=(50, 50), angle=90, trust=1.0)
     assert part.run(road_ellipse=ellipse) == 1.0
Exemple #6
0
 def test_trust_not_perfect(self, part: AngleRoadPart):
     # Record previous value
     assert part.run(
         road_ellipse=Ellipse((70, 71), (100, 200), 45.0, trust=1.0)) == 1.0
     assert part.run(road_ellipse=Ellipse((70, 71), (100, 200), 135.0, trust=0.5)) == 0.25, \
         'At startup, use weighted average between current and previous angles'
Exemple #7
0
 def test_bad_trust(self, part: AngleRoadPart):
     assert 0 < part.run(
         road_ellipse=Ellipse((70, 71), (100, 200), 89.0, trust=1.0)) < 0.1
     assert 0 < part.run(road_ellipse=Ellipse((70, 71), (100, 200), 135.0, trust=0.1)) < 0.1, \
         'Previous value should be used when trust < 0.5'
Exemple #8
0
 def test_turn_left(self, part: AngleRoadPart):
     assert part.run(
         road_ellipse=Ellipse((70, 71), (100, 200), 135.0, 1.0)) == -1.0
     assert part.run(
         road_ellipse=Ellipse((70, 71), (100, 200), 180.0, 1.0)) == -1.0
Exemple #9
0
 def test_turn_right(self, part: AngleRoadPart):
     assert part.run(
         road_ellipse=Ellipse((70, 71), (100, 200), 45.0, 1.0)) == 1.0
     assert part.run(
         road_ellipse=Ellipse((70, 71), (100, 200), 0.1, 1.0)) == 1.0