LoginSignup
0

More than 1 year has passed since last update.

Ubuntu 18.04 にArduPilot SITLシミュレーターをインストール

Last updated at Posted at 2022-10-17

この記事では、Ubuntu 18.04 にArduPilot SITLシミュレーターをインストールする手順とトラブルを共有します。

ArduPilot SITLとは

ArduPilotのドローン実機なくても、開発とテスト検証できるシミュレーターソフトウェアSITL Simulator (Software in the Loop)です。

image.png

インストール手順

Clone ArduPilot repository¶

git clone https://github.com/ArduPilot/ardupilot.git
cd ardupilot
git submodule update --init --recursive

Install some required packages¶

Tools/environment_install/install-prereqs-ubuntu.sh -y
. ~/.profile

compile

./waf configure --board sitl
./waf copter

SITLを起動

cd ardupilot/ArduCopter
../Tools/autotest/sim_vehicle.py -w
パラメータの書き込み更新完了後、Ctrl-Cで上記コマンドを終了します。
再度sim_vehicle.pyを実行します。
../Tools/autotest/sim_vehicle.py --console --map

指定したHomepointで起動する場合、-l オプションで緯度経度を指定して起動できます。
-l CUSTOM_LOCATION, --custom-location=CUSTOM_LOCATION
                    set custom start location (lat,lon,alt,heading)

../Tools/autotest/sim_vehicle.py --console --map -D -l 35.6844910,139.7121530,15,5

トラブル

「Tools/environment_install/install-prereqs-ubuntu.sh -y」のインストール途中で下記エラー発生しました。

TypeError: 'encoding' is an invalid keyword argument for this function

  Using cached dronecan-1.0.16.tar.gz (97 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ePZxjD/dronecan/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ePZxjD/dronecan/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-kK64Ti
         cwd: /tmp/pip-install-ePZxjD/dronecan/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-ePZxjD/dronecan/setup.py", line 19, in <module>
        with open("README.md", "r", encoding = "utf-8") as fh:
    TypeError: 'encoding' is an invalid keyword argument for this function
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 20.3; however, version 20.3.4 is available.
You should consider upgrading via the '/usr/bin/python -m pip install --upgrade pip' command.

デフォルトでは、python2.7になっているの原因です。python3.7等のバージョンに切替必要です。

$ /usr/bin/python -V
Python 2.7.17

$ ll /usr/bin/python
lrwxrwxrwx 1 root root 9  4月 16  2018 /usr/bin/python -> python2.7*

sudo rm -rf /usr/bin/python

sudo ln -s /home/k-koh/miniconda3/bin/python /usr/bin/python

$ /usr/bin/python -V
Python 3.7.0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0