前言
Fast-Planner作为无人机规划界的网红,因为众多优点成为许多初学者入门的首选。
规划涉及的内容重要,表现为代码量庞大。
本文一是为了记录自己的学习经历,一是为了帮助其他初学者来了解如何阅读一个完整的项目。
总览
下载编译本文不涉及,假设已经可以独立完成仿真的复现。
首先给出Fast-Planner的文件夹架构
.
├── bag 录包脚本
│ └── record.sh
├── bspline b样条相关
│ ├── CMakeLists.txt
│ ├── include
│ ├── package.xml
│ └── src
├── bspline_opt b优化相关
│ ├── CMakeLists.txt
│ ├── include
│ ├── package.xml
│ ├── script
│ └── src
├── path_searching 前段搜索
│ ├── CMakeLists.txt
│ ├── include
│ ├── package.xml
│ └── src
├── plan_env 建图模块
│ ├── CMakeLists.txt
│ ├── include
│ ├── package.xml
│ └── src
├── plan_manage 规划主要内容
│ ├── CMakeLists.txt
│ ├── config
│ ├── include
│ ├── launch
│ ├── msg
│ ├── package.xml
│ ├── README.md
│ ├── script
│ └── src
├── poly_traj 多项式轨迹的定义
│ ├── CMakeLists.txt
│ ├── include
│ ├── package.xml
│ └── src
└── traj_utils 一些工具
├── CMakeLists.txt
├── include
├── package.xml
└── src
个人认为较为重点的是 plan manage(管理整个项目的入口)、path-searching(前段搜索部分)bspline opt(后端优化部分),bspline、poly traj 、traj utils 主要是一些辅助工具。
启动
许多新手对整个项目的运行逻辑不清楚,这里逐步介绍在运行仿真后,各个模块之间的关系和运行逻辑。以Github上的教程为例:
1、启动RViz
<!-- go to your workspace and run: -->
source devel/setup.bash
roslaunch plan_manage rviz.launch
这一部分是启动的RVIZ,为后边可视化提供基础。
2、启动规划部分
<!-- open a new terminal, go to your workspace and run: -->
source devel/setup.bash
roslaunch plan_manage kino_replan.launch
这一部分较为关键,找到对应的launch文件如下:
<launch>
<!-- size of map, change the size in x, y, z according to your application -->
<arg name="map_size_x" value="40.0"/>
<arg name="map_size_y" value="20.0"/>
<arg name="map_size_z" value=" 5.0"/>
<!-- topic of your odometry such as VIO or LIO -->
<arg name="odom_topic" value="/state_ukf/odom" />
<!-- main algorithm params -->
<include file="$(find plan_manage)/launch/kino_algorithm.xml">
<arg name="map_size_x_" value="$(arg map_size_x)"/>
<arg name="map_size_y_" value="$(arg map_size_y)"/>
<arg name="map_size_z_" value="$(arg map_size_z)"/>
<arg name="odometry_topic" value="$(arg odom_topic)"/>
<!-- camera pose: transform of camera frame in the world frame -->
<!-- depth topic: depth image, 640x480 by default -->
<!-- don't set cloud_topic if you already set these ones! -->
<arg name="camera_pose_topic" value="/pcl_render_node/camera_pose"/>
<arg name="depth_topic" value="/pcl_render_node/depth"/>
<!-- topic of point cloud measurement, such as from LIDAR -->
<!-- don't set camera pose and depth, if you already set this one! -->
<arg name="cloud_topic" value="/pcl_render_node/cloud"/>
<!-- intrinsic params of the depth camera -->
<arg name="cx" value="321.04638671875"/>
<arg name="cy" value="243.44969177246094"/>
<arg name="fx" value="387.229248046875"/>
<arg name="fy" value="387.229248046875"/>
<!-- maximum velocity and acceleration the drone will reach -->
<arg name="max_vel" value="3.0" />
<arg name="max_acc" value="2.0" />
<!-- 1: use 2D Nav Goal to select goal -->
<!-- 2: use global waypoints below -->
<arg name="flight_type" value="1" />
<!-- global waypoints -->
<!-- If flight_type is set to 2, the drone will travel these waypoints one by one -->
<arg name="point_num" value="2" />
<arg name="point0_x" value="19.0" />
<arg name="point0_y" value="0.0" />
<arg name="point0_z" value="1.0" />
<!-- set more waypoints if you need -->
<arg name="point1_x" value="-19.0" />
<arg name="point1_y" value="0.0" />
<arg name="point1_z" value="1.0" />
<arg name="point2_x" value="0.0" />
<arg name="point2_y" value="19.0" />
<arg name="point2_z" value="1.0" />
</include>
<!-- trajectory server -->
<node pkg="plan_manage" name="traj_server" type="traj_server" output="screen">
<remap from="/position_cmd" to="planning/pos_cmd"/>
<remap from="/odom_world" to="$(arg odom_topic)&