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 \
xmlstarlet
pip install \
pandas \
jinja2 \
pyserial \
cerberus \
pyulog \
numpy \
toml \
pyquaternion
参考链接
参考链接
这是一个飞机固件与ros通信的包:
sudo apt install ros-kinetic-mavros ros-kinetic-mavros-extras
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
sudo chmod a+x ./install_geographiclib_datasets.sh
sudo ./install_geographiclib_datasets.sh ##此时执行速度很慢,耐心等待完成
下载固件
git clone https://github.com/PX4/Firmware
mv Firmware PX4_Firmware
cd PX4_Firmware
git checkout -b xtdrone/dev v1.11.0-beta1
git submodule update --init --recursive
一般来说,第一次安装飞控固件,编译时会报错,因为缺少了必要的python依赖,因此在下载玩Firmware后,在编译之前,首先:
cd PX4_Firmware
bash
bash ./Tools/setup/ubuntu.sh --no-nuttx --no-sim-tools ##此处跳过了仿真器的安装,因为已经在ros已经配置好了
这之后,再执行下面指令,一般就不会出错,如果继续报错,一般为个人电脑环境配置的问题,请根据终端中的错误提示自行安装依赖。
make posix_sitl_default gazebo
**
[ros] ccache: failed to create /home/ 问题解决
解决办法:删除/home/xxx/.ccache文件
(xxx)是你虚拟机用户名的名称
sudo rm -rf /home/xxx/.ccache/
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)
linked by target "LiftDragPlugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_gst_camera_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_barometer_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_geotagged_images_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_magnetometer_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "sensor_msgs" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_irlock_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_video_stream_widget" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_controller_interface" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_wind_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "std_msgs" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_gps_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_sonar_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "mav_msgs" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "nav_msgs" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_lidar_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_opticalflow_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_mavlink_interface" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_uuv_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_vision_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_multirotor_base_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_imu_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_gimbal_controller_plugin" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "physics_msgs" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
linked by target "gazebo_motor_model" in directory /home/sch/catkin_ws/src/Firmware/Tools/sitl_gazebo
-- Configuring incomplete, errors occurred!
解决办法:
sudo apt-get install libgstreamer-plugins-base1.0-dev
[11/33] Building CXX object CMakeFiles...plugin.dir/src/gazebo_uuv_plugin.cpp.o
FAILED: /usr/bin/c++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -Dgazebo_uuv_plugin_EXPORTS -isystem /usr/include/qt4 -isystem /usr/include/qt4/QtGui -isystem /usr/include/qt4/QtCore -isystem /usr/include/gazebo-7 -isystem /usr/include/sdformat-4.4 -isystem /usr/include/ignition/math2 -isystem /usr/include/OGRE -I/home/weiweu/PX4_Firmware/Tools/sitl_gazebo/include -I. -I/usr/include/eigen3 -I/usr/include/eigen3/eigen3 -I/usr/include/gazebo-7/gazebo/msgs -I/home/weiweu/PX4_Firmware/mavlink/include -I/usr/include/OGRE/Paging -isystem /opt/ros/kinetic/include/opencv-3.3.1-dev -isystem /opt/ros/kinetic/include/opencv-3.3.1-dev/opencv -I/home/weiweu/PX4_Firmware/Tools/sitl_gazebo/external/OpticalFlow/include -I/usr/include/gstreamer-1.0 -I/usr/lib/x86_64-linux-gnu/gstreamer-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wno-deprecated-declarations -Wno-address-of-packed-member -fPIC -std=gnu++14 -MMD -MT CMakeFiles/gazebo_uuv_plugin.dir/src/gazebo_uuv_plugin.cpp.o -MF CMakeFiles/gazebo_uuv_plugin.dir/src/gazebo_uuv_plugin.cpp.o.d -o CMakeFiles/gazebo_uuv_plugin.dir/src/gazebo_uuv_plugin.cpp.o -c /home/weiweu/PX4_Firmware/Tools/sitl_gazebo/src/gazebo_uuv_plugin.cpp
c++: internal compiler error: 已杀死 (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
[11/33] Building CXX object CMakeFiles...dir/src/gazebo_mavlink_interface.cpp.o
ninja: build stopped: subcommand failed.
[2/5] Generating ../../logs
FAILED: cd /home/weiweu/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
解决办法:
这个原因是内存不足, 在linux下增加临时swap空间
#注释:of=/home/swap,放置swap的空间; count的大小就是增加的swap空间的大小,64M就是块大小,这里是64MB,所以总共空间就是bs*count=1024MB.这里分配空间的时候需要一点时间,等待执行完毕。
sudo dd if=/dev/zero of=/home/swap bs=64M count=16
#注释:把刚才空间格式化成swap各式
sudo mkswap /home/swap (可能会提示warning: don't erase bootbits sectorson whole disk. Use -f to force,不用理会)
#注释:使刚才创建的swap空间
sudo swapon /home/swap
然后执行你的需要的make,我的是
make px4_sitl_default gazebo
便可以成功运行:
px4无人机的基本环境就配置好了,应该可以看到gazebo界面中已经有了一个叫做iris的无人机。
修改 ~/.bashrc,加入以下代码,注意路径匹配。
source ~/PX4_Firmware/Tools/setup_gazebo.bash ~/PX4_Firmware/ ~/PX4_Firmware/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4_Firmware
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4_Firmware/Tools/sitl_gazebo
然后运行如下命令,此时会启动Gazebo,如下图所示。
roslaunch px4 mavros_posix_sitl.launch
[FATAL] [1592276532.778789363]: UAS: GeographicLib exception: File not readable /usr/share/GeographicLib/geoids/egm96-5.pgm | Run install_geographiclib_dataset.sh script in order to install Geoid Model dataset!
NAV_DLL_ACT: curr: 0 -> new: 2
RTL_DESCEND_ALT: curr: 30.0000 -> new: 5.0000
RTL_LAND_DELAY: curr: -1.0000 -> new: 5.0000
RTL_RETURN_ALT: curr: 60.0000 -> new: 30.0000
SDLOG_MODE: curr: 0 -> new: 1
SDLOG_PROFILE: curr: 3 -> new: 131
SDLOG_DIRS_MAX: curr: 0 -> new: 7
SENS_BOARD_X_OFF: curr: 0.0000 -> new: 0.0000
SENS_DPRES_OFF: curr: 0.0000 -> new: 0.0010
TRIG_INTERFACE: curr: 4 -> new: 3
* RTL_DESCEND_ALT: curr: 5.0000 -> new: 10.0000
* RTL_LAND_DELAY: curr: 5.0000 -> new: 0.0000
PWM_MAX: curr: 2000 -> new: 1950
PWM_MIN: curr: 1000 -> new: 1075
GPS_UBX_DYNMODEL: curr: 7 -> new: 6
* SYS_AUTOCONFIG: curr: 1 -> new: 0
INFO [dataman] Unknown restart, data manager file './dataman' size is 11798680 bytes
INFO [simulator] Waiting for simulator to accept connection on TCP port 4560
[ INFO] [1592276533.100343456]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1592276533.100970472]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[ INFO] [1592276533.123831704]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1592276533.124724290]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
================================================================================REQUIRED process [mavros-6] has died!
process has finished cleanly
log file: /home/weiweu/.ros/log/c620005a-af7d-11ea-ac47-000c299b4adc/mavros-6*.log
Initiating shutdown!
================================================================================
[mavros-6] killing on exit
[vehicle_spawn_weiweu_virtual_machine_5785_5709449976029652956-5] killing on exit
[gazebo_gui-4] killing on exit
[gazebo-3] killing on exit
[sitl-2] killing on exit
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/gazebo_ros/spawn_model", line 32, in <module>
import tf.transformations as tft
File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf/__init__.py", line 28, in <module>
from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 39, in <module>
from .buffer_interface import *
File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/buffer_interface.py", line 32, in <module>
import roslib; roslib.load_manifest('tf2_ros')
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslib/launcher.py", line 62, in load_manifest
sys.path = _generate_python_path(package_name, _rospack) + sys.path
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslib/launcher.py", line 93, 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 410, in parse_manifest_file
from rosdep2.rospack import init_rospack_interface, is_ros_package, is_system_dependency, is_view_empty
File "/usr/lib/python2.7/dist-packages/rosdep2/__init__.py", line 45, in <module>
ERROR [px4] Startup script returned with return value: 2
from .lookup import RosdepDefinition, RosdepView, RosdepLookup, \
File "/usr/lib/python2.7/dist-packages/rosdep2/lookup.py", line 44, in <module>
from .sources_list import SourcesListLoader
File "/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py", line 48, in <module>
from .gbpdistro_support import get_gbprepo_as_rosdep_data, download_gbpdistro_as_rosdep_data
File "/usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py", line 18, in <module>
from .platforms.debian import APT_INSTALLER
File "/usr/lib/python2.7/dist-packages/rosdep2/platforms/__init__.py", line 1, in <module>
KeyboardInterrupt
[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
done
解决办法:
还在解决中!!