目标:在未知环境中寻找生路
比喻:就像在茂密的树林中跑校,你不需要地图。
说明:算法自动忽略小缝隙,选择最宽敞的通道。
threshold
P
avoidance_angle
1.7 m/s
# 1. 启动避障控制节点 roslaunch tianracer_navigation follow_the_gap.launch # 2. 交互观察终端输出 rostopic echo /ackermann_cmd_stamped
在 follow_the_gap.py 中:
follow_the_gap.py
# 第一步:把小于 threshold 的点标记为障碍 lis = [1 if a > threshold else 0 for a in dis_list] # 第二步:寻找最长连续为 1 的区域 gap_list = get_gap(dis_list, threshold) target_angle = (end_idx + start_idx) / 2 # 取中央 # 第三步:映射到转向指令 steering_angle = - target_angle * P
本课产出检查点: