It seems that pitch angle is not directly commanded in Loiter, but computed from target speed. Is there a way to command a fixed pitch angle? I’ve asked this before, but just want to make sure no such mode exists before trying to write a custom mode. PosHold seems to honor commanded pitch angle, but only applies it as an offset for some reason, e.g. if there is wind causing the craft to pitch ‘x’ degrees to hold position, applying the commanded pitch ‘y’ results in pitch x + y.
I’m pretty sure you’ll need to write a custom flight mode to get the result you want. You requirements are very unique.
ok. i thought this would be a common requirement. ‘fly at x pitch’. its a really simple prompt. i know the autopilot can hold to a max pitch pretty well, flying with loiter.
Actually, I think Stabilize is good enough. Set ANGLE_MAX and focus on adjusting throttle.
I think Sport mode used to operate like that, but it was dropped because no one ever used it.
You should be able to find its code in gihub, a few versions back, maybe around 3.6 or earlier.
I found that AltHold works well, and is easier to control than Stabilize. Surprisingly, AltHold seems to fly smoother than Loiter. I think its because, especially in windy conditions, I cant get the copter to always fly at the target velocity, so it is constantly trying to mix forward acceleration into the thrust update. I think there are fewer current spikes in AltHold vs. Loiter as well for the same reason.
The advantage with Loiter is that the copter does not get pushed around by the wind, whereas I have to manually compensate in AltHold. However, I prefer smoother forward flight, so I will be using AltHold going forward instead of Loiter.
By the way, how is Yaw control different between the two modes? My understanding is Loiter tries to maintain heading and will expend considerable energy to do so, until a “Yaw Reset” event if unsuccessful after some time. AltHold will try to maintain yaw rate according to pilot input. If it is externally disturbed in yaw, I assume it will try to achieve 0 yaw rate, but not try to maintain heading (yaw angle)? I will try to look through the controller source (update_flight_mode / ModeStabilize) for these answers as well.