简单来说,Distrobox简化了打指令建立容器的过程,只要几行指令,便可快速建立特定Linux发行版的容器,存取该发行版的套件管理员。用Distrobox建立Linux容器的话较易於管理、备份、升级;另一方面,Distrobox建立的容器预设可以存取/home目录、USB列表等基本配置信息,在此基础上实现了文件的统一化管理与各类系统环境的隔离。(本文的写作缘由是发现基于gazebo的ardupilot开发环境配置完成后再进行PX4环境配置会出现CMake报错且没有明确的错误解决方案)
安装方法:
1、二进制安装(快速方便,适合大多数系统—要提前安装docker)
# Debian/Ubuntu
sudo apt install distrobox
# Fedora
sudo dnf install distrobox
# Arch/Manjaro
sudo pacman -S distrobox
# openSUSE
sudo zypper install distrobox
2、无系统安装权限(如steamOS)
先安装podman
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/extras/install-podman | sh -s -- --prefix ~/.local
再安装distrobox
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sh -s -- --next --prefix ~/.local
在.bashrc中加入以下内容
# Podman和Distrobox的路徑
PATH=$PATH:$HOME/.local/podman/bin:$HOME/.local/bin
# 允許所有應用程式顯示在螢幕上(需安裝xhost)
xhost +si:localuser:$USER
快速开始(在此使用ubuntu20.04为例,更多命令请查看学习官方仓库):
1、添加开发版
distrobox create -i ubuntu:20.04
2、进入开发版
distrobox enter ubuntu-20-04
随后可以看到如下内容:
ubuntu@ubuntu-ThinkPad-E15-Gen-3:~$ distrobox enter ubuntu-20-04
ubuntu@ubuntu-20-04:~$
官方仓库:/89luca89/distrobox
至此,ubuntu20.04虚拟机配置完成,下面进行PX4的开发环境配置
[ROS的安装(鱼香ROS)]
wget http://fishros.com/install -O fishros && . fishros
参考文档:www.fishros.com
[QGC的安装(官网)]
sudo usermod -a -G dialout $USER
sudo apt-get remove modemmanager -y
sudo apt install gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-gl -y
sudo apt install libqt5gui5 -y
sudo apt install libfuse2 -y
wget https://d176tv9ibo4jno.cloudfront.net/latest/QGroundControl.AppImage
sudo chmod 777 QGroundControl.AppImage
./QGroundControl.AppImage
参考文档:Download and Install · QGroundControl User Guide
[MAVROS安装配置]
sudo apt-get update
sudo apt-get install python3 python3-pip ros-noetic-mavros* -y
cd /opt/ros/noetic/lib/mavros
sudo ./install_geographiclib_datasets.sh
[PX4的安装配置]
mkdir -p ${HOME}/repos && cd ${HOME}/repos
git clone https://github.com/PX4/PX4-Autopilot.git -b v1.13.0 --recursive
cd PX4-Autopilot
bash ./Tools/setup/ubuntu.sh
重启电脑
cd ${HOME}/repos/PX4-Autopilot
DONT_RUN=1 make px4_sitl_default gazebo
source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/sitl_gazebo
运行仿真
roslaunch px4 mavros_posix_sitl.launch
[LibRealsense安装配置(带T265,可选]
git clone https://github.com/IntelRealSense/librealsense -b v2.53.1 --recursive
sudo apt-get install libssl-dev libusb-1.0-0-dev libudev-dev pkg-config libgtk-3-dev cmake -y
sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev at -y
cd librealsense
mkdir build && cd build
cmake ../
sudo make uninstall && make clean && make -j8
sudo make install
cd ..
./scripts/setup_udev_rules.sh