Board index FlightGear Development Aircraft Autopilot and route manager

Route manager current waypoint altitude  Topic is solved

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

Route manager current waypoint altitude

Postby Octal450 » Sat Feb 25, 2017 12:57 am

Hello
Again I have a question about this Route Manager...

For my VNAV system, I need to find the altitude for the CURRENT waypoint, not wp[1] or wp[2]. Inside /autopilot/route-manager/wp is listed the current waypoint infos, but missing altitude. Inside /autopilot/route-manager/route/wp[x] I find the altitude property, but those numbers in [x] correspond to different Waypoint IDs, so I can't getprop it... Unless I can somehow put a variable with it's value in the middle of the 2 parts of property... I tried this, but this isn't the right way to do it. But perhaps, it will allow you to understand what I mean. \

Code: Select all
var wpnum = "1";
getprop("/autopilot/route-manager/route/wp["wpnum"]/altitude-ft");


I wish route manager forwarded all waypoint props into the current waypoint selection...
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Route manager current waypoint altitude  

Postby tikibar » Sat Feb 25, 2017 1:44 am

The route manager gives you "autopilot/route-manager/current-wp." You can use that to access the altitude.

Code: Select all
var wp_curr = getprop("autopilot/route-manager/current-wp");
var alt_curr_wp = getprop("autopilot/route-manager/route/wp["~wp_curr~"]/altitude-ft");
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: Route manager current waypoint altitude

Postby Octal450 » Sat Feb 25, 2017 3:33 am

Ahh perfect tikibar!

Thanks for much!

Josh
Last edited by Octal450 on Sat Feb 25, 2017 5:42 pm, edited 1 time in total.
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Route manager current waypoint altitude

Postby zakalawe » Sat Feb 25, 2017 4:43 pm

Please use Nasal API access functions to access this, not the property tree. This is much more efficient than constructing the property path.
zakalawe
 
Posts: 1152
Joined: Sat Jul 19, 2008 4:48 pm
Location: Edinburgh, Scotland
Callsign: G-ZKLW
Version: next
OS: Mac

Re: Route manager current waypoint altitude

Postby Hooray » Sat Feb 25, 2017 4:58 pm

zakalawe wrote in Sat Feb 25, 2017 4:43 pm:Please use Nasal API access functions to access this, not the property tree. This is much more efficient than constructing the property path.

The last comment isn't necessarily quite correct in the case of the posted snippet, because string concatenation in Nasal space can be avoided by using indexed getprop calls, which ultimately means fewer Nasal operands on the opcode stack (and context switches) than doing a C extension API call to query the navcache, e.g. consider using this:

Code: Select all
var alt_curr_wp = getprop("autopilot/route-manager/route/wp",wp_curr,"altitude-ft");


For details, see: http://wiki.flightgear.org/Nasal_library#getprop.28.29

Note: This was implemented by Philosopher a few years ago and committed by Zakalawe.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11340
Joined: Tue Mar 25, 2008 8:40 am

Re: Route manager current waypoint altitude

Postby Octal450 » Sat Feb 25, 2017 5:42 pm

Noted.

Compatibility isn't an issue since ITAF is support in FGFS versions 2016.1.1 and later only. (It could work in earlier, but I don't provide support/help/instructions).

Thanks,
Josh
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: No registered users and 1 guest