无人机自动驾驶软件系列 网址
https://gaas.gitbook.io/guide/software-realization-build-your-own-autonomous-drone/wu-ren-ji-zi-dong-jia-shi-xi-lie-offboard-kong-zhi-yi-ji-gazebo-fang-zhen
1、把用户添加到用户组 “dialout”:
$sudo usermod -a -G dialout $USER
然后注销后,重新登录,因为重新登录后所做的改变才会有效。
2、下载相应的软件
$sudo add-apt-repository ppa:george-edison55/cmake-3.x -y
$sudo apt-get update
$sudo apt-get install python-argparse git-core wget zip python-empy qtcreator cmake build-essential genromfs -y
$sudo add-apt-repository ppa:openjdk-r/ppa
$sudo apt-get update
$sudo apt-get install openjdk-8-jre
$sudo apt-get install ant protobuf-compiler libeigen3-dev libopencv-dev openjdk-8-jdk openjdk-8-jre clang-3.5 lldb-3.5 -y
3、卸载模式管理器
$sudo apt-get remove modemmanager
4、更新包列表和安装下面的依赖包
$sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded -y
$sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
$sudo apt-get update
$sudo apt-get install python-serial openocd \
flex bison libncurses5-dev autoconf texinfo build-essential \
libftdi-dev libtool zlib1g-dev \
python-empy gcc-arm-none-eabi -y
5、安装git-daemon-sysvinit;
$sudo apt-get install git-daemon-sysvinit
6、安装git-all;
$ sudo apt-get install git-all
7、安装python-jinja2 ;
$ sudo apt-get install python-jinja2
8、安装lsb-core;
$ sudo apt-get install lsb-core
9、用pip安装numpy和toml
先把pip安装好
方案一、$ sudo apt-get install python-pip
方案二、
$sudo apt-get install python-setuptools python-dev build-essential
$sudo easy_install pip
方案三、
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
10 接着是安装numpy和toml
$sudo pip install numpy toml
10、安装对应版本的编译器
首先下载编译器
https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/7-2017q4/gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2
请依次执行
pushd .
sudo apt-get remove gcc-arm-none-eabi gdb-arm-none-eabi binutils-arm-none-eabi gcc-arm-embedded -y
sudo add-apt-repository --remove ppa:team-gcc-arm-embedded/ppa -y
tar -jxf gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2
sudo mv gcc-arm-none-eabi-7-2017-q4-major /opt
exportline="export PATH=/opt/gcc-arm-none-eabi-7-2017-q4-major/bin:\$PATH"
if grep -Fxq "$exportline" ~/.profile; then echo nothing to do ; else echo $exportline >> ~/.profile; fi
. ~/.profile
popd
arm-none-eabi-gcc --version
查看当前编译器版本
最好重启一下
10、安装GCC5.4.3版本
请依次执行
wget https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2
pushd .
sudo apt-get remove gcc-arm-none-eabi
tar -jxf gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2
sudo mv gcc-arm-none-eabi-5_4-2016q2 /opt
exportline="export PATH=/opt/gcc-arm-none-eabi-5_4-2016q2/bin:\$PATH"
if grep -Fxq "$exportline" ~/.profile; then echo nothing to do ; else echo $exportline >> ~/.profile; fi
. ~/.profile
popd
可以检查arm-none-eabi 5.4是否安装成功,输入以下指令:
arm-none-eabi-gcc --version
11、下载代码
$mkdir -p ~/src
$cd ~/src
$git clone https://github.com/PX4/Firmware.git
//下载最新版本(不提倡)
git clone -b v1.8.0 https://github.com/PX4/Firmware.git
12、代码编译
先进入Firmware文件夹,进而进行初始化、更新子模块操作,耐心的等待……
$cd Firmware
$git submodule update --init --recursive
$cd ~/src/Firmware
$git describe --always --tags
#查看当前px4固件版本
$make
若不是第一次使用make,请使用make clean后重试;
本文来自 FantasyJXF 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/oqqenvy12/article/details/52035127?utm_source=copy
13、Gazebo配置
安装protobuf库,它用作Gazebo的接口。
sudo apt-get install libprotobuf-dev libprotoc-dev protobuf-compiler libeigen3-dev
在仿真文件夹目录顶层创建一个 Build 文件夹
cd ~/src/Firmware/Tools/sitl_gazebo
mkdir Build
14、添加路径
设置插件的路径以便 Gazebo 能找到模型文件
export GAZEBO_PLUGIN_PATH = ${GAZEBO_PLUGIN_PATH}:$HOME/src/Firmware/Tools/sitl_gazebo/Build
设置模型路径以便 Gazebo 能找到机型
export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$HOME/src/Firmware/Tools/sitl_gazebo/models
禁用在线模型查找
export GAZEBO_MODEL_DATABASE_URI=""
#设置 sitl_gazebo 文件夹的路径
export SITL_GAZEBO_PATH=$HOME/src/Firmware/Tools/sitl_gazebo
(14、文字部分格式如有误,请参照图片)
15、切换到构建目录并从中调用CMake
cd Build
cmake ..
make
16、MAVROS仿真
MAVROSROS包允许在运行ROS的计算机、支持MAVLink的飞控板以及支持MAVLink的地面站之间通讯。虽然MAVROS可以用来与任何支持MAVLink的飞控板通讯,但是本文仅就PX4飞行栈与运行ROS的协同计算机之间的通讯予以说明。
sudo apt-get install ros-kinetic-mavros ros-kinetic-mavros-extras ros-kinetic-control-toolbox
切换到固件目录
cd ~/src/Firmware
启动gazebo仿真
make posix_sitl_default gazebo
本文来自 FantasyJXF 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/oqqENvY12/article/details/55263122?utm_source=copy
为了使用所有脚本的功能,请先按照如下安装依赖项:
sudo pip install
pandas
jinja2
pyserial
cerberus
pyulog
numpy
toml
pyquaternion
sudo apt install -y
ninja-build
exiftool
python-argparse
python-empy
python-toml
python-numpy
python-yaml
python-dev
python-pip
ninja-build
protobuf-compiler
libeigen3-dev
genromfs
MAVROS是一层MAVLink与ROS通信的封装,旨在方便无人机与机载电脑通信。若要安装,你可以选择通过apt安装,或者从源码编译。请参考如下步骤:
你可以使用下列任何一种方法
方法 1
sudo apt-get install ros-kinetic-mavros ros-kinetic-mavros-extras
#安装geographic lib :
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
sudo chmod a+x install_geographiclib_datasets.sh
./install_geographiclib_datasets.sh
方法 2
cd ~/catkin_ws
catkin init && wstool init src
rosinstall_generator --rosdistro kinetic mavlink | tee /tmp/mavros.rosinstall
rosinstall_generator --upstream mavros | tee -a /tmp/mavros.rosinstall
wstool merge -t src /tmp/mavros.rosinstall
wstool update -t src -j4
rosdep install --from-paths src --ignore-src -y
#安装geographic lib :
sudo ./src/mavros/mavros/scripts/install_geographiclib_datasets.sh
sudo apt install ros-kinetic-catkin python-catkin-tools
catkin build
若要了解更多关于Mavros信息,请参考如下网址:
https://github.com/mavlink/mavros/blob/master/mavros/README.md#installation
PX4 Firmware
我们会在此课以及接下来的课程中使用 PX4 v1.8.0固件。
cd ~/catkin_ws/src
git clone https://github.com/PX4/Firmware.git
cd Firmware
git checkout v1.8.0
make posix_sitl_default gazebo
若以上步骤通过,此时会弹出Gazebo模拟器窗口,你会看到一架无人机出现在环境中,现在将窗口关闭即可。
修改环境变量,这样每次打开新的终端都可以保持环境变量一致:
sudo gedit ~/.bashrc
#在bashrc中,拷贝以下内容到bashrc尾端
source ~/catkin_ws/devel/setup.bash # 如果通过第一种方式安装了MAVROS,忽略此步。
source ~/catkin_ws/src/Firmware/Tools/setup_gazebo.bash ~/catkin_ws/src/Firmware/ ~/catkin_ws/src/Firmware/build/posix_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/catkin_ws/src/Firmware
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/catkin_ws/src/Firmware/Tools/sitl_gazebo
roslaunch px4 posix_sitl.launch
在另一个终端,输入:
roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557"
或者你可以直接输入:
roslaunch px4 mavros_posix_sitl.launch
roslaunch mavros px4.launch fcu_url:=serial:///dev/ttyUSB0:57600
rostopic list
rostopic echo /mavros/state #查看机载电脑是否与pixhawk连通
真机offboard只需要做的只有三个步骤:
1、配置Pixhawk上的Telema 2 修改SYS_COMPANION参数改成Companion Link(57600)
2、roslaunch mavros px4.launch fcu_url:=serial:///dev/ttyUSB0:57600
运行外部控制例程
3、rosrun offb_ctrl offb_ctrl_node1