def test_vehicle_pipeline(self):
throttle = random.uniform(-1.0, 1.0)
angle = random.uniform(-1.0, 1.0) * config.car.max_steering_angle
l_a = config.car.L
w_d = config.car.W
w_o = config.car.W_offset
angle_radians = math.radians(angle)
steer_tan = math.tan(angle_radians)
r = l_a / steer_tan
l_out = throttle * (1.0 - (w_d * 0.5 - w_o)/r ) * \
config.differential_car.left_mult
r_out = throttle * (1.0 + (w_d * 0.5 + w_o)/r ) * \
config.differential_car.right_mult
l_out = min(max(l_out, -1), 1)
l_out = min(max(l_out, -1), 1)
self.vehicle.pilot().set_response(angle, throttle)
self.vehicle.step()
self.assertAlmostEqual(self.vehicle.mixer.left_driver.output,
l_out, places=5)
self.assertAlmostEqual(self.vehicle.mixer.right_driver.output,
r_out, places=5)
评论列表
文章目录