(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.