Code covered by the BSD License  

Highlights from
FlightGear Route Manager

image thumbnail
from FlightGear Route Manager by Johann Schweikl
Matlab functions accessing FlightGear to remotely control an aircraft's route and track its position

activate_ap(speed, host, port)
function activate_ap(speed, host, port)
% ACTIVATE_AP(SPEED, HOST, PORT)
% 
% Activate Autopilot in Flightgear over socket connection (HOST,
% PORT) and set target speed = SPEED [mph].
% Run Flightgear on HOST (e.g. '127.0.0.1' = localhost) with
% parameter "--props = PORT".

import java.net.Socket
import java.io.*

fg_socket = Socket(host, port);
out = PrintWriter(fg_socket.getOutputStream(), true);


% activate autopilot
out.println(sprintf(...
    'set /autopilot/locks/altitude altitude-hold\r\n'));
out.println(sprintf(...
    'set /autopilot/locks/heading true-heading-hold\r\n'));
out.println(sprintf(...
    'set /autopilot/locks/speed speed-with-throttle\r\n'));

% set target speed (convert mph to knots)
out.println(sprintf(...
    'set /autopilot/settings/target-speed-kt %d\r\n',speed*0.869));


out.close();
fg_socket.close();

end

Contact us at files@mathworks.com