I am looking to create a script that does the following: Arm my quadcopter then hover at 1m altitude, hover in place, rotate slowly in yaw, then descend. Since this will be indoors, I can’t use GPS and have so far been not using a compass.
I’m running my scripts from a companion pi zero w on the drone itself through pymavlink which is connected through a UART connection.
Here’s some context:
Root issue: EKF stuck in CONST_POS_MODE, POS_HORIZ_REL never set
In Mission Planner’s Flight Data > Status tab ekfflag is always = 167
Hard-rejected at arm time: “AHRS: EK3 sources require GPS”
GSF bootstraps from GPS velocity changes — dead end without GPS
RNGFND1_GNDCLEAR=2
Matched to actual ground reading (was 10, sensor reads 2cm)
No effect on EKF flags
EK3_SRC1_YAW=6 (ExternalNav / VisualOdom)
FC error: “AHRS: EK3 sources require VisualOdom”
Attempted to satisfy this by sending VISION_POSITION_DELTA (ardupilotmega dialect),
ATT_POS_MOCAP, and VISION_POSITION_ESTIMATE from the Pi — all ignored/rejected
Root cause: VISO_TYPE param does not exist on this firmware build — the VisualOdom
subsystem is not compiled in. EK3_SRC1_YAW=6 is entirely unavailable.
EK3_SRC1_YAW=0 (None)
“Need Position Estimate” — same as YAW=1
EKF has no heading at all, can’t fuse optical flow into position estimate
I’m running out of ideas to try, I’ve tried the ideas on this post but it seems that the ekfflag = 167 doesn’t change when I lift up the drone manually.
EK3_SRC1_POSZ=2 is wrong unless you can guarantee that the overflown surface is absolutely flat. Using surface tracking with baro set as POSZ source is the recommended way.
ARMING_CHECK=0 is rarely the correct choice, and this is not one of those cases, your drone should work with ARMING_CHECK=1. You need fully calibrated and compensated compass for optical flow navigation.
For OF navigation to work to work you need.
Healthy optical flow, the sensor must report sufficiently high quality score.
Healthy rangefinder, present and reporting range within configured limits.
EKF origin externally set.
EKF configured to use optical flow as velocity source.
Yes, I’ve already tried setting it both manually and with pymavlink: send_gps_global_origin_send(). With the pymavlink the FC reports back “EKF3 IMU0 origin set”; hasn’t worked with either
I tried setting EK3_SRC1_POSZ=1 to use Baro, but still hasn’t changed.
Also tried with ARMING_CHECK=1 and the FC error changes from “Need Position Estimate” to “AHRS: waiting for home”; looking into that now.
For your comments on OF navigation:
There is healthy optical flow, Flight Data > Status > opt_qua reports >110
Healthy rangefinder: I test by holding drone sensor over my desk viewing down and reported range matches a physical tape measurer, and I can put my finger under the sensor and the reported values change back to 2cm.
EKF Origin has been set, see my comments above
EKF_SRC1_VELXY is set to 5, where the options show “OpticalFlow”
You need fully calibrated and compensated compass for optical flow navigation.
I’m curious about this, I was under the impression I wouldn’t need a compass for optical nav? I had read that there could be strong interference when flying inside and was opting not to use one.
Setting the EKF origin point via right-clicking on the map in Mission Planner indeed works (I have used it many times in indoor missions with only MTF-01 (no companion)). The sign that shows it is working is that the drone icon appears immediately on map.
Two points here, 1. for builds without GPS / compasses how do they provide yaw data?
I have been spoofing the yaw data with the below function, iirc this got past an error but didn’t allow flight. I can run this again later and provide logs
def send_vision_position_estimate(master, yaw=0.0): “”" This is for spoofing the yaw value for EKF. Send VISION_POSITION_DELTA (ardupilotmega dialect) — the incremental odometry message that ArduPilot’s VisualOdom subsystem (EK3_SRC1_YAW=6) actually uses. We send zero deltas with a fixed yaw, giving the EKF a heading reference. “”" usec = int(time.time() * 1e6) & 0xFFFFFFFFFFFFFFFF master.mav.vision_position_delta_send( usec, 50000, # time_delta_usec (50ms) [0.0, 0.0, yaw], # angle_delta [roll, pitch, yaw] radians [0.0, 0.0, 0.0], # position_delta [x, y, z] meters 50.0 # confidence (0-100) )
I have confirmed that the drone icon appears on my map from both right clicking and from function call but this still has no flight. Note that my ekfflag in the Flight Data page continues to read 167, still blocked by CONST_POS_MODE
I can post some sample logs in a bit, but here’s the script I’m running hover-v3.py