I’m using an indoor drone setup with:
-
Optical flow sensor for horizontal position
-
Downward-facing rangefinder for altitude hold
-
No GPS (GPS-denied environment)
-
SpeedyBee F4V5 flight controller
What works:
-
In Loiter mode, the drone maintains altitude perfectly using the rangefinder.
-
Log analysis shows
CTUN.DSAlt(desired rangefinder altitude) properly tracksCTUN.SAlt, and the drone responds as expected.
The problem:
When I switch from Loiter to Guided mode (for velocity commands via MAVLink SET_POSITION_TARGET_LOCAL_NED), the rangefinder altitude is no longer used for the altitude target.
-
CTUN.DSAltdata stops appearing in logs -
CTUN.DAltremains constant at the barometer altitude at the moment of mode switch -
The drone’s altitude becomes barometer-dependent, which drifts significantly indoors due to prop wash and temperature changes
I’ve verified:
-
EK3_SRC1_POSZis set to1(Barometer) -
EK3_RNG_USE_HGTis-1 -
SURFTRAK_MODEis enabled -
Rangefinder works perfectly in Loiter mode
Question:
Is there a way to make Guided mode respect the rangefinder altitude target (like Loiter does via Surface Tracking), or is this an intentional design limitation? I need precise altitude hold while sending velocity commands in Guided mode.
I’m using ArduPilot Copter 4.8
What I’ve tried:
-
Verified rangefinder works in Loiter/AltHold
-
Confirmed
CTUN.DSAltlogging stops immediately upon Guided mode entry -
Checked that Surface Tracking is correctly configured
Why this matters:
Barometer drift indoors makes altitude unreliable. The rangefinder provides accurate ground distance, which is critical for my application.
Update: I’ve also attached a log snippet showing CTUN.DSAlt dropping to zero/stopping after mode change.
The log file: https://drive.google.com/file/d/1GkvsRbodb6JihvcDygZ8UYeC25fADHLL/view?usp=sharing