Browse Source

Copter: fix guided_posvel and guided_vel to update pos_control at same rate as wpnav

mission-4.1.18
Jonathan Challinger 10 years ago committed by Randy Mackay
parent
commit
4e09c9832b
  1. 24
      ArduCopter/control_guided.pde

24
ArduCopter/control_guided.pde

@ -271,8 +271,19 @@ static void guided_vel_control_run()
} }
} }
// calculate dt
float dt = pos_control.time_since_last_xy_update();
// update at poscontrol update rate
if (dt >= pos_control.get_dt_xy()) {
// sanity check dt
if (dt >= 0.2f) {
dt = 0.0f;
}
// call velocity controller which includes z axis controller // call velocity controller which includes z axis controller
pos_control.update_vel_controller_xyz(ekfNavVelGainScaler); pos_control.update_vel_controller_xyz(ekfNavVelGainScaler);
}
// call attitude controller // call attitude controller
if (auto_yaw_mode == AUTO_YAW_HOLD) { if (auto_yaw_mode == AUTO_YAW_HOLD) {
@ -305,8 +316,18 @@ static void guided_posvel_control_run()
posvel_vel_target_cms.zero(); posvel_vel_target_cms.zero();
} }
// calculate dt
float dt = pos_control.time_since_last_xy_update();
// update at poscontrol update rate
if (dt >= pos_control.get_dt_xy()) {
// sanity check dt
if (dt >= 0.2f) {
dt = 0.0f;
}
// advance position target using velocity target // advance position target using velocity target
posvel_pos_target_cm += posvel_vel_target_cms * G_Dt; posvel_pos_target_cm += posvel_vel_target_cms * dt;
// send position and velocity targets to position controller // send position and velocity targets to position controller
pos_control.set_pos_target(posvel_pos_target_cm); pos_control.set_pos_target(posvel_pos_target_cm);
@ -315,6 +336,7 @@ static void guided_posvel_control_run()
// run position controller // run position controller
pos_control.update_xy_controller(AC_PosControl::XY_MODE_POS_AND_VEL_FF, ekfNavVelGainScaler); pos_control.update_xy_controller(AC_PosControl::XY_MODE_POS_AND_VEL_FF, ekfNavVelGainScaler);
pos_control.update_z_controller(); pos_control.update_z_controller();
}
// call attitude controller // call attitude controller
if (auto_yaw_mode == AUTO_YAW_HOLD) { if (auto_yaw_mode == AUTO_YAW_HOLD) {

Loading…
Cancel
Save