Servers by jDrones

Help unpacking passtrough telemetry data with a LUA script in OpenTX 2.2

(alex) #1

Hi all,
I’m working on a LUA telemetry script but I do not get what I expect by unpacking GPS 0x5002 telemetry frames.
In particular the altitude that I obtain never matches what mission planner shows at the very same time.
I expect the frame to be as prepared by calc_gps_status() and at prep_number() in
I unpack the frame with

numSats = bit32.extract(VALUE,0,4)
gpsStatus = bit32.extract(VALUE,4,2)
gpsHdopC = bit32.extract(VALUE,7,7) * (10^bit32.extract(VALUE,6,1)) – dm
gpsAlt = bit32.extract(VALUE,22,7) * (10^bit32.extract(VALUE,29,2)) – dm
if (bit32.extract(VALUE,31,1) == 1) then
gpsAlt = gpsAlt * -1

I must be missing something obvious…

I’m using copter 3.5.3 on a pixracer

thanks a lot


(Sergey) #2

Do you mean your unpacked value is totally wrong or it differs by a few meters?
Are the numSats and gpsStatus correct?

(alex) #3

Hi Sergey,
I get sat count, hdop and gps fix status as reported by mission planner, but altitude is off.
I’m checking alt and altasl in mission planner, this two values differ as long as there is no gps fix.
Once I get a fix I see in mission planner alt and altasl matching but the value unpacked from telemetry frame is different, what is the gps altitude value that I should compare to in mission planner?
If I unpack the home frame 0x5004 once I get a gps fix the home altitude is exactly as reported by alt and altasl in mission planner, I simply have no idea how to validate what I see.
In the home frame I also have a problem in the home angle which is always unpacked at 0

homeDist = bit32.extract(VALUE,2,10) * (10^bit32.extract(VALUE,0,2))
homeAlt = bit32.extract(VALUE,14,10) * (10^bit32.extract(VALUE,12,2)) * 0.1
homeAngle = bit32.extract(VALUE, 25, 7) * 3


(Luís Vale Gonçalves) #4

Check here

(alex) #5

GPS altitude now working, should have been
gpsAlt = bit32.extract(VALUE,24,7) * (10^bit32.extract(VALUE,22,2)) – dm