整理补充于https://zhuanlan.zhihu.com/p/91329291
本教程将在Ubuntu 16.04上安装ROS Kinetic以及px4 toolchain
由于ROS Kinetic上的gazebo7与px4 toolchain中的gazebo9不兼容,所以安装要特别注意
考虑到可能已经安装过ros, 这里我们选择使用ubuntu_sim_common_deps.sh脚本, 该脚本不会安装gazebo,不然会将ros-kinetic中安装的gazebo7覆盖
step1:
新建脚本一个空的文件ubuntu_sim_common_deps.sh,写入如下代码:
#!/bin/bash
## Bash script for setting up a PX4 development environment on Ubuntu LTS (16.04).
## It can be used for installing simulators (only) or for installing the preconditions for Snapdragon Flight or Raspberry Pi.
##
## Installs:
## - Common dependencies and tools for all targets (including: Ninja build system, Qt Creator, pyulog)
## - FastRTPS and FastCDR
## - jMAVSim simulator dependencies
## - PX4/Firmware source (to ~/src/Firmware/)
# Preventing sudo timeout https://serverfault.com/a/833888
trap "exit" INT TERM; trap "kill 0" EXIT; sudo -v || exit $?; sleep 1; while true; do sleep 60; sudo -nv; done 2>/dev/null &
# Ubuntu Config
echo "We must first remove modemmanager"
sudo apt-get remove modemmanager -y
# Common dependencies
echo "Installing common dependencies"
sudo apt-get update -y
sudo apt-get install git zip qtcreator cmake build-essential genromfs ninja-build exiftool astyle -y
# make sure xxd is installed, dedicated xxd package since Ubuntu 18.04 but was squashed into vim-common before
which xxd || sudo apt install xxd -y || sudo apt-get install vim-common --no-install-recommends -y
# Required python packages
sudo apt-get install python-argparse python-empy python-toml python-numpy python-dev python-pip -y
sudo -H pip install --upgrade pip
sudo -H pip install pandas jinja2 pyserial pyyaml
# optional python tools
sudo -H pip install pyulog
# Install FastRTPS 1.7.1 and FastCDR-1.0.8
fastrtps_dir=$HOME/eProsima_FastRTPS-1.7.1-Linux
echo "Installing FastRTPS to: $fastrtps_dir"
if [ -d "$fastrtps_dir" ]
then
echo " FastRTPS already installed."
else
pushd .
cd ~
wget https://www.eprosima.com/index.php/component/ars/repository/eprosima-fast-dds/eprosima-fast-rtps-1-7-1/eprosima_fastrtps-1-7-1-linux-tar-gz -O eprosima_fastrtps-1-7-1-linux.tar.gz
tar -xzf eprosima_fastrtps-1-7-1-linux.tar.gz eProsima_FastRTPS-1.7.1-Linux/
tar -xzf eprosima_fastrtps-1-7-1-linux.tar.gz requiredcomponents
tar -xzf requiredcomponents/eProsima_FastCDR-1.0.8-Linux.tar.gz
cpucores=$(( $(lscpu | grep Core.*per.*socket | awk -F: '{print $2}') * $(lscpu | grep Socket\(s\) | awk -F: '{print $2}') ))
(cd eProsima_FastCDR-1.0.8-Linux && ./configure --libdir=/usr/lib && make -j$cpucores && sudo make install)
(cd eProsima_FastRTPS-1.7.1-Linux && ./configure --libdir=/usr/lib && make -j$cpucores && sudo make install)
rm -rf requiredcomponents eprosima_fastrtps-1-7-1-linux.tar.gz
popd
fi
# jMAVSim simulator dependencies
echo "Installing jMAVSim simulator dependencies"
sudo apt-get install ant openjdk-8-jdk openjdk-8-jre -y
为脚本添加权限:
sudo chmod +x ubuntu_sim_common_deps.sh
step2:
打开一个新的terminal,执行
sudo usermod -a -G dialout $USER
执行完之后重启一下, 官方说的是Logout and login again 使得操作生效
step3:
在刚刚建立ubuntu_sim_common_deps.sh的目录下,执行
source ubuntu_sim_common_deps.sh
等待安装…
terminal中出现done
表示安装完成
2.编译px4_Firmware
编译px4 /Firmware, 这里安装1.10版本
mkdir PX4
cd PX4
git clone https://github.com/PX4/Firmware.git
cd Firmware
git checkout v1.10.0
# 若这步很慢看后面的解决方案
git submodule update --init --recursive
make px4_sitl jmavsim
# gazebo
# make px4_sitl gazebo
3.安装ros(如果安装过ros请忽略)
https://www.cnblogs.com/liu-fa/p/5779206.html
4.mavros and mavlink 安装
在terminal中执行
sudo apt-get install ros-kinetic-mavros ros-kinetic-mavros-extras
安装完成后,执行
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
chmod +x install_geographiclib_datasets.sh
./install_geographiclib_datasets.sh
完毕后,执行
roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557"
如果不报错,证明ok了
网址变更了
https://blog.csdn.net/Qevery678/article/details/94391782?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param
新网址为
https://www.eprosima.com/index.php/component/ars/repository/eprosima-fast-dds/eprosima-fast-rtps-1-7-1/eprosima_fastrtps-1-7-1-linux-tar-gz
运行上面的.sh
应该就行,还是有问题的话自行重新输入新地址就好
zsh不兼容的坑-zsh:no matches found
https://blog.csdn.net/u012675539/article/details/52079013
步骤如下:
cd Firmware
gedit .gitmodules
然后把下面这个内容替换原来的 .gitmodules
文件:
[submodule "mavlink/include/mavlink/v2.0"]
path = mavlink/include/mavlink/v2.0
url = https://gitee.com/jianhengLiu/c_library_v2.git
branch = master
[submodule "src/drivers/uavcan/libuavcan"]
path = src/drivers/uavcan/libuavcan
url = https://gitee.com/jianhengLiu/uavcan.git
branch = px4
[submodule "msg/tools/genmsg"]
path = msg/tools/genmsg
url = https://gitee.com/jianhengLiu/genmsg.git
branch = px4
[submodule "msg/tools/gencpp"]
path = msg/tools/gencpp
url = https://gitee.com/jianhengLiu/gencpp.git
branch = px4
[submodule "Tools/jMAVSim"]
path = Tools/jMAVSim
url = https://gitee.com/zhuleilei33/jMAVSim.git
branch = master
[submodule "Tools/sitl_gazebo"]
path = Tools/sitl_gazebo
url = https://gitee.com/zhuleilei33/sitl_gazebo.git
branch = master
[submodule "src/lib/matrix"]
path = src/lib/matrix
url = https://gitee.com/jianhengLiu/Matrix.git
branch = master
[submodule "src/lib/DriverFramework"]
path = src/lib/DriverFramework
url = https://gitee.com/jianhengLiu/DriverFramework.git
branch = master
[submodule "src/lib/ecl"]
path = src/lib/ecl
url = https://gitee.com/jianhengLiu/ecl.git
branch = Release_v1.10
[submodule "boards/atlflight/cmake_hexagon"]
path = boards/atlflight/cmake_hexagon
url = https://gitee.com/jianhengLiu/cmake_hexagon.git
branch = px4
[submodule "src/drivers/gps/devices"]
path = src/drivers/gps/devices
url = https://gitee.com/jianhengLiu/GpsDrivers.git
branch = master
[submodule "src/modules/micrortps_bridge/micro-CDR"]
path = src/modules/micrortps_bridge/micro-CDR
url = https://gitee.com/jianhengLiu/micro-CDR.git
branch = px4
[submodule "platforms/nuttx/NuttX/nuttx"]
path = platforms/nuttx/NuttX/nuttx
url = https://gitee.com/jianhengLiu/NuttX.git
branch = px4_firmware_nuttx-7.29+
[submodule "platforms/nuttx/NuttX/apps"]
path = platforms/nuttx/NuttX/apps
url = https://gitee.com/jianhengLiu/NuttX-apps.git
branch = px4_firmware_nuttx-7.29+
[submodule "cmake/configs/uavcan_board_ident"]
path = cmake/configs/uavcan_board_ident
url = https://gitee.com/jianhengLiu/uavcan_board_ident.git
branch = master
如果发生了报错自行将.gitmodules
的url对应github上的库替换成gitee的
若发现改为之后速度没有变化,可能是因为更改前已经执行了git submodule update --init --recursive
则需重新clone或者其他方法,重新注册一遍
第一次执行指令应该出现类似以下输出
Submodule 'Tools/jMAVSim' (https://gitee.com/zhuleilei33/jMAVSim.git) registered for path 'Tools/jMAVSim'
Submodule 'Tools/sitl_gazebo' (https://gitee.com/zhuleilei33/sitl_gazebo.git) registered for path 'Tools/sitl_gazebo'
Submodule 'boards/atlflight/cmake_hexagon' (https://gitee.com/jianhengLiu/cmake_hexagon.git) registered for path 'boards/atlflight/cmake_hexagon'
Submodule 'cmake/configs/uavcan_board_ident' (https://gitee.com/jianhengLiu/uavcan_board_ident.git) registered for path 'cmake/configs/uavcan_board_ident'
Submodule 'mavlink/include/mavlink/v2.0' (https://gitee.com/jianhengLiu/c_library_v2.git) registered for path 'mavlink/include/mavlink/v2.0'
Submodule 'msg/tools/gencpp' (https://gitee.com/jianhengLiu/gencpp.git) registered for path 'msg/tools/gencpp'
Submodule 'msg/tools/genmsg' (https://gitee.com/jianhengLiu/genmsg.git) registered for path 'msg/tools/genmsg'
Submodule 'platforms/nuttx/NuttX/apps' (https://gitee.com/jianhengLiu/NuttX-apps.git) registered for path 'platforms/nuttx/NuttX/apps'
Submodule 'platforms/nuttx/NuttX/nuttx' (https://gitee.com/jianhengLiu/NuttX.git) registered for path 'platforms/nuttx/NuttX/nuttx'
Submodule 'src/drivers/gps/devices' (https://gitee.com/jianhengLiu/GpsDrivers.git) registered for path 'src/drivers/gps/devices'
Submodule 'src/drivers/uavcan/libuavcan' (https://gitee.com/jianhengLiu/uavcan.git) registered for path 'src/drivers/uavcan/libuavcan'
Submodule 'src/lib/DriverFramework' (https://gitee.com/jianhengLiu/DriverFramework.git) registered for path 'src/lib/DriverFramework'
Submodule 'src/lib/ecl' (https://gitee.com/jianhengLiu/ecl.git) registered for path 'src/lib/ecl'
Submodule 'src/lib/matrix' (https://gitee.com/jianhengLiu/Matrix.git) registered for path 'src/lib/matrix'
Submodule 'src/modules/micrortps_bridge/micro-CDR' (https://gitee.com/jianhengLiu/micro-CDR.git) registered for path 'src/modules/micrortps_bridge/micro-CDR'
报错如下
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GSTREAMER_LIBRARIES (ADVANCED)
解决办法
sudo apt-get install libgstreamer-plugins-base1.0-dev