Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Horus] Reading internal GPS via LUA Script #5112

Closed
labeh opened this issue Jul 24, 2017 · 13 comments
Closed

[Horus] Reading internal GPS via LUA Script #5112

labeh opened this issue Jul 24, 2017 · 13 comments

Comments

@labeh
Copy link

labeh commented Jul 24, 2017

I like to read the internal GPS from the Horus via LUA Script to implement a Widget which can show me the distance between model (is also equipped with a GPS) and pilot.

For this widget I need access to the internal GPS from the Horus via LUA. Currently I did much research including reading much opentx code but did not find any suggestion how the internal gps is available. Could anybody help me please?

@schwabe
Copy link
Member

schwabe commented Jul 24, 2017

Currently the internal GPS is not supported very well. You cannot it from lua or other telemetry. Search for INTERNAL_GPS and gpsData to see what is implemented so far.

Making this available via lua should be easy but the question is rather if the internal GPS should available as normal telemetry source.

@labeh
Copy link
Author

labeh commented Jul 24, 2017

I have done that already. But I sadly don't know enough about the rest of the code to do a quick fix and provide it by a pull request. It is not obvious for me how the data comes to the Lua Scripts. Maybe there should be a LUA_EXPORT(...) expression added in https://github.com/opentx/opentx/blob/cd23fedb56e85945455474d4e52d709740c0a114/radio/src/dataconstants.h ? But this can't be enough?

@schwabe
Copy link
Member

schwabe commented Jul 24, 2017

probably not.

As a quick hack, this might work, after the internal GPS position should available as telemetry value:

diff --git a/radio/src/gps.cpp b/radio/src/gps.cpp
index 5a62fb5ac..9b10694a5 100644
--- a/radio/src/gps.cpp
+++ b/radio/src/gps.cpp
@@ -265,6 +265,8 @@ bool gpsNewFrameNMEA(char c)
                 gpsData.altitude = gps_Msg.altitude;
                 __enable_irq();
               }
+              setTelemetryValue(TELEM_PROTO_FRSKY_SPORT, GPS_ID, 1, 0, gpsData.latitude, UNIT_GPS_LATITUDE, 0);
+              setTelemetryValue(TELEM_PROTO_FRSKY_SPORT, GPS_ID, 1, 0, gpsData.longitude, UNIT_GPS_LONGITUDE, 0);
               break;
             case FRAME_RMC:
               gpsData.speed = gps_Msg.speed;

@3djc
Copy link
Contributor

3djc commented Jul 25, 2017

Yeah, GPS and lua need some love, I had a few things ready (like disatnce computation for lua), need to do some code archeology :D

@projectkk2glider
Copy link
Member

Should be easy:

  • export MIXSRC_TX_GPS to lua with LUA_EXPORT() macro
  • write custom handler in luaGetValueAndPush() for that source.

@1Sven
Copy link

1Sven commented Jul 27, 2017

Perfect idea, the position and acceleration sensors are also essential. Then you can finally create a follow me mode.

@WimSanders
Copy link

I would be already very happy if I can display the internal GPS.
So if the can make as an selectable sensor in the telemetry menu it would be great.
If it’s only to find back a lost model

@3djc
Copy link
Contributor

3djc commented Mar 7, 2018

All that is available

Was done in #5610

@3djc 3djc closed this as completed Mar 7, 2018
@WimSanders
Copy link

WimSanders commented Mar 7, 2018 via email

@3djc
Copy link
Contributor

3djc commented Mar 7, 2018

You do not. You have been able to display internal sensor on widgets since 2.2.0 without any lua knowledge.

Create a sensor display widget and select the internal GPS, it is available as a source

@WimSanders
Copy link

WimSanders commented Mar 7, 2018 via email

@3djc
Copy link
Contributor

3djc commented Mar 7, 2018

Either the radio could not get a fix (very cloudy, obstacles,...) or your internal gps is defective, because it does work

@WimSanders
Copy link

WimSanders commented Mar 7, 2018 via email

@kilrah kilrah modified the milestones: OpenTX 2.2.X, OpenTX 2.2.2 Mar 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants