Genetic Neural Network Control Framework for ArduCopter (Multi-Instance SITL)
GannFlight is a research framework for launching and coordinating multiple ArduCopter SITL (Software-In-The-Loop) instances during controller experiments.
This repository now includes two command-line scripts designed to work together:
controller.py: runs on the machine that has ArduPilot installed and manages SITL processes.client.py: sends start/stop/list commands tocontroller.pyover TCP.
controller.py- TCP server that starts/stops SITL instances.client.py- CLI client for controlling instances remotely or locally.main/simulation_controller.py- backward-compatible entrypoint that forwards tocontroller.py.main/client.ipynb- notebook used for experimentation/training workflows.images/- plots and output images from simulation/training runs.
- Linux (tested on Ubuntu)
- Python 3.10+
- ArduPilot source checkout (default expected path:
/home/robotics/ardupilot)
Recommended: create and use a Python virtual environment for your experiment tooling.
Starts a TCP server and accepts these commands:
start <instance_id> <out_port>stop <instance_id>liststop-all
python3 controller.py --helpImportant arguments:
--host(default0.0.0.0): interface to bind for incoming client connections.--port(default14500): TCP port for control commands.--ardupilot-path(default/home/robotics/ardupilot): local ArduPilot checkout path.--out-host(default127.0.0.1): destination host for SITL MAVLink--outstream.
Sends one command per invocation.
python3 client.py --helpSubcommands:
start <instance_id> <out_port>stop <instance_id>liststop-allraw "<command>"
This mode is for when controller + client + MAVLink consumer all run on one computer.
python3 controller.py \
--host 0.0.0.0 \
--port 14500 \
--ardupilot-path /home/robotics/ardupilot \
--out-host 127.0.0.1python3 client.py --host 127.0.0.1 --port 14500 start 0 14550
python3 client.py --host 127.0.0.1 --port 14500 start 1 14551
python3 client.py --host 127.0.0.1 --port 14500 listFor instance 0 started with out_port=14550, connect your consumer to UDP port 14550 on the same machine (example pymavlink endpoint: udpin:0.0.0.0:14550).
python3 client.py --host 127.0.0.1 --port 14500 stop 0
python3 client.py --host 127.0.0.1 --port 14500 stop-allThis mode is for when SITL runs on one machine and your experiment/training code runs on another.
- Machine A (simulation host): runs
controller.pyand ArduPilot SITL. - Machine B (experiment host): runs
client.pyand your training/analysis code.
Assume:
- Machine A IP:
192.168.1.124 - Machine B IP:
192.168.1.40 - Control port:
14500
python3 controller.py \
--host 0.0.0.0 \
--port 14500 \
--ardupilot-path /home/robotics/ardupilot \
--out-host 192.168.1.40This ensures each SITL instance is launched with --out 192.168.1.40:<out_port>.
python3 client.py --host 192.168.1.124 --port 14500 start 0 14550
python3 client.py --host 192.168.1.124 --port 14500 start 1 14551
python3 client.py --host 192.168.1.124 --port 14500 listYour consumer/training loop should bind to each configured out_port (for example 14550, 14551).
- Open TCP
14500from Machine B to Machine A. - Open UDP
14550+(or your chosen range) to Machine B. - Ensure no local firewall blocks these ports.
- Verify routing between subnets/VLANs if machines are not on the same LAN.
python3 client.py --host 192.168.1.124 --port 14500 stop-all- Instance IDs should be unique per controller process.
- Keep
out_portunique per instance to avoid UDP conflicts. - Use
listto inspect currently managed instances. - Use
main/simulation_controller.pyonly if older automation still points to that path.
