ドローンの自律飛行を実現するには、DronecodeとMAVSDKを試してみます。
目次
動作環境
- Ubuntu 18.04
- ROS Melodic
PX4環境構築
ユーザ権限の設定、dialoutグループに追加
$ sudo usermod -a -G dialout $USER
ユーザ権限反映には、Logout and Loginしてください
Gazebo, JMAVSim and NuttX (Pixhawk) Targets
- Download ubuntu.sh and requirements.txt from the PX4
- Run the ubuntu.sh to install
wget https://raw.githubusercontent.com/PX4/Firmware/v1.10.0/Tools/setup/ubuntu.sh
wget https://raw.githubusercontent.com/PX4/Firmware/v1.10.0/Tools/setup/requirements.txt
source ubuntu.sh
ROS/Gazebo
- Download ubuntu_sim_ros_melodic.sh
- Run the ubuntu_sim_ros_melodic.sh to install
install ROS/Gazebo ("Melodic") for use with PX4
$ wget https://raw.githubusercontent.com/PX4/Devguide/v1.9.0/build_scripts/ubuntu_sim_ros_melodic.sh
$ source ubuntu_sim_ros_melodic.sh
Downloading PX4 Source Code
$ git clone https://github.com/PX4/Firmware.git
First Build (Using the jMAVSim Simulator)
use java 8
$ sudo apt install openjdk-8-jdk
$ sudo update-alternatives --config java # choose java-8
PX4 Make Build Targets
make [VENDOR_][MODEL][_VARIANT] [VIEWER_MODEL_DEBUGGER]
VENDOR: The manufacturer of the board: px4(Pixhawk), intel, parrot, etc.
MODEL: The board model : sitl, fmu-v2, etc.
VARIANT: Indicates particular configurations: rtps, lpe, default, and may be omitted.
VIEWER: This is the simulator : gazebo, jmavsim
MODEL: The vehicle model : iris (default), rover, etc.
DEBUGGER: Debugger to use: none (default), ide, gdb, lldb, ddd, valgrind, callgrind
Use jMAVSim Simulation
$ cd Firmware
$ make px4_sitl jmavsim
pxh> commander takeoff
Use Gazebo Simulation
$ make px4_sitl gazebo
pxh> commander takeoff
Fast RTPS のインストール
eProsima Fast RTPSとは、RTPS (Real Time Publish Subscribe) protocolです。
Fast RTPS を使ってPX4 uORB topicsのデータを各モジュールの間で共有する。
eProsima Fast RTPSを使用には、Java(Java JDK 8推奨)が必要です。
Installation from Sources
- foonathan_memory のインストール
$ git clone https://github.com/foonathan/memory.git
$ cd memory
$ git submodule update --init --recursive
$ mkdir build && cd build
$ cmake -DCMAKE_CXX_FLAGS=-fPIC ..
$ cmake --build . --target install
- Fast-RTPS のインストール
$ git clone -b master https://github.com/eProsima/Fast-RTPS
$ mkdir Fast-RTPS/build && cd Fast-RTPS/build
$ sudo apt-get install gradle
$ cmake -DBUILD_JAVA=ON -DCOMPILE_EXAMPLES=ON -DPERFORMANCE_TESTS=ON -DTHIRDPARTY=ON -DCMAKE_PREFIX_PATH=/usr/local/lib/ ..
$ make
$ sudo make install
QGroundControl のインストール
sudo usermod -a -G dialout $USER
sudo apt-get remove modemmanager -y
sudo apt-get install gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-gl -y
- Download QGroundControl.AppImage.
- Install (and run) using the terminal commands:
chmod +x ./QGroundControl.AppImage
./QGroundControl.AppImage (or double click)
Next: uORB Messaging