Advertisement

动手学运动规划:1.1.c 车辆运动学:自行车模型代码解析

阅读量:

You realize that certain types of birds are not intended for being confined, their feathers are simply too vibrant.

你了解某些鸟类注定无法被困在笼子里吗?它们每一根羽毛都在诉说着自由的独特光彩。 Shawshank Redemption 肯定会被记住.

�️代码实现与环境设置 :请参考0.2 环境配置和代码 | 动手学运动规划


本节提供了自行车模型的代码测试.

复制代码
    python3 tests/basic/kinematic_test.py
    
    
    bash

1.1.c.1 自行车模型实现

以下是以后轴中心为基准点的自行车模型的状态转移函数。更新后该状态的距离信息。

复制代码
    def bicycle_model(point, distance):
    next_point = copy.deepcopy(point)
    next_point.x += distance * cos(point.theta)
    next_point.y += distance * sin(point.theta)
    next_point.theta += normallization(distance * tan(point.steer) / WHEEL_BASE)
    
    return next_point
    
    
    python

tests\basic\kinematic_test.py调用了这个函数,展示了模型效果

1.1.c.2 代码测试

(1)前轮偏角固定,车辆走出一道圆弧:

复制代码
     for t in np.arange(0, total_t, delta_t):
        new_p = bicycle_model(points[-1], points[-1].v * delta_t)
        points.append(new_p)
    
    
    python

(2)前轮偏角逐渐变化:

复制代码
    for t in np.arange(0, total_t, delta_t):
        new_p = points[-1]
        if t < 3:
            new_p.steer = max(new_p.steer - 0.01, -MAX_STEER)
        else:
            new_p.steer = min(new_p.steer + 0.02, MAX_STEER)
        new_p = bicycle_model(new_p, new_p.v * delta_t)
        points.append(new_p)
    
    
    python

$自驾车官方网和自动驾驶官方网

$self-driving cars official website and autonomous vehicles official website

🐮GitHub 代码仓:https://github.com/Hello-Xiao-Bai/Planning-XiaoBai!

🌠代码配合官网教程食用更佳!

🚀知乎,微信,知识星球全平台同号!

全部评论 (0)

还没有任何评论哟~