(Yes, I did have the wind calibration script running, but I’ve removed that in case somehow that was causing the issue. It wasn’t)
The only edit I made to either script was to change from switch 1 (300) to switch 2 (301).
-- get rangefinder distance
local rngfnd_distance_m = 0
if rangefinder:has_data_orient(rangefinder_rotation) then
rngfnd_distance_m = rangefinder:distance_orient(rangefinder_rotation) -- this is line 124
end
local rngfnd_over_threshold = (rngfnd_distance_m == 0) or (rngfnd_distance_m > rangefinder_thresh_dist)
Just been playing with this some more and have more info, but still no solution:
When I power the drone with USB the script works as advertised, however there is also an error that there’s no range finder data.
Once I plug in battery power the script returns to the error I mentioned above. It doesn’t seem to matter what order I apply power it’s the same. Script works with USB power (but no range finder data). Script doesn’t work on Battery (range finder working).
I’ve just tried running the script rangefinder_test.lua. I get the GCS message that I have one rangefinder. But then I get the same Nil value errors when it tries to return any data about the range finder. (line 22…)
I’ve also tried a boot delay on the board of 3 seconds. No joy.
Ranger finder and optical flow both work. Surface track works. All good until I try the script ahrs_source_gps_optflow.lua
These lines:
local rngfnd_distance_m = 0
if rangefinder:has_data_orient(rangefinder_rotation) then
rngfnd_distance_m = rangefinder:distance_orient(rangefinder_rotation)
end
This error
Lua: /APM/scripts/ahrs-source-gps-optflow.lua:125: attempt to call a nil value (method 'distance_orient')
@Yuri_Rage , sorry to call you in but I’m stuck. Tried nothing and I’m all out of ideas.
Thanks! Only had a second to test it, but that seemed to do the trick.
I’ve just take the scripts from the AP libraries on Github, I’m not smart enough to write my own. Does that mean there is an error in these scripts or are they updated based on the dev version, not beta or stable?