Display Distance wheels encoder

OK, I had some time to test this morning

First just make sure that your file extension is ending with “.lua” because under Windows, the texte editor has a tendency to add .txt at the end

Second , I experienced an issue with the lat lng alt format on the example, I kept getting

number has no integer representation

I placed my EKF ORIGIN manually and cut&paste the numbers from Mission Planner and it works OK
Here is the line I changed with my coordinate … Coliseum @ Québec City :wink:
location = Location() location:lat(4.682895e+08) location:lng(-7.125028e+08) location:alt(-78.0)

@ppoirier, are you sure you were using 4.1 firmware? I’m almost certain that the script will not work unless 4.2 is in use (as tested on actual Cube Orange hardware).

I dont think I ever mention what release, anyway I am running Master

Given the frustration already expressed by the OP so far, it’s probably not wise for him to update his autopilot to the master branch right now. The script will not work on his autopilot running 4.1.2.

Well, well depends how bad he need it
So yes , good catch Yuri, it probably require 4.2

1 Like

I read your last comments and very much appreciate the attention you paid to my requests and I also wanted to thank you for the work you do in the community.
I will take into account @ppoirier’s remarks
and those of Yuri. test and retest version 4.2 and earlier and see if it works and what benefit I can get from it. I will tell you all that in my next message. thank you again very much

and yes Yuri, it’s a purple cube. i tell orange but it was wrong, the firmware is ok purple. :+1:

@ppoirier and @Yuri_Rage sorry but with firmware 4.2


not work no more… :roll_eyes:

What do you mean ? I see it started
When flashing a new load you may have to recalibrate but for the rest it should be business as usual.

Keep trying, you are on the learning curve… :wink:

sorry bad translation: 4.2 works but
with version 4.2 the scripts home point or origin don t start. Yes Extension is .lua no .txt
i reboot FC after modifs yet.
morever, in 4.2 if i set origin manually the location displayed but when i turn wheels the distances don’ t move, stay fixed. with version 4.1.2 if manually set origin (right clic map, set home home here…) all is OK.

Add this to the script:

function update ()

if not ahrs:initialised() then
    return update, 5000
end

gcs:send_text(0, "STARTING SCRIPT EKF ORIGIN ")

origin = assert(not ahrs:get_origin(),"Refused to set EKF origin - already set")

It should appears on Message when -IF - starting.

As for the wheel encoders, the method has changed for the GPIO assignment …you need to set SERVOn_FUNCTION to -1 on the encoders channels.

P.S. J’ai toujours dit que la technologie c’est un paquet de conneries mais l’important c’est de toutes les connaitres !! :slight_smile:

it s seems same thing with script: NOK message and NOK origine SET
i m not sure understand : SERVOn_FUNCTION to -1
my encoder is in 55 (pin B) and 54 (pinnA) AUX 6 and 5

when i have a look for my servos, only SERVO1_FUNCTION is on 55 but anyone on 54.
i have to set -1 in serv01 only ? it is that ?

– example script for using “set_origin()”" and “initialised()”

– sets the ekf origin if not already set

function update ()

if not ahrs:initialised() then

    return update, 5000

end



gcs:send_text(0,"STARTING SCRIPT EKF ORIGIN")

origin = assert(not ahrs:get_origin(),"Refused to set EKF origin - already set")

location = Location() location:lat(4.682895e+08) location:lng(-7.125028e+08) location:alt(-78.0)



if ahrs:set_origin(location) then

    gcs:send_text(0, string.format("Origin Set - Lat:%.7f Long:%.7f Alt:%.1f", location:lat()/10000000, location:lng()/10000000, location:alt()/100))

else

    gcs:send_text(0, "Refused to set EKF origin")

end

return

end

return update()


@ppoirier

Holala… The purple just expose 8 GPIO… I’ll have to double check on the hdw define,

But it was working before == Assign to parameters on the pins where you were connected on 4.1 and assign -1 to the corresponding servoN

yes i understand, my encoder is in 55 et 54 aux but as i tell you SERVO1 was set 55 ( i set -1)but no servo in 54 …?
what can i do to 54 ?

perhaps an idea : if i install one GPS , do you think Origin will be set ?