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: Redirecting to latest version of document (main)

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).” (Altitude (MC) · PX4 v1.9.0 User Guide)
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.

I am aware that this thread is long closed, but I had a few questions that may be relative to my situation.

The vertical ascent is set to a default of 3m/s then is this only achieved if the throttle stick is at 100%?
I am having issues in my missions where the drone is not ascending nearly fast enough to reach the desired altitude. It seems to put a preference and ground speed over all else and is messing up with my LiDAR missions.

Can I impact its ability to climb at these velocities by changing an acceleration value? Is there a more simple solution that places weight on altitude vs speed so the drone will adjust its speed to reach the desired waypoint`s altitude?

Please create a new issue. This answer is for a specific question about a specific mode on PX4 v1.9 - unless you’re working on that same mode and close to that same version it is better to ask a new question and cross link if you think this question is relevant.