Pr port hf4 hf5 fixes to 4.6.3 - #113
Conversation
* Add thrust vectoring desaturation and halved PID gain parameters (#99) * Fix weathervane control slope based scale calculation error when control effort is between Q_TAILSIT_CE_LO and Q_TAILSIT_CE_HI (#82) * Fix weathervane control slope based scale calculation error when control effort is between Q_TAILSIT_CE_LO and Q_TAILSIT_CE_HI * Pixhawk6C-bdshot/scripts: Add vibration monitoring script and rename autobailout script filename --------- Co-authored-by: akshar-airbound <[email protected]> * Rename ab_autobailout.lua back to autobailout.lua for hf3 (#84) * Update the version to V4.5.7.4 -hf1 * /AP_MotorsTailsitter.cpp:Update the desaturation logic * Update the version to Airbound ArduPlane V4.5.7.5 -rc1 - Controller desaturation * Update version to V4.5.7.4 -hf4 - Controller desaturation * Reset yaw I term when disabling yaw control * Update the angle p gains of roll and yaw axes * Update the version to Airbound ArduPlane V4.5.7.4 -hf4 - Controller desat+ Half gain * Update the fixed wing parameters --------- Co-authored-by: akshar-airbound <[email protected]> Co-authored-by: Mayank Joneja <[email protected]> Co-authored-by: Manuraj P M <[email protected]> * Add function to check tailsitter backtransition in quadplane class Add lua bindings exposing above function for lua scripting * autobailout.lua:Removed debug gcs strings * Changed version to 4.5.7.4-hf3 + new autobailout changed default value of parameter AUTOB_BTRN_DLY to 2500 * autobailout.lua: remove unused variables * quadplane.cpp: add time argument to vtol transition function * autobailout.lua: increase loop rate from 10 to 20 Hz defaults.parm: Change param name TECS_SPD_WEIGHT to TECS_SPDWEIGHT * Changed version name * autobailoout.lua:Renamed variable * Fixed TECS_SYNAIRSPEED 0 -> 1 * Change version name * Reduce weathervane gain during pos1 pos2 repositioning --------- Co-authored-by: akshar-airbound <[email protected]> Co-authored-by: Mayank Joneja <[email protected]> Co-authored-by: Manuraj P M <[email protected]>
Greptile SummaryThis PR backports ArduPlane hotfixes HF4 and HF5 to the 4.6.3 branch, covering tailsitter stability, thrust vectoring, auto-bailout logic, and Pixhawk6C-bdshot tuning parameters.
Confidence Score: 3/5The attitude controller fix in AC_AttitudeControl.cpp is broken as written and should not be merged without correction; the remaining changes are sound. The yaw gyro-passthrough fix writes to the member variable libraries/AC_AttitudeControl/AC_AttitudeControl.cpp — the member-vs-local variable mix-up needs to be corrected before merging. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Lua as autobailout.lua
participant QP as QuadPlane (C++)
participant AC as AC_AttitudeControl
participant Motors as AP_MotorsTailsitter
Note over Lua: update() every 50ms
Lua->>QP: tailsitter_in_vtol_transition()
QP-->>Lua: bool (new binding)
Lua->>QP: in_vtol_mode()
QP-->>Lua: bool
Note over Lua: in_vtol_flight() guards monitoring
alt in_vtol_flight() and armed and delay elapsed
Lua->>Lua: check pitch vs AUTOB_PIT_LIM
alt "pitch bad for > AUTOB_PIT_TOUT ms"
Lua->>QP: vehicle:set_mode(QLOITER)
end
end
Note over QP: vtol_position_controller() QRTL path
QP->>QP: weathervane set_gain(wvane_max_gain/3)
Note over AC: attitude_controller_run_quat()
AC->>AC: compute local ang_vel_body
alt "thrust_error > 2x threshold"
AC->>AC: "_ang_vel_body.z = get_gyro().z [BUG: overwritten]"
AC->>AC: reset_I() on yaw PID
end
AC->>AC: "_ang_vel_body = ang_vel_body [overwrites .z]"
Note over Motors: output_armed_stabilizing()
Motors->>Motors: constrain pitch_thrust
Motors->>Motors: "yaw_headroom = 1 - abs(pitch_thrust)"
Motors->>Motors: limit yaw to headroom, set limit.yaw
Motors->>Motors: "tilt_left/right = pitch +/- yaw_limited"
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Lua as autobailout.lua
participant QP as QuadPlane (C++)
participant AC as AC_AttitudeControl
participant Motors as AP_MotorsTailsitter
Note over Lua: update() every 50ms
Lua->>QP: tailsitter_in_vtol_transition()
QP-->>Lua: bool (new binding)
Lua->>QP: in_vtol_mode()
QP-->>Lua: bool
Note over Lua: in_vtol_flight() guards monitoring
alt in_vtol_flight() and armed and delay elapsed
Lua->>Lua: check pitch vs AUTOB_PIT_LIM
alt "pitch bad for > AUTOB_PIT_TOUT ms"
Lua->>QP: vehicle:set_mode(QLOITER)
end
end
Note over QP: vtol_position_controller() QRTL path
QP->>QP: weathervane set_gain(wvane_max_gain/3)
Note over AC: attitude_controller_run_quat()
AC->>AC: compute local ang_vel_body
alt "thrust_error > 2x threshold"
AC->>AC: "_ang_vel_body.z = get_gyro().z [BUG: overwritten]"
AC->>AC: reset_I() on yaw PID
end
AC->>AC: "_ang_vel_body = ang_vel_body [overwrites .z]"
Note over Motors: output_armed_stabilizing()
Motors->>Motors: constrain pitch_thrust
Motors->>Motors: "yaw_headroom = 1 - abs(pitch_thrust)"
Motors->>Motors: limit yaw to headroom, set limit.yaw
Motors->>Motors: "tilt_left/right = pitch +/- yaw_limited"
Reviews (1): Last reviewed commit: "ported hf4 anf hf5" | Re-trigger Greptile |
| _ang_vel_body.z = _ahrs.get_gyro().z; | ||
| get_rate_yaw_pid().reset_I(); |
There was a problem hiding this comment.
Assignment to member variable is immediately overwritten
The change writes _ang_vel_body.z = _ahrs.get_gyro().z to the member, but line 969 unconditionally does _ang_vel_body = ang_vel_body, which replaces the entire struct — including .z — with the local ang_vel_body that was never updated in this branch. The intended gyro-passthrough for yaw during large thrust errors is silently discarded, so the rate controller receives the error-derived yaw target instead of the raw gyro value. The original code correctly wrote to ang_vel_body.z (the local variable), which was then picked up by the final assignment. The fix should use ang_vel_body.z = _ahrs.get_gyro().z; so the gyro value survives to line 969.
| _ang_vel_body.z = _ahrs.get_gyro().z; | |
| get_rate_yaw_pid().reset_I(); | |
| ang_vel_body.z = _ahrs.get_gyro().z; | |
| get_rate_yaw_pid().reset_I(); |
| function is_vehicle_landing() | ||
| local current_mode = vehicle:get_mode() | ||
| if current_mode == MODE_QLAND then | ||
| return true | ||
| elseif quadplane:in_vtol_land_descent() then | ||
| if quadplane:in_vtol_land_descent() then | ||
| return true | ||
| else | ||
| return false | ||
| end | ||
| end |
There was a problem hiding this comment.
Dead code:
is_vehicle_landing() is no longer called
The refactor replaced the is_vehicle_landing() guard in update() with in_vtol_flight(), but is_vehicle_landing() itself was left defined. It is now dead code and can be removed to avoid confusion.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
This PR has porting of ArduPlane hotfixes 4 and 5 (versions V4.5.7.4-hf4/hf5 and V4.5.7.5-rc1) to the 4.6.3.
https://www.notion.so/airbound/backporting-HF4-HF5-to-4-6-3-38121adf4be980fb8fa9cb9bd17600c1?v=29721adf4be981d59032000c1dc9579e&source=copy_link