test_vehicle.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:burro 作者: yconst 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号