Board index FlightGear Development Aircraft Autopilot and route manager

Altitude hold

Designing a stable autopilot is one of the hardest things. Need help?

Altitude hold

Postby Octal450 » Wed May 18, 2016 4:50 am

I am trying to program a function to make the plane hold the altitude to the nearest 100ft. Currently, I have used this:

Code: Select all
var altsh = getprop("/instrumentation/altimeter/indicated-altitude-ft");
setprop("/autopilot/settings/target-altitude-ft", altsh);


Which is exucted when the ALT switch it pressed, and it levels off. But I want it to round to the nearest 100. How do I accomplish this?
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Altitude hold

Postby tikibar » Wed May 18, 2016 5:07 am

Look in the MD-11 AFDS.nas. It does exactly that.
Boeing 747-8 (rename folder to 747-8i)
Boeing 757-200/300 (rename folder to 757-200)
Boeing 767-300/ER (rename folder to 767-300)
McDonnell Douglas MD-11 (rename folder to MD-11)
User avatar
tikibar
 
Posts: 514
Joined: Mon Mar 05, 2012 6:05 am
Location: Los Angeles
Callsign: CHT0009
OS: Ubuntu 14.04

Re: Altitude hold

Postby Octal450 » Wed May 18, 2016 5:34 am

@tikibar
OK

EDIT: It is this line if anyone wants it :D
Code: Select all
var alt = int((getprop("instrumentation/altimeter/indicated-altitude-ft")+50)/100)*100;


I modified it as a setprop, and worked for me.

Regards,
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm


Return to Autopilot and route manager

Who is online

Users browsing this forum: YandexBot [Bot] and 1 guest