【XTDrone Ubuntu18.04】XTDrone + Ubuntu18.04 + PX4 安装过程

重新配置所有的软件
卸载之前安装的ROS GAZEBO
记得把/home下的.ros和.gazebo也删除,删就删干净
参考链接:ROS的卸载与安装 血泪总结!亲测有效
卸载ROS方法

正式安装
安装依赖

sudo apt install ninja-build exiftool ninja-build protobuf-compiler libeigen3-dev genromfs xmlstarlet libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev python-pip python3-pip gawk -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip2 install pandas jinja2 pyserial cerberus pyulog==0.7.0 numpy toml pyquaternion empy pyyaml -i https://pypi.tuna.tsinghua.edu.cn/simple/

pip3 install packaging numpy empy toml pyyaml jinja2 pyargparse -i https://pypi.tuna.tsinghua.edu.cn/simple/

国内源地址

https://pypi.tuna.tsinghua.edu.cn/simple/

http://mirrors.aliyun.com/pypi/simple/

http://pypi.mirrors.ustc.edu.cn/simple/

https://repo.huaweicloud.com/repository/pypi/simple/

ROS安装

参考链接:ubuntu 18.04 三五分钟即可一键安装ROS系统(亲测有效)
再次安装出现依赖混乱的问题:
apt-get purge package-name

sudo apt-get purge ninja-build exiftool ninja-build protobuf-compiler libeigen3-dev genromfs xmlstarlet libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev python-pip python3-pip gawk
下列软件包是自动安装的并且现在不需要了:
  default-libmysqlclient-dev dh-python freeglut3 freeglut3-dev gdal-data
  gir1.2-harfbuzz-0.0 google-mock googletest hdf5-helpers ibverbs-providers
  icu-devtools libaec-dev libaec0 libapr1 libapr1-dev libaprutil1
  libaprutil1-dev libarmadillo-dev libarmadillo8 libarpack2 libarpack2-dev
  libassuan-dev libavcodec-dev libavdevice-dev libavdevice57 libavfilter-dev
  libavformat-dev libavresample-dev libavutil-dev libblas-dev libblas3
  libboost-all-dev libboost-atomic-dev libboost-atomic1.65-dev
  libboost-atomic1.65.1 libboost-chrono-dev libboost-chrono1.65-dev
  libboost-chrono1.65.1 libboost-container-dev libboost-container1.65-dev
  libboost-container1.65.1 libboost-context-dev libboost-context1.65-dev
  libboost-context1.65.1 libboost-coroutine-dev libboost-coroutine1.65-dev
  libboost-coroutine1.65.1 libboost-date-time-dev libboost-date-time1.65-dev
  libboost-dev libboost-exception-dev libboost-exception1.65-dev
  libboost-fiber-dev libboost-fiber1.65-dev libboost-fiber1.65.1
  libboost-filesystem-dev libboost-filesystem1.65-dev libboost-graph-dev
  libboost-graph-parallel-dev libboost-graph-parallel1.65-dev
  libboost-graph-parallel1.65.1 libboost-graph1.65-dev libboost-graph1.65.1
  libboost-iostreams-dev libboost-iostreams1.65-dev libboost-locale-dev
  libboost-locale1.65-dev libboost-log-dev libboost-log1.65-dev
  libboost-log1.65.1 libboost-math-dev libboost-math1.65-dev
  libboost-math1.65.1 libboost-mpi-dev libboost-mpi-python-dev
  libboost-mpi-python1.65-dev libboost-mpi-python1.65.1 libboost-mpi1.65-dev
  libboost-mpi1.65.1 libboost-numpy-dev libboost-numpy1.65-dev
  libboost-numpy1.65.1 libboost-program-options-dev
  libboost-program-options1.65-dev libboost-program-options1.65.1
  libboost-python-dev libboost-python1.65-dev libboost-python1.65.1
  libboost-random-dev libboost-random1.65-dev libboost-random1.65.1
  libboost-regex-dev libboost-regex1.65-dev libboost-regex1.65.1
  libboost-serialization-dev libboost-serialization1.65-dev
  libboost-serialization1.65.1 libboost-signals-dev libboost-signals1.65-dev
  libboost-signals1.65.1 libboost-stacktrace-dev libboost-stacktrace1.65-dev
  libboost-stacktrace1.65.1 libboost-system-dev libboost-system1.65-dev
  libboost-test-dev libboost-test1.65-dev libboost-test1.65.1
  libboost-thread-dev libboost-thread1.65-dev libboost-timer-dev
  libboost-timer1.65-dev libboost-timer1.65.1 libboost-tools-dev
  libboost-type-erasure-dev libboost-type-erasure1.65-dev
  libboost-type-erasure1.65.1 libboost-wave-dev libboost-wave1.65-dev
  libboost-wave1.65.1 libboost1.65-dev libboost1.65-tools-dev libbullet-dev
  libbullet2.87 libbz2-dev libconsole-bridge-dev libconsole-bridge0.4
  libcurl4-openssl-dev libdap-dev libdap25 libdapclient6v5 libdapserver7v5
  libdrm-dev libegl1-mesa-dev libepsilon-dev libepsilon1 libexpat1-dev
  libfabric1 libfreeimage-dev libfreeimage3 libfreexl-dev libfreexl1
  libfyba-dev libfyba0 libgdal-dev libgdal20 libgeos-3.6.2 libgeos-c1v5
  libgeos-dev libgeotiff-dev libgeotiff2 libgfortran4 libgif-dev libgif7
  libgl1-mesa-dev libgles1 libgles2-mesa-dev libglib2.0-dev libglib2.0-dev-bin
  libglu1-mesa-dev libglvnd-core-dev libglvnd-dev libgpg-error-dev
  libgpgme-dev libgraphite2-dev libgtest-dev libgts-dev libharfbuzz-dev
  libharfbuzz-gobject0 libhdf4-0-alt libhdf4-alt-dev libhdf5-100
  libhdf5-cpp-100 libhdf5-dev libhwloc-dev libhwloc-plugins libhwloc5
  libibverbs-dev libibverbs1 libice-dev libicu-dev libicu-le-hb-dev
  libicu-le-hb0 libiculx60 libignition-common libignition-fuel-tools1-1
  libignition-math4 libignition-msgs libignition-transport4 libjbig-dev
  libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev libjson-c-dev libjsoncpp-dev
  libjxr0 libkml-dev libkmlbase1 libkmlconvenience1 libkmldom1 libkmlengine1
  libkmlregionator1 libkmlxsd1 liblapack-dev liblapack3 libldap2-dev
  liblog4cxx-dev liblog4cxx10v5 libltdl7:i386 liblz4-dev liblzma-dev
  libminizip-dev libminizip1 libmysqlclient-dev libmysqlclient20 libnetcdf-dev
  libnetcdf13 libnl-route-3-200 libnuma-dev libodbc1 libogdi3.2 libogdi3.2-dev
  libogre-1.9-dev libogre-1.9.0v5 libopenblas-base libopengl0 libopenjp2-7-dev
  libopenmpi-dev libopenmpi2 liborc-0.4-dev liborc-0.4-dev-bin libpcre16-3
  libpcre3-dev libpcre32-3 libpcrecpp0v5 libpng-dev libpng-tools libpoco-dev
  libpococrypto50 libpocodata50 libpocodatamysql50 libpocodataodbc50
  libpocodatasqlite50 libpocofoundation50 libpocojson50 libpocomongodb50
  libpoconet50 libpoconetssl50 libpocoredis50 libpocoutil50 libpocoxml50
  libpocozip50 libpoppler-dev libpoppler-private-dev libpostproc-dev libpq-dev
  libpq5 libproj-dev libproj12 libprotobuf-dev libprotobuf-lite10
  libprotoc-dev libprotoc10 libpsm-infinipath1 libpthread-stubs0-dev
  libpython-all-dev libpython-dev libpython2.7-dev libpython3-dev
  libpython3.6-dev libqhull-dev libqhull-r7 libqhull7 libqt5concurrent5
  libqt5designer5 libqt5opengl5 libqt5opengl5-dev libqt5sql5 libqt5sql5-sqlite
  libqt5test5 libqwt-headers libqwt-qt5-6 libqwt-qt5-dev librdmacm1
  libsctp-dev libsctp1 libsdformat6 libsdl2-2.0-0 libsimbody-dev
  libsimbody3.5v5 libsm-dev libspatialite-dev libspatialite7 libspnav0
  libsqlite3-dev libssl-dev libsuperlu-dev libsuperlu5 libswresample-dev
  libswscale-dev libsz2 libtar-dev libtar0 libtbb-dev libtbb2 libtiff-dev
  libtiff5-dev libtiffxx5 libtinyxml-dev libtinyxml2-6 libtinyxml2-dev
  libtinyxml2.6.2v5 liburdfdom-dev liburdfdom-headers-dev liburdfdom-model
  liburdfdom-model-state liburdfdom-sensor liburdfdom-world liburiparser-dev
  liburiparser1 libusb-1.0-0-dev libusb-1.0-doc libwayland-bin libwayland-dev
  libwebp-dev libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 libx11-dev libx11-doc
  libx11-xcb-dev libxau-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev
  libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-shape0-dev
  libxcb-sync-dev libxcb-xfixes0-dev libxcb1-dev libxdamage-dev libxdmcp-dev
  libxerces-c-dev libxerces-c3.2 libxext-dev libxfixes-dev libxi-dev
  libxml2-dev libxmu-dev libxmu-headers libxshmfence-dev libxt-dev
  libxxf86vm-dev libyaml-cpp-dev libyaml-cpp0.5v5 libyaml-dev libzip-dev
  libzip4 libzmq3-dev linux-headers-5.4.0-146-generic
  linux-hwe-5.4-headers-5.4.0-146 linux-image-5.4.0-146-generic
  linux-modules-5.4.0-146-generic linux-modules-extra-5.4.0-146-generic
  mesa-common-dev mpi-default-bin mpi-default-dev mysql-common odbcinst:i386
  odbcinst1debian2 odbcinst1debian2:i386 openmpi-bin openmpi-common pkg-config
  proj-data python-all python-all-dev python-asn1crypto python-cffi-backend
  python-crypto python-cryptography python-dbus python-defusedxml python-dev
  python-empy python-enum34 python-gi python-gnupg python-idna
  python-ipaddress python-keyring python-keyrings.alt python-netifaces
  python-nose python-numpy python-paramiko python-pip-whl python-pyasn1
  python-pycryptodome python-rospkg python-secretstorage python-wheel
  python-wxgtk3.0 python-wxtools python-wxversion python-xdg python2.7-dev
  python3-catkin-pkg-modules python3-dev python3-pyparsing python3-wheel
  python3.6-dev qt5-qmake qt5-qmake-bin qtbase5-dev qtbase5-dev-tools
  qtchooser sdformat-sdf ttf-dejavu-core unixodbc-dev uuid-dev
  x11proto-core-dev x11proto-damage-dev x11proto-dev x11proto-fixes-dev
  x11proto-input-dev x11proto-xext-dev x11proto-xf86vidmode-dev
  xorg-sgml-doctools xtrans-dev zlib1g-dev
使用'sudo apt autoremove'来卸载它(它们)

使用该命令删除之前安装的包,(如果依赖关系冲突,不能被解决,我的情况是给不出依赖问题解决方案,如果不手动解决,无法安装,所以我直接卸载删除之前安装的所有)

sudo apt autoremove

然后使用命令

wget http://fishros.com/install -O fishros && . fishros

使用roscore命令检查是否安装成功。

... logging to /home/sunx/.ros/log/56dfc0a6-ecbd-11ed-98fb-28cdc497963d/roslaunch-sunx-NBLK-WAX9X-15496.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://sunx-NBLK-WAX9X:37869/
ros_comm version 1.14.13


SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.13

NODES

auto-starting new master
process[master]: started with pid [15516]
ROS_MASTER_URI=http://sunx-NBLK-WAX9X:11311/

setting /run_id to 56dfc0a6-ecbd-11ed-98fb-28cdc497963d
process[rosout-1]: started with pid [15534]
started core service [/rosout]

安装完后还需要初始化下rosdep

wget http://fishros.com/install -O fishros && . fishros

由于前面已经删除了catkin_ws,所以这里需要重新建一个。

mkdir -p ~/catkin_ws/src
mkdir -p ~/catkin_ws/scripts
cd catkin_ws && catkin init # 使用catkin_make话,则为cd catkin_ws/src && catkin_init_workspace
catkin build # 使用catkin_make话,则为 cd .. && catkin_make 

如果前面没用过catkin build需要先装catkin-tools(sudo apt install python3-catkin-tools)。
然后再

mkdir -p ~/catkin_ws/src
mkdir -p ~/catkin_ws/scripts
cd catkin_ws && catkin init # 使用catkin_make话,则为cd catkin_ws/src && catkin_init_workspace
catkin build # 使用catkin_make话,则为 cd .. && catkin_make 
Warning, builtin verb aliases at '/home/sunx/.config/catkin/verb_aliases/00-default-aliases.yaml' differ from builtin, overwriting
---------------------------------------------------------
Profile:                     default
Extending:             [env] /opt/ros/melodic
Workspace:                   /home/sunx/catkin_ws
---------------------------------------------------------
Build Space:        [exists] /home/sunx/catkin_ws/build
Devel Space:        [exists] /home/sunx/catkin_ws/devel
Install Space:      [unused] /home/sunx/catkin_ws/install
Log Space:         [missing] /home/sunx/catkin_ws/logs
Source Space:       [exists] /home/sunx/catkin_ws/src
DESTDIR:            [unused] None
---------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
---------------------------------------------------------
Additional CMake Args:       None
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
---------------------------------------------------------
Buildlisted Packages:        None
Skiplisted Packages:         None
---------------------------------------------------------
Workspace configuration appears valid.

NOTE: Forcing CMake to run for each package.
---------------------------------------------------------
[build] No packages were found in the source space '/home/sunx/catkin_ws/src'
[build] No packages to be built.
[build] Package table is up to date.                                           
Starting  >>> catkin_tools_prebuild                                            
Finished  <<< catkin_tools_prebuild                [ 2.6 seconds ]             
[build] Summary: All 1 packages succeeded!                                     
[build]   Ignored:   None.                                                     
[build]   Warnings:  None.                                                     
[build]   Abandoned: None.                                                     
[build]   Failed:    None.                                                     
[build] Runtime: 2.6 seconds total.  

Gazebo

参考链接:Ubuntu18安装Gazebo9
卸载

sudo apt-get remove gazebo* 
sudo apt-get remove libgazebo*
sudo apt-get remove ros-melodic-gazebo* #kinetic noetic对应修改

先Git一个XTDrone代码。

git clone https://gitee.com/robin_shaun/XTDrone.git
cd XTDrone
git submodule update --init --recursive

step-by-step安装方式

sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'

You can check to see if the file was written correctly.

cat /etc/apt/sources.list.d/gazebo-stable.list

setup keys

wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -

update the debian database

sudo apt-get update

Next install gazebo-9 by:

sudo apt-get install gazebo9
# For developers that work on top of Gazebo, one extra package
sudo apt-get install libgazebo9-dev

检查安装情况:

gazebo

出现错误:

sunx@sunx-NBLK-WAX9X:~$ gazebo
gazebo: symbol lookup error: /usr/lib/x86_64-linux-gnu/libgazebo_common.so.9: undefined symbol: _ZN8ignition10fuel_tools12ClientConfig12SetUserAgentERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

这个是有相应的库没有升级

sudo apt upgrade libignition-math2

我们对Gazebo的ROS插件做了修改,因此需要源码编译。安装依赖:

sudo apt-get install ros-melodic-moveit-msgs ros-melodic-object-recognition-msgs ros-melodic-octomap-msgs ros-melodic-camera-info-manager  ros-melodic-control-toolbox ros-melodic-polled-camera ros-melodic-controller-manager ros-melodic-transmission-interface ros-melodic-joint-limits-interface

然后编译(如果编译时还缺其他的依赖,同上方法安装),由于需要用到XTDrone的文件,需要先完成XTDrone源码下载。

cd ~/catkin_ws
cp -r ~/XTDrone/sitl_config/gazebo_ros_pkgs src/
catkin build #开发者测试使用catkin_make会出问题,因此建议使用catkin build

错误2
编译的时候的错误:
执行catkin build时报错:

---------------------------------------------------------
Profile:                     default
Extending:             [env] /opt/ros/melodic
Workspace:                   /home/sunx/catkin_ws
---------------------------------------------------------
Build Space:        [exists] /home/sunx/catkin_ws/build
Devel Space:        [exists] /home/sunx/catkin_ws/devel
Install Space:      [unused] /home/sunx/catkin_ws/install
Log Space:          [exists] /home/sunx/catkin_ws/logs
Source Space:       [exists] /home/sunx/catkin_ws/src
DESTDIR:            [unused] None
---------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
---------------------------------------------------------
Additional CMake Args:       None
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
---------------------------------------------------------
Buildlisted Packages:        None
Skiplisted Packages:         None
---------------------------------------------------------
Workspace configuration appears valid.
---------------------------------------------------------
[build] Found 6 packages in 0.0 seconds.                                       
[build] Updating package table.                                                
Starting  >>> gazebo_dev                                                       
Starting  >>> gazebo_msgs                                                      
Finished  <<< gazebo_dev                        [ 2.7 seconds ]                
Finished  <<< gazebo_msgs                       [ 9.6 seconds ]                
Starting  >>> gazebo_ros                                                       
Finished  <<< gazebo_ros                        [ 21.5 seconds ]               
Starting  >>> gazebo_plugins                                                   
Starting  >>> gazebo_ros_control                                               
Finished  <<< gazebo_ros_control                [ 27.2 seconds ]               
_______________________________________________________________________________
Errors     << gazebo_plugins:make /home/sunx/catkin_ws/logs/gazebo_plugins/build.make.000.log
c++: internal compiler error: 已杀死 (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
make[2]: *** [CMakeFiles/gazebo_ros_openni_kinect.dir/src/gazebo_ros_openni_kinect.cpp.o] Error 4
make[1]: *** [CMakeFiles/gazebo_ros_openni_kinect.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....
make: *** [all] Error 2
cd /home/sunx/catkin_ws/build/gazebo_plugins; catkin build --get-env gazebo_plugins | catkin env -si  /usr/bin/make --jobserver-fds=3,4 -j; cd -

...............................................................................
Failed     << gazebo_plugins:make               [ Exited with code 2 ]         
Failed    <<< gazebo_plugins                    [ 2 minutes and 26.4 seconds ] 
Abandoned <<< gazebo_ros_pkgs                   [ Unrelated job failed ]       
[build] Summary: 4 of 6 packages succeeded.                                    
[build]   Ignored:   None.                                                     
[build]   Warnings:  None.                                                     
[build]   Abandoned: 1 packages were abandoned.                                
[build]   Failed:    1 packages failed.                                        
[build] Runtime: 2 minutes and 57.6 seconds total.                             
[build] Note: Workspace packages have changed, please re-source setup files to use them.

这个错误是因为系统的交换空间不够,需要临时增加交换空间大小
参考链接make px4_sitl_default gazebo
我执行了命令,释放空间

sudo dd if=/dev/zero of=/swapfile bs=64M count=32 #使用swap创建临时分区
#count的大小就是增加的swap空间的大小,64M是块大小,所以空间大小是bs*count=1024MB(这里空间大小也可以根据自己的需要设置)
sudo mkswap /swapfile
sudo chmod 0600 /swapfile 
sudo swapon /swapfile
swapoff -a

再次执行catkin build通过编译

---------------------------------------------------------
Profile:                     default
Extending:          [cached] /opt/ros/melodic
Workspace:                   /home/sunx/catkin_ws
---------------------------------------------------------
Build Space:        [exists] /home/sunx/catkin_ws/build
Devel Space:        [exists] /home/sunx/catkin_ws/devel
Install Space:      [unused] /home/sunx/catkin_ws/install
Log Space:          [exists] /home/sunx/catkin_ws/logs
Source Space:       [exists] /home/sunx/catkin_ws/src
DESTDIR:            [unused] None
---------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
---------------------------------------------------------
Additional CMake Args:       None
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
---------------------------------------------------------
Buildlisted Packages:        None
Skiplisted Packages:         None
---------------------------------------------------------
Workspace configuration appears valid.
---------------------------------------------------------
[build] Found 6 packages in 0.0 seconds.                                       
[build] Package table is up to date.                                           
Starting  >>> gazebo_dev                                                       
Starting  >>> gazebo_msgs                                                      
Finished  <<< gazebo_dev                        [ 0.2 seconds ]                
Finished  <<< gazebo_msgs                       [ 0.8 seconds ]                
Starting  >>> gazebo_ros                                                       
Finished  <<< gazebo_ros                        [ 0.6 seconds ]                
Starting  >>> gazebo_plugins                                                   
Starting  >>> gazebo_ros_control                                               
Finished  <<< gazebo_ros_control                [ 0.3 seconds ]                
Finished  <<< gazebo_plugins                    [ 16.4 seconds ]               
Starting  >>> gazebo_ros_pkgs                                                  
Finished  <<< gazebo_ros_pkgs                   [ 2.7 seconds ]                
[build] Summary: All 6 packages succeeded!                                     
[build]   Ignored:   None.                                                     
[build]   Warnings:  None.                                                     
[build]   Abandoned: None.                                                     
[build]   Failed:    None.                                                     
[build] Runtime: 20.6 seconds total.                                           
[build] Note: Workspace packages have changed, please re-source setup files to use them.

编译成功后执行:

source ~/catkin_ws/devel/setup.bash
rosrun gazebo_ros gazebo

第一次执行会稍微慢一点,其中可以

gedit ~/.bashrc
# 把setup.bash写入到其中
source ~/catkin_ws/devel/setup.bash
# 并保存

这样以后使用就比较方便了.
下载模型,并解压

unzip models.zip
cp -r models ~/.gazebo/models/

MAVROS安装

sudo apt install ros-kinetic-mavros ros-kinetic-mavros-extras 		# for ros-kinetic
sudo apt install ros-melodic-mavros ros-melodic-mavros-extras 		# for ros-melodic
wget https://gitee.com/robin_shaun/XTDrone/raw/master/sitl_config/mavros/install_geographiclib_datasets.sh

sudo chmod a+x ./install_geographiclib_datasets.sh
sudo ./install_geographiclib_datasets.sh #这步需要装一段时间
sunx@sunx-NBLK-WAX9X:~$ wget https://gitee.com/robin_shaun/XTDrone/raw/master/sitl_config/mavros/install_geographiclib_datasets.sh
--2023-05-07 21:09:40--  https://gitee.com/robin_shaun/XTDrone/raw/master/sitl_config/mavros/install_geographiclib_datasets.sh
正在解析主机 gitee.com (gitee.com)... 212.64.63.215, 212.64.63.190
正在连接 gitee.com (gitee.com)|212.64.63.215|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 1244 (1.2K) [text/plain]
正在保存至: “install_geographiclib_datasets.sh.1”

install_geographicl 100%[===================>]   1.21K  --.-KB/s    用时 0s    

2023-05-07 21:09:41 (164 MB/s) - 已保存 “install_geographiclib_datasets.sh.1” [1244/1244])

sunx@sunx-NBLK-WAX9X:~$ sudo chmod a+x ./install_geographiclib_datasets.sh
sunx@sunx-NBLK-WAX9X:~$ sudo ./install_geographiclib_datasets.sh #这步需要装一段时间
GeographicLib geoids dataset egm96-5 already exists, skipping
GeographicLib gravity dataset egm96 already exists, skipping
GeographicLib magnetic dataset emm2015 already exists, skippings

PX4配置

git clone https://github.com/PX4/PX4-Autopilot.git
mv PX4-Autopilot PX4_Firmware
cd PX4_Firmware
git checkout -b xtdrone/dev v1.11.0-beta1
git submodule update --init --recursive
make px4_sitl_default gazebo

PX4安装可以参考该链接:
完整安装PX4/PX4-Autopilot,无需科学上网

报错:c++: internal compiler error: 已杀死 (program cc1plus)

c++: internal compiler error: 已杀死 (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
[47/100] Building CXX object CMakeFile...dir/src/gazebo_gst_camera_plugin.cpp.o
ninja: build stopped: subcommand failed.
[736/740] Linking CXX executable bin/px4
FAILED: external/Stamp/sitl_gazebo/sitl_gazebo-build 
cd /home/sunx/PX4_Firmware/build/px4_sitl_default/build_gazebo && /usr/bin/cmake --build .
ninja: build stopped: subcommand failed.
Makefile:198: recipe for target 'px4_sitl_default' failed
make: *** [px4_sitl_default] Error 1

空间不够大,编译不了

执行命令:

cd PX4_Firmware
make px4_sitl_default gazebo

运行报错:

Traceback (most recent call last):
  File "/home/sunx/catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/spawn_model", line 34, in <module>
    from tf.transformations import quaternion_from_euler
  File "/opt/ros/melodic/lib/python2.7/dist-packages/tf/__init__.py", line 30, in <module>
    from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
  File "/opt/ros/melodic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 39, in <module>
    from .buffer_interface import *
  File "/opt/ros/melodic/lib/python2.7/dist-packages/tf2_ros/buffer_interface.py", line 32, in <module>
    import roslib; roslib.load_manifest('tf2_ros')
  File "/opt/ros/melodic/lib/python2.7/dist-packages/roslib/launcher.py", line 64, in load_manifest
    sys.path = _generate_python_path(package_name, _rospack) + sys.path
  File "/opt/ros/melodic/lib/python2.7/dist-packages/roslib/launcher.py", line 97, in _generate_python_path
    m = rospack.get_manifest(pkg)
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 171, in get_manifest
    return self._load_manifest(name)
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 215, in _load_manifest
    retval = self._manifests[name] = parse_manifest_file(self.get_path(name), self._manifest_name, rospack=self)
  File "/usr/lib/python2.7/dist-packages/rospkg/manifest.py", line 414, in parse_manifest_file
    _static_rosdep_view = init_rospack_interface()
  File "/usr/lib/python2.7/dist-packages/rosdep2/rospack.py", line 60, in init_rospack_interface
    lookup = _get_default_RosdepLookup(Options())
  File "/usr/lib/python2.7/dist-packages/rosdep2/main.py", line 136, in _get_default_RosdepLookup
    verbose=options.verbose)
  File "/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py", line 603, in create_default
    sources = load_cached_sources_list(sources_cache_dir=sources_cache_dir, verbose=verbose)
  File "/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py", line 560, in load_cached_sources_list
    raise CachePermissionError('Failed to write cache file: ' + str(e))
rosdep2.core.CachePermissionError: Failed to write cache file: [Errno 13] Permission denied: '/home/sunx/.ros/rosdep/sources.cache/index'
[vehicle_spawn_sunx_NBLK_WAX9X_3023_4520051423393195513-5] process has died [pid 3101, exit code 1, cmd /home/sunx/catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/spawn_model -sdf -file /home/sunx/PX4_Firmware/Tools/sitl_gazebo/models/iris/iris.sdf -model iris -x 0 -y 0 -z 0 -R 0 -P 0 -Y 0 __name:=vehicle_spawn_sunx_NBLK_WAX9X_3023_4520051423393195513 __log:=/home/sunx/.ros/log/b4e3907c-ece2-11ed-b9a4-28cdc497963d/vehicle_spawn_sunx_NBLK_WAX9X_3023_4520051423393195513-5.log].
log file: /home/sunx/.ros/log/b4e3907c-ece2-11ed-b9a4-28cdc497963d/vehicle_spawn_sunx_NBLK_WAX9X_3023_4520051423393195513-5*.log

解决方法:

sudo rosdep fix-permissions

运行命令

rostopic echo /mavros/state

结果:

XTDrone

对XTDrone进行配置,因为之前已经下载了源码

cd XTDrone
git submodule update --init --recursive
cp sensing/gimbal/gazebo_gimbal_controller_plugin.cpp ~/PX4_Firmware/Tools/sitl_gazebo/src/
cp sitl_config/init.d-posix/rcS ~/PX4_Firmware/ROMFS/px4fmu_common/init.d-posix/
cp sitl_config/worlds/* ~/PX4_Firmware/Tools/sitl_gazebo/worlds/
cp -r sitl_config/models/* ~/PX4_Firmware/Tools/sitl_gazebo/models/ 
cp -r sitl_config/launch/* ~/PX4_Firmware/launch/
cd ~/.gazebo/models/
rm -r stereo_camera/ 3d_lidar/ 3d_gpu_lidar/ hokuyo_lidar/


参考链接:ROS 遇到问题及解决——汇总

XTDorne平台搭建无人机仿真环境时遇到的问题及解决

ubuntu卸载已安装的包

你可能感兴趣的:(XTDrone,PX4,学习)