Skip to content

Commit

Permalink
Simplify init z controller
Browse files Browse the repository at this point in the history
  • Loading branch information
lthall committed Oct 1, 2024
1 parent f94d04f commit 11958e4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libraries/AC_AttitudeControl/AC_PosControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,15 +818,17 @@ void AC_PosControl::relax_z_controller(float throttle_setting)
/// This function is private and contains all the shared z axis initialisation functions
void AC_PosControl::init_z_controller()
{
// initialise offsets to target offsets and ensure offset targets are zero if they have not been updated.
// initialise terrain targets and offsets to zero
init_terrain();

// initialise offsets to target offsets and ensure offset targets are zero if they have not been updated.
init_offsets_z();

_pos_target.z = _inav.get_position_z_up_cm();
_pos_desired.z = _pos_target.z - (_pos_offset.z + _pos_terrain);
_pos_desired.z = _pos_target.z - _pos_offset.z;

_vel_target.z = _inav.get_velocity_z_up_cms();
_vel_desired.z = _vel_target.z - (_vel_offset.z + _vel_terrain);
_vel_desired.z = _vel_target.z - _vel_offset.z;

// Reset I term of velocity PID
_pid_vel_z.reset_filter();
Expand Down

0 comments on commit 11958e4

Please sign in to comment.