Last active
July 7, 2026 12:30
-
-
Save CSUwangj/c4bca4a9eaade3e84ad5aadccd28be1f to your computer and use it in GitHub Desktop.
t
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/data/data/com.termux/files/usr/bin/bash | |
| # install-prereqs-termux.sh (headless SITL, no GUI) | |
| # | |
| # Sets up a rootless Ubuntu environment (via proot-distro) inside Termux on | |
| # Android so ArduPilot's ORIGINAL, UNMODIFIED install-prereqs-ubuntu.sh can | |
| # run and give you headless SITL vehicle simulation -- no map/console GUI, | |
| # no X11, no wxPython/SFML/OpenCV graphics stack. | |
| # | |
| # Why proot-distro at all, if there's no GUI: ArduPilot's SITL binary is | |
| # real C/C++ built with assumptions from glibc-based Linux. Compiling and | |
| # running it natively against Termux/Android's Bionic libc is unsupported | |
| # and prone to obscure failures. A real (rootless) Ubuntu userland avoids | |
| # all of that, while still being lightweight since we skip every graphical | |
| # package. | |
| # | |
| # Run this INSIDE the Termux app (not inside any proot-distro container). | |
| echo "---------- $0 start ----------" | |
| set -e | |
| sep="##############################################" | |
| heading() { echo "$sep"; echo "$*"; echo "$sep"; } | |
| heading "Updating Termux package lists" | |
| pkg update -y | |
| pkg upgrade -y | |
| heading "Installing Termux-side tools" | |
| pkg install -y proot-distro wget git | |
| heading "Installing Ubuntu rootfs via proot-distro (skips if already installed)" | |
| if ! proot-distro list 2>/dev/null | grep -qi "ubuntu.*installed"; then | |
| proot-distro install ubuntu | |
| else | |
| echo "Ubuntu proot-distro container already installed, skipping." | |
| fi | |
| heading "Creating launcher: start-ubuntu-sitl.sh" | |
| cat > "$HOME/start-ubuntu-sitl.sh" << 'EOF' | |
| #!/data/data/com.termux/files/usr/bin/bash | |
| # Logs into the Ubuntu proot-distro container. No display server needed. | |
| proot-distro login ubuntu | |
| EOF | |
| chmod +x "$HOME/start-ubuntu-sitl.sh" | |
| echo "Done!" | |
| echo "" | |
| heading "Termux-side setup complete. Remaining manual steps:" | |
| cat << 'EOF' | |
| 1. Log into the Ubuntu container: | |
| ~/start-ubuntu-sitl.sh | |
| 2. Inside that Ubuntu shell (first time only), get ArduPilot and run the | |
| ORIGINAL Ubuntu prereqs script unmodified, but with graphics skipped: | |
| sudo apt update | |
| git clone https://github.com/ArduPilot/ardupilot.git | |
| cd ardupilot | |
| git submodule update --init --recursive | |
| export SKIP_AP_GRAPHIC_ENV=1 | |
| Tools/environment_install/install-prereqs-ubuntu.sh -y | |
| SKIP_AP_GRAPHIC_ENV=1 tells ArduPilot's own script to skip wxPython, | |
| opencv-python, matplotlib, pygame, SFML/CSFML, SDL, and all X11 font | |
| packages -- exactly the graphical stack you don't need. Everything | |
| required for vehicle simulation itself (build tools, pymavlink, | |
| MAVProxy, dronecan, numpy, etc.) still gets installed normally. | |
| 3. Build and run SITL headlessly, e.g.: | |
| ./waf configure --board sitl | |
| ./waf copter | |
| Tools/autotest/sim_vehicle.py -v ArduCopter | |
| Do NOT pass --console or --map -- those are the GUI windows and need | |
| the graphics stack you just skipped. Without them, MAVProxy runs as a | |
| plain text console in your Termux terminal, which is exactly what you | |
| get here. You can drive it with normal MAVProxy text commands (mode, | |
| arm throttle, takeoff, etc.) or drive it via mavlink from a script. | |
| Notes: | |
| - Re-export SKIP_AP_GRAPHIC_ENV=1 in future shells before re-running the | |
| prereqs script, or add "export SKIP_AP_GRAPHIC_ENV=1" to ~/.bashrc | |
| inside the Ubuntu container so it's always set. | |
| - A phone with 4GB+ RAM and a few GB free storage is enough for this -- | |
| it's much lighter than the GUI setup since there's no desktop, no X11, | |
| no wxWidgets/SFML build artifacts. | |
| EOF | |
| echo "---------- $0 end ----------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment