安装及编译
Yuhua.Qi edited this page on Jun 30, 2021 · 20 revisions
Pages 56
Clone this wiki locally
安装及编译
操作系统及硬件平台要求
操作系统:Ubuntu 18.04 Ubuntu 18.04 镜像下载
注:理论来说,Prometheus项目也支持其他ubuntu版本。 注:如果需要使用视觉检测模块,建议使用ubuntu18.04,否则会遇到opencv版本问题(需自行解决)。
根据使用场景选择硬件平台:
- 软件在环仿真测试
- 在笔记本或台式机中进行配置!!!(不能在树莓派、TX2、NX等机载电脑中配置仿真环境!!!)
- 启动盘制作及双系统安装教程
- Gazebo仿真对CPU要求较高(对GPU和内存要求较低),注意:不建议使用虚拟机
- 执行完本文档后,请查阅仿真飞行配置
- 机载飞行测试(经验不足的开发者请先进行本地仿真测试)
- 在机载电脑中进行配置!!!
- 机载设备推荐:Nvidia TX2, Nvidia Nano, INTEL NUC
- 根据预算及实验需求综合选择
- 执行完本文档后,请查阅机载飞行配置(此部分暂时不开源)
特别注意:双系统镜像和Docker均不是最推荐的安装方式!安装及仿真环境配置虽然对于新手有一些繁琐,但一定是最合理的开发方式,同时也是学习的过程。
依赖项安装
必备依赖项安装
-
安装ROS,安装教程:ROS: Home
-
ROS安装的最后一步rosdep一定要安装正确,不然仿真中没法spawn模型
-
通过二进制的方法安装Mavros功能包(如果你已经使用源码的方式安装过Mavros功能包,请先将其删除),安装教程: https://github.com/mavlink/mavros
安装Mavros包
sudo apt-get install ros-melodic-mavros ros-melodic-mavros-extras
安装GeographicLib(这一步如果一直下载不下来请翻墙或切换手机热点多次尝试,请耐心等待,这一步就是比较慢)
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
sudo ./install_geographiclib_datasets.sh
建图模块依赖项安装
激光SLAM依赖项安装
视觉检测依赖项安装
如果需要运行数字识别
、SiamRPN跟踪
,需要安装PyTorch
。
目前ROS仅支持python2,所以确保你的CUDA版本为10.1或9.2
# 首先查看CUDA版本
nvidia-smi
# CUDA 10.1
pip2 install torch==1.4.0 torchvision==0.5.0
# CUDA 9.2
pip2 install torch==1.4.0+cu92 torchvision==0.5.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html
# CPU only,如果没有Nvidia显卡,则安装CPU版本(影响检测性能)
pip2 install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
规划模块依赖项安装
Prometheus项目下载
-
下载项目代码,使用crtl+alt+T
打开一个新的终端
git clone https://github.com/amov-lab/Prometheus
也可以使用国内Gitee源(我们会定期搬运更新!)
git clone https://gitee.com/amovlab/Prometheus.git
-
环境变量配置,打开一个新终端,输入gedit .bashrc
并回车,在打开的bashrc.txt
文件中添加 source /home/$(your computer name)/Prometheus/devel/setup.bash
,或者使用如下命令(需编译后才会出现该文件!)
echo "source (Path To Prometheus)/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
Prometheus项目编译
代码概览
代码框架
代码目录 | 功能 |
---|
Modules | 各模块功能的源代码 |
Simulator | 仿真飞行相关代码 |
Experiment | 真实飞行相关代码 |
Modules介绍
模块 | 目录 | 功能 |
---|
控制模块 | Modules/control | 底层控制 |
规划模块 | Modules/planning | 路径规划 |
SLAM模块 | Modules/slam | 定位与建图 |
目标检测模块 | Modules/object_detection | 目标识别与检测 |
地面站模块 | Modules/ground_station | 地面监控与消息打印 |
任务模块 | Modules/mission | 上层任务 |
公用模块 | Modules/common | 各模块公用代码 |
自定义消息模块 | Modules/common/msgs | 本项目自定义消息 |
仿真环境配置
Yuhua.Qi edited this page on Oct 20, 2021 · 8 revisions
Pages 56
Clone this wiki locally
仿真飞行配置
目前仅提供Gazebo仿真配置教程
十分重要:不能在树莓派、TX2、NX等机载电脑中配置仿真环境!!!
PX4编译环境及固件代码安装
执行完本文件后,可参考项目概览及功能说明进行仿真测试!
PX4编译环境配置及固件代码安装
Prometheus项目中的Gazebo仿真模块依赖PX4固件及sitl_gazebo包,因此需先配置PX4编译环境
-
下载PX4固件代码,此处请使用阿木实验室的Prometheus项目专用的PX4仓库:prometheus_px4,安装方法如下
git clone https://gitee.com/amovlab/prometheus_px4.git
cd prometheus_px4
git submodule update --init --recursive
pip3 install --user toml empy jinja2 packaging
make amovlab_sitl_default gazebo
-
PX4编译环境安装(第一次安装PX4环境需要运行)
cd prometheus_px4/Tools/setup
## 请在运行此脚本时注意终端的打印信息,保证每一项均顺利安装
## 这一步问题最多,一定仔细检查是否正确安装!!!
## 若有某一项失败或一直卡住,请重新运行即可!
source ./ubuntu.sh
-
不需要进行分支切换,直接使用主分支Prometheus_PX4_1.11.1
说明:
-
对于之前使用Firmware_v110的开发者,请直接删除Firmware_v110整个文件夹,然后按照上述流程安装(可不执行PX4编译环境安装)
-
如果在更新子模块时遇到问题,可尝试先make_distclean,再git submodule update --init --recursive
-
在安装PX4编译环境时,比较常遇到的问题就是arm-none-eabi-gcc安装失败或者版本不对,请注意以下几点
-
版本问题:一定使用prometheus_px4/Tools/setup目录下的ubuntu.sh进行安装,如果使用PX4官方master分支下的对应文件则会安装高级版本的arm-none-eabi-gcc,会使得编译prometheus_px4出错
-
可以通过如下指令查看arm-none-eabi-gcc版本
$arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204]
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
prometheus_px4对应的版本是gcc version 9-2020-q2-update(其他版本gcc可能也支持,只要能顺利编译固件即可),如果之前已经安装过最新的arm-none-eabi-gcc,请重新运行ubuntu.sh文件后,重启电脑。
-
安装失败:一般是由于网络原因导致,在运行ubuntu.sh文件时,请耐心查看安装记录,下载arm-none-eabi-gcc有时会因为网络原因而自动放弃下载,此时,也只需要反复运行ubuntu.sh文件直至安装成功。
-
PX4环境配置可参考PX4手册 - getting_started,请选择1.11分支。
-
建议同时安装PX4官方仓库和本仓库,如果官方仓库能正常编译,而本仓库不行,可提问。否则请先解决官方仓库编译问题
-
若使用官方PX4仓库,Prometheus部分功能会失效,需要修改后方能使用(暂无详细说明,需自行解决)
-
此处安装成功的标志为:PX4固件能够编译,并能运行其自带的Gazebo仿真,即运行make px4_sitl gazebo
能够正常运行Gazebo仿真
-
**此处安装及编译出现任何问题,请前往PX4 Firmware的issue区寻找答案(但大部分情况是没有问题,请保证PX4环境配置正确)**或者前往本仓库的issue区提问,网址:Issues · AMOVLAB/Prometheus_PX4 - Gitee.com
-
对PX4固件代码进行任何修改或者执行过git pull
都需要重新运行make px4_sitl gazebo
相关链接:
- PX4 Github主页:PX4 Github (代码有分支,请查看v1.10.0分支)
- PX4开发者手册:PX4手册 v1.11 (手册有分支,请查看v1.11.0分支)
- PX4官方仿真教程 : PX4手册 - gazebo simulation
报错解决:
- 缺少gstreamer:
sudo apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
环境变量配置
-
打开终端,并输入如下指令打开bashrc
文件
sudo gedit ~/.bashrc
-
在打开的文件中手动添加如下指令(以下若存在已添加过的命令,请勿重复添加),其中${your prometheus path}
为Prometheus项目路径,${your px4 path}
为安装PX4固件的路径。
source ${your prometheus path}/Prometheus/devel/setup.bash
export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:${your prometheus path}/Prometheus/devel/lib
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${your prometheus path}/Prometheus/Simulator/gazebo_simulator/models
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${your prometheus path}/Prometheus/Simulator/gazebo_simulator/amov_models
source ${your px4 path}/prometheus_px4/Tools/setup_gazebo.bash ${your px4 path}/prometheus_px4 ${your px4 path}/prometheus_px4/build/amovlab_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:${your px4 path}/prometheus_px4
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:${your px4 path}/prometheus_px4/Tools/sitl_gazebo
备注:
- 添加以上环境变量后,每次打开终端会出现配置好的路径,忽略即可。
- 此步骤经常容易出错,请再三检查。(每一个路径都是有实际含义,请确保电脑中有该路径存在)
仿真用插件安装
-
安装3Dlidar插件
sudo apt-get install ros-melodic-velodyne-gazebo-plugins
-
安装octomap在rviz中的插件
sudo apt-get install ros-melodic-octomap-rviz-plugins
-
安装Turtlebot3 仿真插件
sudo apt-get install ros-melodic-turtlebot3-*
Gazebo模型库下载
为了获得更多的Gazebo模型文件,则必须下载完整的模型文件
cd ~/.gazebo/
## 如果之前没有models文件夹的话,创建models文件夹
mkdir -p models
cd ~/.gazebo/models/
## 这个仓库是从官方仓库(https://github.com/osrf/gazebo_models)复制过来的,会定期更新
git clone https://gitee.com/potato77/gazebo_models
说明:此处的models文件与本项目中自带的models互为补充关系
Prometheus仿真功能包编译
请确保Prometheus项目中其他相应的功能包均已编译通过,然后编译prometheus_gazebo功能包
cd Prometheus
./compile_gazebo.sh
Gazebo仿真运行测试
运行如下命令测试是否Gazebo仿真是否正确配置
roslaunch prometheus_gazebo sitl.launch
此时,第一个终端同时运行了PX4仿真、Mavros、px4_pos_estimator、px4_pos_controller四个节点,第二个终端则运行了ground_station节点。因此,若第一个终端无报错,第二个终端显示[Connected]
并能够查看到飞机状态,且Gazebo成功运行,代表成功运行。
在Gazebo仿真环境中,根据仿真目的不同提供以下方式控制无人机飞行:
注:因为版本更新,以下图片和目前版本有些许出入
1.终端控制(全自主的offboard控制,推荐!)
运行如下指令启动终端控制节点,并根据终端提示输入指令
rosrun prometheus_control terminal_control
运行之后需要选择使用command input control(通过输入目标点的方式控制) 或者keyboard input control(通过键盘控制)两种方式
Promehteus仿真功能
onexming edited this page on Feb 17 · 7 revisions
Pages 56
Clone this wiki locally
Prometheus仿真功能
所有Gazebo仿真功能启动文件均位于prometheus_gazebo功能包中,但是所有核心模块(如控制、检测、规划等)代码均在各自功能包中。
PX4-Gazebo仿真说明
Prometheus仿真功能启动脚本一览
备注:
- 未提及到的launch文件功能正在开发中,可能无法稳定运行
- 开发建议:阅读gazebo文件及其所指向的源文件(大部分代码都有注释)!
- 大部分参数在launch文件中可直接修改,部分参数需要修改对应的config文件
launch_basic文件夹(基本或通用的launch文件)
## 最基本的仿真启动文件,大部分功能均依赖此launch文件
## 必须成功运行,基本所有功能都会调用该文件
roslaunch prometheus_gazebo sitl.launch
launch_control文件夹(控制相关,如位置环控制)
## 使用px4_sender对飞机进行控制测试(建议熟练使用),上手难度:★
roslaunch prometheus_gazebo sitl_control.launch
## 使用px4_pos_controller对飞机进行控制测试,上手难度:★★
roslaunch prometheus_gazebo sitl_pos_control.launch
## 航点追踪脚本,上手难度:★
roslaunch prometheus_gazebo sitl_waypoint_tracking.launch
launch_detection文件夹(目标检测相关,如自主降落等)
## 自主降落(静止目标),上手难度:★
roslaunch prometheus_gazebo sitl_landing_static_target.launch
## 自主降落(移动目标),上手难度:★★
roslaunch prometheus_gazebo sitl_landing_moving_target.launch
## 若要使小车移动,需在飞机起飞后运行以下指令
rosrun prometheus_gazebo move_landing_pad.py
## 数字识别,上手难度:★
roslaunch prometheus_gazebo sitl_number_detection.launch
## 颜色识别并依据颜色巡线,上手难度:★
roslaunch prometheus_gazebo sitl_color_line_following.launch
## 圆形识别与圆形穿越,上手难度:★
roslaunch prometheus_gazebo sitl_circle_crossing.launch
## KCF框选追踪,上手难度:★★
roslaunch prometheus_gazebo sitl_kcf_detection.launch
## Aruco码检测,上手难度:★
roslaunch prometheus_gazebo sitl_aruco_detection.launch
## PX4云台相关仿真,上手难度:★★
## 与其他仿真不同,云台相关仿真使用typhoon_h480模型
## 云台基本控制测试
roslaunch prometheus_gazebo sitl_gimbal_control.launch
## 云台速度控制测试(如果无法运行请到 https://mp.weixin.qq.com/s/S_kiOZV9NfJWZluiJlAsxg 进行升级)
roslaunch prometheus_gazebo sitl_gimbal_control_vel.launch
## 云台示例程序1:刷锅
roslaunch prometheus_gazebo sitl_gimbal_circle.launch
## 云台示例程序2:目标追踪(无视觉信息反馈,使用目标真值进行控制)
roslaunch prometheus_gazebo sitl_gimbal_tracking_no_vision.launch
## 云台示例程序3:目标追踪(有视觉信息反馈,使用目标真值进行控制)
roslaunch prometheus_gazebo sitl_gimbal_tracking.launch
launch_planning文件夹(规划相关)
## 局部规划-APF方法,上手难度:★★
## APF方法使用2d激光雷达
roslaunch prometheus_gazebo sitl_apf_2dlidar.launch
## APF方法使用rgbd相机(有些小问题,正在解决中)
roslaunch prometheus_gazebo sitl_apf_rgbd.launch
## 局部规划 - VFH方法(有bug,不推荐使用),上手难度:★★
## VFH方法使用2d激光雷达
roslaunch prometheus_gazebo sitl_vfh_2dlidar.launch
## 全局规划 - Astar方法,上手难度:★★
## Astar方法使用3d激光雷达
roslaunch prometheus_gazebo sitl_astar_3dlidar.launch
## Astar方法使用2d激光雷达(建议,比较贴合实际)
roslaunch prometheus_gazebo sitl_astar_2dlidar.launch
## Astar方法使用rgbd相机(有些小问题,正在解决中)
roslaunch prometheus_gazebo sitl_astar_rgbd.launch
## 全局规划 - 混合Astar方法,上手难度:★★
## 混合Astar方法使用3d激光雷达
roslaunch prometheus_gazebo sitl_astar_3Dlidar.launch
## 混合Astar方法使用2d激光雷达(建议,比较贴合实际)
roslaunch prometheus_gazebo sitl_astar_hokuyo.launch
## 轨迹规划 - fastplanner - 待更新
launch_swarm文件夹(集群控制相关)
sudo apt install xmlstarlet
## 多无人机编队飞行(可实现切换阵型,编队飞行等),上手难度:★★
roslaunch prometheus_gazebo sitl_swarm_4uav.launch
roslaunch prometheus_gazebo sitl_swarm_8uav.launch
## 编队+APF避障(测试中,可以运行)
roslaunch prometheus_gazebo sitl_swarm_4uav_vel.launch
## 多无人机无人车混合编队飞行(需要安装turtlebot功能包),上手难度:★★
## 注:该功能处于开发测试阶段,目前仅可以实现简单移动(无人车与无人机无信息交互)
roslaunch prometheus_gazebo sitl_swarm_4uav_4ugv.launch
launch_ego_planner文件夹(测试阶段!)
cd Prometheus
## 编译
./compile_ego.sh
## 运行
./ego_test.sh
launch_slam文件夹
## cartographer slam(需要安装cartographer 功能包),上手难度:★★
roslaunch prometheus_gazebo sitl_cartorgrapher_rplidar.launch
## octomap建图,上手难度:★★
roslaunch prometheus_gazebo sitl_octomap.launch
## rtabmap建图,上手难度:★★
roslaunch prometheus_gazebo sitl_rtabmap.launch
prometheus_gazebo功能包说明
目录 | 功能 |
---|
gazebo_simulator/amov_models | 特定模型文件 |
gazebo_simulator/models | 通用模型文件 |
gazebo_simulator/worlds | 地图文件 |
gazebo_simulator/cpp_nodes | 辅助的cpp节点 |
gazebo_simulator/py_nodes | 辅助的python节点 |
gazebo_simulator/launch_xxxx | 各类启动文件 |
gazebo_simulator/config | 仿真相关的配置文件 |
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)