安装全过程建议科学上网,安装体验更佳。
系统环境,建议用Ubuntu18.04。
安装px4 的 offboard 模式下的二次开发环境
准备工作:
(1)更改源
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
sudo nano /etc/apt/sources.list
然后将下面代码复制到新建的sources.list文件中
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
(2)设置github 地址格式
解决方案:
git config --global url."git://".insteadOf https://
或者
git config --global url."git://".insteadOf http://
1.创建文件夹
首先我现在我的虚拟机ubuntu中在根目录下创建PX4文件夹
然后给文件夹权限
sudo chmod -R 777 /PX4
2.然后下载ubuntu.sh和requirements.txt
wget https://raw.githubusercontent.com/PX4/Firmware/master/Tools/setup/ubuntu.sh
wget https://raw.githubusercontent.com/PX4/Firmware/master/Tools/setup/requirements.txt
这两个文件使官方推荐的安装脚本文件。
3.执行脚本进行安装
sudo chmod 777 ./ubuntu.sh
./ubuntu.sh
遇到错误
解决方案
sudo apt install libjpeg-dev zlib1g-dev
4.下载px4源码
git clone git://github.com/PX4/Firmware.git
进入到刚下载好的 Firmware 目录下
运行命令
git init
git submodule update --init --recursive
5.gazebo仿真
make -j2 px4_sitl gazebo_iris
编译完后会自行启动
不小心关闭了,可以在命令行输入
gazebo
重新打开。
6.mavros的安装
安装仿真依赖项
wget https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim_common_deps.sh
将下载下来的 .sh 脚本文件给与可执行的权限
sudo chmod +x ubuntu_sim_common_deps.sh
然后执行安装脚本
./ubuntu_sim_common_deps.sh
这一步,我并未遇到问题,其中一篇参考文献遇到了问题。
然后安装ROS+Gazebo
(1)添加下载源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
(2)设置密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
(3)再运行
curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add -
(4)更新源
sudo apt-get update
(5)安装ros
sudo apt install ros-melodic-desktop-full -y
(6)环境配置
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
(7)安装rosdep
sudo apt install rospack-tools
(8)初始化代码
sudo rosdep init
提示:
(9)根据提示,执行update
rosdep update
遇到的问题:
解决方案:
wget -qO - https://raw.fastgit.org/my-rds-store/my_space/master/source/ros/shell/rosdep_repair.sh | bash
(10)设置环境变量
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
(11)安装完成
(11)安装其他环境
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential -y
参考文献
[1] [Pixhawk/PX4]开发环境搭建(Ubuntu 18.04) - SharkU - 博客园
[2] [PX4]mavros安装+offboard控制过程记录 - SharkU - 博客园