plane icon Welcome to Microsoft Flight Simulator’s SDK Q&A Platform!

You have questions regarding the SDK? DevMode Tools? SimConnect? You would like to submit an idea for future improvements, seek help or exchange knowledge? You’re in the right place.


Please take a moment to read the platform’s guidelines before you get started!


question

sonicviz avatar image
sonicviz asked FlyingRaccoon commented

Do all Altitude SimVar's work correctly, and is the documentation on them correct?

ref: https://docs.flightsimulator.com/html/Programming_Tools/SimVars/Aircraft_SimVars/Aircraft_Misc_Variables.htm

Context: Using js html_ui\JS\simvar.js

The referenced link above says all three Simvars are settable in ft, but from my testing it appears PLANE ALTITUDE is working in metres, not feet. I'm also not sure if the two AGL ones work properly. Could you please confirm if this is so? Thanks!

  • PLANE ALTITUDE
  • PLANE ALT ABOVE GROUND
  • PLANE ALT ABOVE GROUND MINUS CG

CC @FlyingRaccoon



simconnectdocumentation
1 comment
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Flysimware avatar image Flysimware commented ·

Yes these work.

Do you use the Simvars? You can easily check all variables using this tool.

Also make sure your sim is setup to use feet not meters if testing in sim by setting US system. See images.

screenshot-15.jpgscreenshot-16.jpg


0 Likes 0 ·
screenshot-15.jpg (133.2 KiB)
FlyingRaccoon avatar image
FlyingRaccoon answered FlyingRaccoon edited

Hello @sonicviz

PLANE ALTITUDE is settable in feet (regardless of the selected unit system)
PLANE ALT ABOVE GROUND is only settable through SimConnect.
PLANE ALT ABOVE GROUND MINUS CG is not settable and the documentation will be fixed.
@Nocturne FYI

Regards,
Sylvain

10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

sonicviz avatar image
sonicviz answered

Hi @FlyingRaccoon
Thanks for the confirmation!

10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Flysimware avatar image
Flysimware answered Flysimware edited

Sorry I for some reason looked at the title and in the question itself I missed the settable part. So that was a good question as it looks like the SDK is wrong.

@FlyingRaccoon I tested and found PLANE ALTITUDE worked only. So 2 are wrong. Is that correct?

10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

FlyingRaccoon avatar image
FlyingRaccoon answered

Hello @Flysimware @sonicviz

Ok my bad, in fact PLANE ALT ABOVE GROUND is only writable through SimConnect.
There's a dedicated SimConnect function on server side that processes that writing request and writes to PLANE ALTITUDE based on your input value and GROUND ALTITUDE.

So you are right, in JS, only PLANE ALTITUDE can be written and you have to implement a similar function.

Regards,
Sylvain

10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

sonicviz avatar image
sonicviz answered

@FlyingRaccoon @Flysimware

Thanks. I was about to get back to you on that as I was double checking and just confirmed PLANE ALT ABOVE GROUND in js wasn't working, but you did it for me.


10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

sonicviz avatar image
sonicviz answered FlyingRaccoon commented

Hello @FlyingRaccoon CC @Flysimware

>>PLANE ALTITUDE is settable in feet (regardless of the selected unit system)

I'm still not convinced this is so, as from my testing using simvars.js it is taking the input number as metres then converting it to feet to set the altitude. Here's my test results.

Start Position 1 is the green highlighted row. The saved altitude (and lat/long) are from the locationInfos location.lla object, of which the altitude always is metres (745) but I show the converted feet, which also matches the Altimeter setting:
start.jpg


What I want to do is when the user hits the Go button >>> it will teleport them 1500 ft above the saved ground altitude, in this case 745m or 2475ft. So, 1500ft AGL target.

If I use the following calculation to set the teleport target altitude, converting from m to ft:

//Convert meters to feet and add a height above ground buffer

var teleportAltitude = (params.data.altitude * 3.2808) + 1500; //Metres to feet

//var teleportAltitude = params.data.altitude + (1500 * 0.3048); //Metres + 1500ft buffer

console.log("LM setColumnData() params.data.altitude: " + params.data.altitude + " teleportAltitude: " + teleportAltitude);

Log output is:

[Log] LM setColumnData() params.data.altitude: 754.4590454101562 teleportAltitude: 3975.2292361816408 (LMPanel.js, line 366)


and result teleport is:
feet2.jpg

The result is not 3975 ft but ~13211 ft which is (metres to feet) ~ 3975.22 * 3.2808 = 13041.9018 (Close enough)

If I switch the calculations to use metres:

//Convert meters to feet and add a height above ground buffer

//var teleportAltitude = (params.data.altitude * 3.2808) + 1500; //Metres to feet

var teleportAltitude = params.data.altitude + (1500 * 0.3048); //Metres + 1500ft buffer

console.log("LM setColumnData() params.data.altitude: " + params.data.altitude + " teleportAltitude: " + teleportAltitude);


Log output is:

[Log] LM setColumnData() params.data.altitude: 754.4590454101562 teleportAltitude: 1211.6590454101563 (LMPanel.js, line 366)


and result teleport is:
metre2.jpg

We arrive at ~4247ft which is close to (metres to feet) 1211.65 * 3.2808 = 3975.1813


Test was repeated with another saved location with slightly different saved height. Interestingly this was also Zell Am See but airport save is at 745m but a custom location right beside the airport tarmac sets it to 500m.

Using feet calculation as above as teleport altitude for 1500ft AGL target :

[Log] LM setColumnData() params.data.altitude: 500 teleportAltitude: 3140.4 (LMPanel.js, line 366)


3140 * 3.2808 = 10301.712


feet1a.jpg

Using metre calculation as teleport altitude for 1500ft AGL target:

[Log] LM setColumnData() params.data.altitude: 500 teleportAltitude: 957.2 (LMPanel.js, line 366)



957.2 * 3.2808 = 3,140.3818

metre1a.jpg



Hope that makes sense. My system settings are US imperial, but as you say these calcs should be independant of the system settings.


I'm just trying to clarify exactly what the internal calc does so the docs can be accurate and we can get consistent results. I'm fine with it as metres as well, but if I am right and you want to revert it back to feet I'm fine with that as long as I know, as long as it's going to stay that way. That's a big height difference, and I just want to teleport people in at a nice low "safe enough" VFR height for sightseeing at the selected saved location.


Thanks.


start.jpg (1.0 MiB)
feet2.jpg (600.0 KiB)
metre2.jpg (702.1 KiB)
feet1a.jpg (644.9 KiB)
metre1a.jpg (715.5 KiB)
5 comments
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

FlyingRaccoon avatar image FlyingRaccoon ♦♦ commented ·
How are you writing the PLANE ALTITUDE simvar?

You want to use SetSimVarValue("A:PLANE ALTITUDE","feet",value);

0 Likes 0 ·
sonicviz avatar image sonicviz FlyingRaccoon ♦♦ commented ·

Hey @FlyingRaccoon

>>How are you writing the PLANE ALTITUDE simvar? You want to use SetSimVarValue("A:PLANE ALTITUDE","feet",value);


Aha, there be the issue. I'm using the following, assuming the type field was for field type not unit type. So it looks like if you use anything other than "feet" it defaults to metres, so you can use whichever you like, which is aok too.

SimVar.SetSimVarValue("A:PLANE ALTITUDE", "number", teleportAltitude);


I was using an example of SetSimVarValue as my guide, and my assumption about the 2nd param was wrong. Would be great if there was some short clarification in the docs about this, just to make it clear. (or if there is and I missed it, my bad!)

0 Likes 0 ·
FlyingRaccoon avatar image FlyingRaccoon ♦♦ sonicviz commented ·
The simulation has conversion tables and when converting from number to feet, the input is considered as provided in meters.
1 Like 1 ·
Flysimware avatar image Flysimware commented ·

I forgot to mention this too I also had a feeling if choosing a unit since it's settable it will use that unit value. But I never tested since I forgot. But I too did not believe it was only feet.

So does it only work for feet?

0 Likes 0 ·
sonicviz avatar image sonicviz Flysimware commented ·

It seems to me it will do either, depending what you specify. ie: if not "feet" it will default to metres.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 19.1 MiB each and 23.8 MiB total.