def test_act(): v = Vehicle(road=None, position=[0, 0], velocity=20, heading=0) v.act({'acceleration': 1, 'steering': 0}) for _ in range(1 * FPS): v.step(dt=1/FPS) assert v.velocity == pytest.approx(21) v.act({'acceleration': 0, 'steering': 0.5}) for _ in range(1 * FPS): v.step(dt=1/FPS) assert v.velocity == pytest.approx(21) assert v.position[1] > 0
def test_brake(): v = Vehicle(road=None, position=[0, 0], velocity=20, heading=0) for _ in range(10 * FPS): v.act({'acceleration': min(max(-1*v.velocity, -6), 6), 'steering': 0}) v.step(dt=1/FPS) assert v.velocity == pytest.approx(0, abs=0.01)