This is not really a post about something new but rather a summary of steps others did before me and a little help to my personal memory (already forgot once how it works). The post is referring to ArduPlane but I don't see what would be different for ArduCopter. Would also like to say thanks to the developers here :-)
The problem: you want to get a HIL simulation running without windows (i.e., on a Mac or linux system) using the latest APM git repo code and QGroundcontrol as the GCS.
Outline of one possible solution:
- Install dependencies: ArduPlane (git version), QGroundcontrol 0.9.0, FlightGear V2.4.0, python 2.7, pyserial-2.5, MAVProxy (git version), pymavlink (git version), arduino-0022 and cmake 2.8.6 for building and uploading APM code straight from console
- Copy MAVLink.xml to FlighGear protocol directory (for Mac OS: /Applications/FlightGear.app/Contents/Resources/data/Protocol/ )
- Start MAVProxy: python2.7 mavproxy.py --master=/dev/tty.usbserial-A600dLKS --fgout=localhost:5010 --fgin=localhost:5000 --out=localhost:14550
- Start FlighGear with parameters: --generic=socket,out,40,localhost,5000,udp,MAVLink --generic=socket,in,45,localhost,5010,udp,MAVLink
- Start QGroundcontrol
- Enjoy :)
More detailed info on dependencies and configuration:
- git clone https://code.google.com/p/ardupilot-mega/
- cd ardupilot-mega/ArduPlane
- Modify APM_Config.h: "#define HIL_MODE HIL_MODE_ATTITUDE"
"#define HIL_PORT 0"
- cd ..
- Follow instructions in README.txt for building and uploading code (essentially, assuming arduino1280: mkdir build && cd build && cmake .. && make ArduPlane-upload )
B) MAVProxy and pymavlink: (note: should be in the same directory(?)):
- mkdir APMHIL
- git clone git://git.samba.org/tridge/UAV/pymavlink.git
- git clone git://git.samba.org/tridge/UAV/MAVProxy.git
C) Setting stuff up (modify paths according to your installation paths):
- export PYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.7:/Users/andre/pyserial/lib/python2.7/site-packages
- export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH
D) Trouble shooting:
For my EasyStar I had to fix rudder control to 0 and invert the direction of elevator control. This is easily done by the two modifications inside mavproxy.py:
status.rc_elevator = (-1.0) * scale_rc(m.servo2_raw, -1.0, 1.0, param='RC2')
status.rc_rudder = 0.0;
Also: every time one starts FlightGear one needs to start the engine manually by pressing 'S', which is annoying :)