ここに従う。
docs.px4.io
$ git clone https://github.com/PX4/PX4-Autopilot.git --recursive $ make px4_sitl jmavsim
ビルド時にはいくつかPythonライブラリがないと言われたので、pipでインストールした。
(追記)以下を実行すると自動で依存ライブラリがインストールされる。
./Tools/setup/ubuntu.sh
次はGazeboでのシミュレーションを試してみる。
GazeboへのMakeにはGstreamerのライブラリが必要だった。
bugs.webkit.org
$ sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
$ make px4_sitl gazebo
Gazeboが起動したがモデルがないと言われたので、以下からモデルをダウンロードした。
github.com
ダウンロードしたモデルの置き場所は以下。
/usr/share/gazebo-[VERSION]/models
さて、実際にPixhawk向けにビルドしてみる。
pixhawknいはハードウェアがいくつかあるが、手持ちのPixhawkは既にディスコンになっているものだった。
docs.px4.io
USBデバイスの名前をみると、3D Roboitcs FMU v2.xと表示されている。
ビルド
$ make px4_fmu-v2_default
gcc-arm-none-eabiがないと言われたのでインストール
$ sudo apt install gcc-arm-none-eabi
コンパイルできたのでアップロードしようとしたら次のエラー。
Found board id: 9,0 bootloader version: 5 on /dev/serial/by-id/usb-3D_Robotics_PX4_BL_FMU_v3.x_0-if00 sn: 001f00383037510536383839 chip: 20016419 family: b'STM32F42x' revision: b'3' flash: 2080768 bytes ERROR: Board can accept larger flash images (2080768 bytes) than board config (1032192 bytes). Please use the correct board configuration to avoid lacking critical functionality.
どうもこのハードウェアは旧版の1MBではなく2MBのフラッシュを搭載しているらしい。バージョンを変更して再度ビルドする(v2->v3)。
$ make px4_fmu-v3_default
今度はうまくいった。
Loaded firmware for board id: 9,0 size: 1910841 bytes (91.83%), waiting for the bootloader... Found board id: 9,0 bootloader version: 5 on /dev/serial/by-id/usb-3D_Robotics_PX4_BL_FMU_v3.x_0-if00 sn: 001f00383037510536383839 chip: 20016419 family: b'STM32F42x' revision: b'3' flash: 2080768 bytes Windowed mode: False Erase : [====================] 100.0% Program: [====================] 100.0% Verify : [====================] 100.0% Rebooting. Elapsed Time 26.967 [100%] Built target upload