# SITL user guide ###### tags: `飛控` `模擬` 架構圖![](https://i.imgur.com/2WjamIx.png) ## 安裝方法 ### 一、安裝PX4 Windows Cygwin toolchain 按照[官網教學](https://docs.px4.io/v1.12/en/dev_setup/dev_env_windows_cygwin.html)安裝cygwin,並下載V1.12.3的Firmware([參考下載原始碼部分](https://hackmd.io/@ncku-uav/BJdMG2f49)) ### 二、安裝libraries #### boost & eigen3 在安裝PX4位置,進入 pixhawk安裝位置/toolchain/cygwin64/開啟set-x86_64.exe ![](https://i.imgur.com/vAd5uz2.png) 1. 選擇Install from internet 2. 將root設在 pixhawk安裝位置/toolchain/cygwin64/ 3. Local Package Directory設在 pixhawk安裝位置/toolchain/cygwin64/lib 4. 選擇Using System Proxy Settings 5. 按下一步到出現以下畫面 ![](https://i.imgur.com/2LHDD80.png) 將右上角的Best更改成keep ![](https://i.imgur.com/w4hE9Dc.png) 將View旁邊的Pending改成Full並搜尋eigen3、boost_build及libboost-devel並將skip更改成最新版本。 ![](https://i.imgur.com/cJlb0CW.png) 在按下一步進行安裝 #### TinyXML 1. 前往[官網](http://sourceforge.net/projects/tinyxml/)下載原始碼 2. 解壓縮至 ==/home/Firmware/== 資料夾中 3. 開啟Makefile 4. 將TINYXML_USE_STL設為YES ![](https://i.imgur.com/33kFl14.png) 5. 將Target of the build中的 `OUTPUT := xmltest` 更改為 `OUTPUT := libtinyxml.a ` 6. 將 Output 中 `${OUTPUT}: ${OBJS}` 的內容 `${LD} -o $@ ${LDFLAGS} ${OBJS} ${LIBS} ${EXTRA_LIBS}` 更改為 `${AR} $@ ${LDFLAGS} ${OBJS} ${LIBS} ${EXTRA_LIBS}` ![](https://i.imgur.com/BaPP7zV.png) 7. 透過 ==run-console.bat== 前往TinyXML資料夾並輸入`make` #### JSBSim 先下載JSBSim原始碼至Firmware中,並記得切換至穩定版本 在run-console.bat按照[官網](https://jsbsim-team.github.io/jsbsim-reference-manual/mypages/quickstart-building-the-program/)中的Building with CMake做 在執行`make`後,再執行`make install` ### 編譯JSBSim_bridge 1. `git clone https://github.com/koukoc/px4-jsbsim-bridge.git` 之後進到產生的資料夾中輸入`git checkout jsbsim_bridge_windows` 成功的話會顯示 `Switched to a new branch 'jsbsim_bridge_windows' branch 'jsbsim_bridge_windows' set up to track 'origin/jsbsim_bridge_windows'` 3. 進入CMakeList.txt中 ```cmake= SET(TinyXML_LIBRARY "/cygdrive/e/PX4/home/Firmware/tinyxml/libtinyxml.a") SET(TinyXML_INCLUDE_DIR "/cygdrive/e/PX4/home/Firmware/tinyxml/") ``` 將後面的路徑更改為先前TinyXML的位置 上面是 ==libtinyxml.a== 這個檔案的位置 下面是這個檔案所在資料夾的位置 3. 複製include,model,scene,src與CMakeLists一起複製並丟到pixhawk安裝位置/Tools/jsbsim_bridge並取代 4. 打開 ==run_console.bat== 移動位置到 ==Firmware== 之後輸入 `make px4_sitl jsbsim` - 如果這個步驟遇到問題,通常是有些東西還沒安裝,在跳出的錯誤訊息中會告訴你要怎麼去安裝,照著做就可以了 - 如果錯誤訊息中出現`ModuleNotFoundError: No module named 'future'`這類訊息,可以照著前面的方法安裝需要的 moule ## For WSL https://microsoft.github.io/AirSim/px4_sitl_wsl2/(查位址教學) https://ardupilot.org/mavproxy/(WSL& Windows connection 在Windows跟Linux都要)