Today we finally got bored of waiting for the windy weather to subside so we took ArduWot out anyway. In the couple of weeks since our last flight we've written an interface between APM and MATLAB/Simulink utilising the MAVLink protocol. For anyone not famliar with Simulink its basically a tool used by control engineers to prototype control systems in a (reasonbly) friendly graphical way. We've used Simulink to control helicopters (T-Rex 250) indoors using a Vicon visual tracking system to determine position/attitude at 100Hz and a conventional RC transmitter. By utilising APMs fly-by-wire mode as the inner loop controller we can command roll, pitch and thottle at a fairly low rate from Simulink over Zigbee. This functionality lets us move outdoors (where we don't have the luxury of a VTS to give us 0.1mm/deg resolution!) and conduct some more interesting research activities, such as optimal control, formation flying, target tracking, etc...
Todays flight was a simple proof of concept test where we used a Simulink based PID controller to perform heading hold. It worked remarkably well but it was too windy to perform any meaningful performance assessments. The biggest issue we have is that using the RC_CHANNELS_OVERRIDE message takes command away from the RC transmitter (in FBW mode) so when we terminate the Simulink model if APM doesn't receive the message to stop overriding (setting all commands to zero) then it freezes on the last signal it received. As we're currently using XBee modules with whip antennae we do regularly lose connection for short periods so occasionally can not get control back (without switching to manual mode, which is undesirable in strong winds!). However, it seems that APM times out after about 20-30s and defaults back to the RC transmitter.
We are using RC_CHANNELS_OVERRIDE at the moment because the SET_ROLL_PITCH_YAW_THRUST message doesn't seem to be implemented on APM. I think for our purposes we may implement this message instead as this would allow us to command the nav_pitch and nav_roll angles on APM directly and utilise the mixing of RC transmitter and APM control if we ever need to get out of trouble quickly!
If anyone is interested in control of APM from Simulink I'd be happy to release the code (after a bit more testing!). Also if anyone has an interest in sending attitude commands and implementing the relevant MAVLink messages, let me know and I'd be happy to help!