2015年12月19日 星期六

QGroundControl / APM Planner 2.0 編譯記錄 (ubuntu)

最近玩飛控,先來研究一下這套軟體。

1. 安裝環境

  • ubuntu 15.10 desktop

2. 安裝套件

要編譯 QGroundControl 要裝下面這些套件:
sudo apt-get install git-core cmake gstreamer1.0 libgstreamer1.0 libsdl1.2-dev \
   libudev-dev freeglut3-dev
其中freeglut3-dev 是包含 openGL 的套件。
至於要編譯 APM Planner 2.0 還必須裝:
sudo apt-get install libsdl2-dev libsndfile1-dev libssl-dev
反正全裝就是了~

3. 安裝 Qt open source

載點在 http://www.qt.io/download-open-source/。選擇 offline installer (如 qt-opensource-linux-x64-5.5.1.run) 可以一次下載整包,速度較快。
安裝程式結束後,會建立一個 Qt 的資料夾,並且包含所有 Qt 的檔案。

4. 重新編譯 QtCreator

其實在剛剛安裝的 Qt open source 中,已經包含了 QtCreator。那麼為何要重新編一個呢? 因為下載來的 QtCreator 畢竟只是個 binary 檔,裡面和其他套件的相依性已經改不了了,所以在執行時,常會發生版本匹配錯誤的問題。

因此,我乾脆用我目前的環境重新編譯一個。有趣的是,我是用現在這個 QtCreator 來編,就是用 QtCreator 來編 QtCreator 。

先 clone 一份 QtCreator 的 code。
git clone git://github.com/qtproject/qt-creator.git 
然後,用目前的 QtCreator (qt-creator.sh) 開啟 qtcreator.pro 這個檔案,這樣 project 就開啟了。 接下來要注意的是 kit 的設定:

  • compiler, debugger, cmake: 指定成 ubuntu 內建的。(就是在 /usr/bin/ 之下的 )
  • Qt version: 指定成剛剛下載的 Qt open source。
最後 build project 就完成了。

5. 編譯 QGroundControl

終於到了最後的步驟了。同樣,一開始先下載 source:
git clone --recursive https://github.com/mavlink/qgroundcontrol.git

然後用新編好的 QtCreator (檔名同樣是 qt-creator.sh,路徑不同) 來開啟 qgroundcontrol.pro,編譯結束後,QGroundControl就完成了!

6. 編譯 APM Planner 2.0

APM Planner 2.0 的編譯步驟和 QGC 一樣。先取得 source:
git clone https://github.com/diydrones/apm_planner.git
接下來一樣用新的 QtCreator 來開啟 qgroundcontrol.pro .....等等,怎麼檔名還是 qgroundcontrol.pro 啊? 看來 APM Planner 2.0 是怎麼寫出來的,呼之欲出了....
總之,編譯結束就完成了。

沒有留言:

張貼留言