Alp Posted December 23, 2020 Report Share Posted December 23, 2020 Hello, I need get altitude (agl). When i trying use 0020 or 0B4C offsets, i could not get any meaningful result. For example: When my airplane was on the ground, result is 85. My app screenshot is https://prnt.sc/w8qh7z . By the way i'm using VB.NET. My code is in the below Private agl As New Offset(Of Short)(&HB4C) Dim aglmttoft = agl.Value() * 3.2808399 Me.AGLDurum.Text = aglmttoft Link to comment Share on other sites More sharing options...
Pete Dowson Posted December 24, 2020 Report Share Posted December 24, 2020 11 hours ago, Alp said: When i trying use 0020 or 0B4C offsets, i could not get any meaningful result. For example: When my airplane was on the ground, result is 85. As documented, those offsets contain the Ground Altitude (above mean sea level), not your AGL! The AGL is the difference between that and your aircraft's altitude. Pete Link to comment Share on other sites More sharing options...
Alp Posted December 24, 2020 Author Report Share Posted December 24, 2020 First of all thank you for your response. Well, how can i get altitude (AGL) ? When i trying search agl offset in the document, i could not found. Link to comment Share on other sites More sharing options...
Paul Henty Posted December 24, 2020 Report Share Posted December 24, 2020 Quote Well, how can i get altitude (AGL) ? Read the aircraft altitude (e.g., offset 6020) then subtract the ground height (e.g. 0B4C). Don't expect 0 when you are on the ground - the altitude is measured from the origin of the aircraft model which is usually in the middle of the aircraft. So it will be a few feet off the ground. You could also try the radio altitude which measures the height above the ground, but I think this might only work at low altitudes as in real life. See offset 31E4. Paul Link to comment Share on other sites More sharing options...
Alp Posted December 25, 2020 Author Report Share Posted December 25, 2020 Firstly thank you for your response but when i tried these offsets, i am getting ridiculous numbers return. how can i fix it? Link to comment Share on other sites More sharing options...
Paul Henty Posted December 25, 2020 Report Share Posted December 25, 2020 The main causes of this are: Declaring an offsets as the wrong type Not converting the values from FSUIPC units to human units correctly. Refer to the FSUIPC Offset list to check the offset types and also to get the conversion formulas (if applicable). If you can't spot the problem, please post your offset declarations and the code where you are using the values. I'll be able to tell you what the exact problem is. I can't really help much without code. Paul Link to comment Share on other sites More sharing options...
Alp Posted January 8, 2021 Author Report Share Posted January 8, 2021 Hello, When i tried to use 0020 offset with this code; Private agl As New Offset(Of UInteger)(&H20) aglStatus.Text = agl.Value() i am getting a constant number like a 12719. And this number did not changing (when airplane is flying) When i tried to use 0B4C offset with this code; Private agl As New Offset(Of UInteger)(&HB4C) aglStatus.Text = agl.Value() i am getting a constant number like a 49. And this number did not changing (when airplane is flying) Link to comment Share on other sites More sharing options...
Pete Dowson Posted January 8, 2021 Report Share Posted January 8, 2021 Neither of those are AGL values, but ground altitudes. Please do refer to the provided offsets list for details of what they contain. Your 12719 is 12719/256 = 49.68 metres. The 0B4C offset is just metres with no fractional part. So at least you are getting consistent results. Try flyng over some hills, or the ocean, and see those values change! For AGL (which means "ABOVE ground level" you need to read your own altitude and do a subtraction. Pete Link to comment Share on other sites More sharing options...
Paul Henty Posted January 8, 2021 Report Share Posted January 8, 2021 In addition to Pete's answer above... 0B4C is only 2 bytes long, so it needs to be declared as Short. (Not UShort because some land is below sea level and therefore the elevation is negative). Private groundElevation As New Offset(Of Short)(&HB4C) 0020 should also be Integer not UInteger. Here is the code with conversion to metres... Private groundElevation As New Offset(Of Integer)(&H20) aglStatus.Text = groundElevation.Value / 256D As I said in a reply above, if you want AGL you need to subtract the ground elevation from the aircraft's current altitude: Quote Read the aircraft altitude (e.g., offset 6020) then subtract the ground height (e.g. 0B4C). Paul Link to comment Share on other sites More sharing options...
Alp Posted January 8, 2021 Author Report Share Posted January 8, 2021 aaaaa i got it. I thought 0020 is giving me directly agl information. When i do msl altitude minus 0020 value; i'm getting real altitude (agl). I tried now and i got a solution. Thank you so much Mr. Dowson. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now