Altitude Mode

Hello all,

I’m looking at the page below for the altitude mode.
https://docs.px4.io/v1.9.0/en/flight_modes/altitude_mc.html
I would like to understand the details of how the altitude mode works for quadcopter and have some questions.

Question 1:
The quadcopter has the pixhawk 4 and does not have GPS and other extra sensors.
For that case, the altiude mode uses the barometer and accelerometer inside of the Pixhawk 4?

Question 2:
Are the barometer and accelerometer enough to hold the altitude without fluctuations?

Question 3:
Is my understanding below correct?
The throttle stick controls rate of ascend/descend [m/s].
With the settings below, the vertical velocity is correct for the throttle stick position?

Settings:
Maximum vertical ascent velocity. Default: 3 m/s.
Maximum vertical descent velocity. Default: 1 m/s.

Throttle Position & Vertical Velocity:
Throttle stick is at 25%. ⇒ Vertical descent velocity of 0.5 m/s is set.
Throttle stick is at 50%. ⇒ Vertical descent velocity of 0 m/s is set. (holding the altitude)
Throttle stick is at 75%. ⇒ Vertical asscent velocity of 1.5 m/s is set.

Question 4:
Where could I find the codes for the altitude mode logic?

Not an expert, but here goes.

Yes.

Yes.
Generally you can hold vertical position fairly well - barometer is almost always used for calculating altitude. However note that since barometers calculate altitude from pressure, anything that affects the pressure can affect the estimate (e.g. bad weather). The estimator attempts to fuse the accelerometer data to compensate for this. An example of a problem case: https://docs.px4.io/master/en/advanced_config/static_pressure_buildup.html

Nearly. There is a deadzone at 50% (see docs). This is a zone in which moving the sticks up or down doesn’t change the altitude. In the zone, yes, the vertical velocity is zero. What this zone means though is that the “half way” positions might not be at 75 and 25% as you have indicated.
Also the velocity isn’t halved at the “half way points” - it is reversed. So at 0 it will be 3/ms down, and at 100% it will be 3m/s up.

I’m guessing here: https://github.com/PX4/Firmware/blob/master/src/lib/flight_tasks/tasks/ManualAltitude/FlightTaskManualAltitude.cpp

@bresch Anything I got wrong?

@hamishwillee It’s all correct, you learned your lessons pretty well! :smiley:

One thing to add is that the actual logic is a combination of several “Flight tasks” (i.e.: setpoint generator):
The altitude setpoint generator is FlightTaskManualAltitudeSmoothVel and inherits from FlightTaskManualAltitude that inherits from FlightTaskManual.
The “FlightTaskAltitudeSmoothVel” uses a library to generate smooth vertical setpoints (jerk-limited). The interface class is https://github.com/PX4/Firmware/blob/master/src/lib/flight_tasks/tasks/Utility/ManualVelocitySmoothingZ.cpp and uses a time-optimal jerk-limited trajectory generator.

1 Like

Thank you very much for your response. I really appreciate it.

Do you know the range of the deadzone? The document says “the vehicle will take off if the throttle stick is raised above 62.5% percent (of the full range from bottom).” (https://docs.px4.io/v1.9.0/en/flight_modes/altitude_mc.html)
So, I’m guessing the deadzone is somewhere below 50% to 62.5%.

It seems that the link is broken. Could you update the link?

Search for RCX_DZ in https://docs.px4.io/v1.9.0/en/flight_modes/altitude_mc.html

It is a range in us around the centre of the specified channel used for throttle.

I don’t know what that corresponds to on a “normal” stick but I’d guess you might be about right on your guess.

Thank you very much for your response. By the way, what does “us” for the unit stand for? Sorry, I could not find the definition.

Us is for Microseconds

Thank you very much. I understand it now.