Land detection logic documentation appears inconsistent with source code

I’m trying to determine the minimum landing descent speed allowed without risking the chance of disarming in the sky. The Land documentation here:
http://ardupilot.org/copter/docs/land-mode.html

claims:

“Copter will recognise that it has landed if the motors are at minimum but it’s climb rate remains between -20cm/s and +20cm/s for one second. It does not use the altitude to decide whether to shut off the motors except that the copter must also be below 10m above the home altitude.”

but it appears that 100 cm/s is used in the source code:

to determine the lower threshold on descent speed for landing detection.

Should the source code logic be set to 20 cm/s or should the documentation be 100 cm/s? The default landing speed is 50 cm/s so 100 cm/s is too high.
I realize that there are other parameters such as the throttle setting that will likely dominate the logic, but why use a landing speed that is higher than the default and reasonable landing speeds? I have my copter set to 25 cm/s right now for instance.

Is there other code that uses the 20 cm/s value for land detection that I’m missing?

Think about that. Does your copter hover or slowly descend with the throttle at minimum? It’s in impossible scenario. In such a very slow descent, the throttle will be only a hair below hover power.

It does appear you’ve found a conflict between documentation and code though.

I realize that, but why use a landing speed threshold that is a valid descent speed? Is there that much slop in the vertical speed measurements when the copter is on the ground that requires a 1 m/s threshold?

There are situations where the throttle logic will fail as well where the hover setting has been set too high. Having a realistic descent speed when on the ground would prevent the copter from powering off in flight when the hover power setting was set way too high (like with a highly overpowered copter). I realize that the automatic hover power learn parameter can eliminate this scenarios, but it can be disabled.

I think you’re misunderstanding the logic. It is only looking for that descent speed when the motors are at minimum throttle. It is impossible for the copter to be descending at such a rate AND have the throttle at minimum. It isn’t one or the other. There is no problem with it, other than not matching the documentation.

My comments were based on the comment in the code here:


Maybe that comment is invalid as well.

Nonetheless, why use 1 m/s descent speed?

You’re reading one variable definition. That isn’t what makes the decision for the landing detector. Keep reading down, where it checks if ALL of those conditions are true, not just any one of them.

As for why that value was chosen, @rmackay9 could speak factually. But I’m sure it was after analyzing performance and determining what will make the landing detector most reliable. The impacts and vibrations that often occur on landing could easily fool a smaller value and prevent landing detection.