GPS Distance Trip Find Return Home Lua Script

RCdiy

RCdiy
http://rcdiy.ca/gps-directions-home/
https://www.youtube.com/watch?v=Cb7SlKAHbFU


This GPS script was published last year. A viewer requested that the script be updated to use an optional second GPS sensors. One on the aircraft and another in the transmitter. This allows a pilot who does cross country flying to have directions relative to their current position instead of relative to the flying field.

The script has also been updated to
- use optional altitude and speed sensors,
- use the smaller screen of the Taranis Q X7,
- draw arrows instead on using images which has resulted in fewer files,
- announce in german using the supplied files

Check out the blog post and video.

Stay Safe & Have Fun
 

FransH

New member
Receive Bad script error

Unfortunately I receive a bad script error when I try to start the page.
If I open the script with Notepad, it says some items will be lost when saving.
So I tried to open and save it it in Word and I also receive the same message.
In what Text format should I save?
When I open the file in Notepad, it looks quite normal.
What to do?
Thanks in advance
Frans
 

RCdiy

RCdiy
Also, which version of OpenTX are you on?
You need to be on 2.2.0 or later...
The script is a plain text file... GPS2.lua
 

FransH

New member
I was running 2.1.9.
I installed 2.2 now and everything seems fine now!
Thx for the quick response
Frans
 

RCdiy

RCdiy
Hi, remember me. I have only been able to try this on a couple of occasions. Basically I fly it in a known direction away from me and hit the switch to get the instructions on which way to turn, to get back. Two problems.


When I hit the switch , I get all the other reports first, height, speed, distance etc,, then the turn command. This takes so long that I have usually had to turn before I get this far. Then the turn instruction that I get never seems correct.



Now this could all be down to me, but can you help me with this.


1/ The voice reports are set to operate from the two position switch on the left. (F maybe), Can I change the Lua script so that I can operate the turn back command from Logical switch xx, and all the others from Logical switch yy. If this can be done, how would I edit the script to do this.


2/ I read on RC forums the other day, a guy saying that the FRsky GPS module had a 10 second latency. Is this true, as this would surely effect the information I am getting from the Lua script.


3/ Any other thoughts that you may have, much appreciated.



To wrap your head around the turn instructions this video may help.https://youtu.be/Cb7SlKAHbFU?t=31s
The key is to make small adjustments. Gentle turns. Stop turn. Listen. Repeat.




Use ls1 ls2 etc.


Change this to a lower value
local AnnounceAircraftReturnHomeTurnsSeconds = 15


10s delay? I don’t know and since I can’t control that won’t be bothered by it.


The fact is that one person has reported back that they were able to use the script to recover an aircraft when they lost sight of it. Got it to fly back to them.


If you have a “good friend” get them to walk out into a field with your Rx and GPS and mimic a flight.
I used Companion’s simulator to figure out if the turns were correct.
 

BarryCole

New member
My memory is failing...

When I try to run the Lua script, I get a low memory warning...
Memory says 18183 bytes free.

How much memory do I need??

Taranis Plus. OTX 2.2.1

Thanks for your help BC

Update:- I have removed nearly all the models from the memory, now have 28397 bytes free.
Still getting the low memory warning....

Update-2:- I tried with a Taranis (NotPlus) Got the same memory warning.
Both these Taranii are running OTX 2.2.1, I flashed the Taranis back to 2.2.0, and the lua script starts to run, but then I get Script Syntax Error.
 
Last edited:

RCdiy

RCdiy
Appreciate your enthusiasm but don't keep changing things. Report the problem and please wait....
I check/update my code based on the current OpenTX release.
We are now on 2.2.1. I will have to test on this version again and get back to you.
 

RCdiy

RCdiy
View attachment GPS2.lua.zip
Thanks for your feedback... I now know the cause of the syntax error... when there is no GPS lock one of the variables is a nil value causing the syntax error... I believe I fixed the syntax error.... I have an over cast day with thick clouds, my GPS is not getting a lock so can't test further....
I did manage to reduce memory use slightly...

Please try the attached file and report back...
If you get a syntax error please let me know the line number...
 
Last edited:

RCdiy

RCdiy
X7 2.2.1 works
X9D 2.2.0 works
X9D+ 2.2.1 Script panic, not enough memory

I'm following up with the OTX developers
 

BarryCole

New member
OK Rav, thanks.

FYI, I ran it on my X9D Notplus, and I still get the Syntax error message. There is no line number, and if you ignore that, it seems to work OK.

Hope that helps.

BC
 

RCdiy

RCdiy
Barry, I'm told
- x7 has more ram available for the lua because of the smaller screen
- 2.2.1 has less RAM for lua compared to 2.2.0

Trying to get some help on this....
FYI
https://www.rcgroups.com/forums/showthread.php?2180477-LUA-scripting-Technical-discussion/page164

My options are
- figure out how to optimize the code to use less memory
- remove support for 2 GPS and go back to a single GPS
 

RCdiy

RCdiy
OK Rav, thanks.

FYI, I ran it on my X9D Notplus, and I still get the Syntax error message. There is no line number, and if you ignore that, it seems to work OK.

Hope that helps.

BC

Are you sure it was the new script I gave you?
 

RCdiy

RCdiy
Try this.
Companion > Run > GPS2.lua
A GPS2.luac file will be created.
Rename GPS2.luac GPS2c.lua

On the TX
Delete existing GPS2.lua and GPS2.luac (if it exists)
Place GPS2c.lua on the Tx
Configure it to run using the DISPLAY screen.

Let me know if this works. It did for me.
 

BarryCole

New member
Rav,
Thanks for that. I will try it over the next couple of days.

I am not sure that I understand it at present, but I will see what I an do.

BC

EDIT:- No sorry I fell at the first hurdle. Can you explain "Companion > Run > GPS2.lua"
 
Last edited: