mirror of https://github.com/ArduPilot/ardupilot
Plane: move mode manual reset into run function removing manual early return
This commit is contained in:
parent
160629eb18
commit
2254252aff
|
@ -346,13 +346,6 @@ void Plane::stabilize_yaw()
|
|||
*/
|
||||
void Plane::stabilize()
|
||||
{
|
||||
if (control_mode == &mode_manual) {
|
||||
// reset steering controls
|
||||
steer_state.locked_course = false;
|
||||
steer_state.locked_course_err = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t now = AP_HAL::millis();
|
||||
#if HAL_QUADPLANE_ENABLED
|
||||
if (quadplane.available()) {
|
||||
|
@ -361,19 +354,13 @@ void Plane::stabilize()
|
|||
#endif
|
||||
|
||||
if (now - last_stabilize_ms > 2000) {
|
||||
// if we haven't run the rate controllers for 2 seconds then
|
||||
// reset the integrators
|
||||
rollController.reset_I();
|
||||
pitchController.reset_I();
|
||||
yawController.reset_I();
|
||||
|
||||
// and reset steering controls
|
||||
steer_state.locked_course = false;
|
||||
steer_state.locked_course_err = 0;
|
||||
// if we haven't run the rate controllers for 2 seconds then reset
|
||||
control_mode->reset_controllers();
|
||||
}
|
||||
last_stabilize_ms = now;
|
||||
|
||||
if (control_mode == &mode_training) {
|
||||
if (control_mode == &mode_training ||
|
||||
control_mode == &mode_manual) {
|
||||
plane.control_mode->run();
|
||||
#if AP_SCRIPTING_ENABLED
|
||||
} else if (nav_scripting_active()) {
|
||||
|
|
|
@ -212,3 +212,16 @@ void Mode::run()
|
|||
plane.stabilize_pitch();
|
||||
plane.stabilize_yaw();
|
||||
}
|
||||
|
||||
// Reset rate and steering controllers
|
||||
void Mode::reset_controllers()
|
||||
{
|
||||
// reset integrators
|
||||
plane.rollController.reset_I();
|
||||
plane.pitchController.reset_I();
|
||||
plane.yawController.reset_I();
|
||||
|
||||
// reset steering controls
|
||||
plane.steer_state.locked_course = false;
|
||||
plane.steer_state.locked_course_err = 0;
|
||||
}
|
||||
|
|
|
@ -79,6 +79,9 @@ public:
|
|||
// returns true if the vehicle can be armed in this mode
|
||||
bool pre_arm_checks(size_t buflen, char *buffer) const;
|
||||
|
||||
// Reset rate and steering controllers
|
||||
void reset_controllers();
|
||||
|
||||
//
|
||||
// methods that sub classes should override to affect movement of the vehicle in this mode
|
||||
//
|
||||
|
@ -355,6 +358,8 @@ public:
|
|||
|
||||
// methods that affect movement of the vehicle in this mode
|
||||
void update() override;
|
||||
|
||||
void run() override;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -11,3 +11,7 @@ void ModeManual::update()
|
|||
plane.nav_pitch_cd = ahrs.pitch_sensor;
|
||||
}
|
||||
|
||||
void ModeManual::run()
|
||||
{
|
||||
reset_controllers();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue