In 4.3.7 (yes I know it’s old, I can’t update it just yet)
Looking to understand how the craft determines “Not Landed” when using sticks to throttle up in Alt Hold. I have an event in my log labeled “Not Landed” and the only place it appears to come from is if Copter::set_land_complete is called with False, and the only callsite I can find for that when using AltHod is in land_detector.cpp here, which comes with the caveat that “this shouldn’t happen because takeoff detection should be done by the flight mode”.
In stabilize, this is determined by simply checking if the motors are spinning above some minimum level. In Alt Hold however I can’t find an explicit check.
I am trying to walk through the code to see what would happen when the user arms the craft in alt hold, then raises the throttle stick to take off (and NOT a GCS Takeoff command). After arming and while on the ground, we should hit the AltHold_Landed_Pre_Takeoff state first. All the while, the position controller for Z is updating with the pilot’s input and I suppose is starting to drive the motors higher. I don’t see where alt hold eventually detects that the craft is in the air.
My ultimate problem is that some state estimation error is tricking the system into thinking that it is no longer on the ground and turning on the integrators when in fact we haven’t lifted off yet. The first smoking gun was that ground effects were spiking the baro which coincided with “Not Landed” in the log while we were still clearly on the ground, and the baro-primary altitude was tricking the altitude controller into spinning the motors up and down. Changing the primary altitude source to GPS fixed the throttle control, but “Not Landed” is still triggering early. We’ve worked around the Roll/Pitch I term buildup on the ground by taking off faster for now. Attached are examples
I was looking into adding a rangefinder to see if that would help provide a clean trigger for “taken off”, but it doesn’t look like the rangefinder detection adds much.