I have two rangefinders facing downward and want to process the readings of both. I have a LUA script that does that already properly. I get a new distance “newDistance”, which I am sending the the GCS and tested during flight without issues. However, I cannot seem to get the drone/EKF to use this data.
How do I inject/overwrite the rangefinder reading that the EKF uses for low altitude control?
Reading works with
local rf_l = (backend_l and backend_l:distance()) or 0
local rf_r = (backend_r and backend_r:distance()) or 0
Injection does not, I am trying ”backend_l:set_distance(newDistance)” to overwrite the first rangefinder reading, which the EKF uses by default (only the first rangefinder) to no avail.
Best of my knowledge, you’ll need to make all downward facing rangefinder instances scripted, do all the processing in your script, and set the distance once (on instance 0) at the end of the processing period. To my knowledge, we don’t fuse multiple same-facing rangefinders in the EKF (I have not confirmed this with code review, but your observation seems to back this up).