Skip to content

Commit

Permalink
Plane: move set_servos_idle functionality to ModeAuto
Browse files Browse the repository at this point in the history
  • Loading branch information
IamPete1 authored and tridge committed Oct 31, 2023
1 parent 220ab51 commit 8061b1b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 24 deletions.
6 changes: 0 additions & 6 deletions ArduPlane/Plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,6 @@ class Plane : public AP_Vehicle {
// have we checked for an auto-land?
bool checked_for_autoland;

// Altitude threshold to complete a takeoff command in autonomous modes. Centimeters
// are we in idle mode? used for balloon launch to stop servo
// movement until altitude is reached
bool idle_mode;

// are we in VTOL mode in AUTO?
bool vtol_mode;

Expand Down Expand Up @@ -930,7 +925,6 @@ class Plane : public AP_Vehicle {
void do_loiter_unlimited(const AP_Mission::Mission_Command& cmd);
void do_loiter_turns(const AP_Mission::Mission_Command& cmd);
void do_loiter_time(const AP_Mission::Mission_Command& cmd);
void do_altitude_wait(const AP_Mission::Mission_Command& cmd);
void do_continue_and_change_alt(const AP_Mission::Mission_Command& cmd);
void do_loiter_to_alt(const AP_Mission::Mission_Command& cmd);
void do_vtol_takeoff(const AP_Mission::Mission_Command& cmd);
Expand Down
10 changes: 0 additions & 10 deletions ArduPlane/commands_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ bool Plane::start_command(const AP_Mission::Mission_Command& cmd)
// except in a takeoff
auto_state.takeoff_complete = true;

// start non-idle
auto_state.idle_mode = false;

nav_controller->set_data_is_stale();

// reset loiter start time. New command is a new loiter
Expand Down Expand Up @@ -93,7 +90,6 @@ bool Plane::start_command(const AP_Mission::Mission_Command& cmd)
break;

case MAV_CMD_NAV_ALTITUDE_WAIT:
do_altitude_wait(cmd);
break;

#if HAL_QUADPLANE_ENABLED
Expand Down Expand Up @@ -519,12 +515,6 @@ void Plane::do_continue_and_change_alt(const AP_Mission::Mission_Command& cmd)
reset_offset_altitude();
}

void Plane::do_altitude_wait(const AP_Mission::Mission_Command& cmd)
{
// set all servos to trim until we reach altitude or descent speed
auto_state.idle_mode = true;
}

void Plane::do_loiter_to_alt(const AP_Mission::Mission_Command& cmd)
{
//set target alt
Expand Down
2 changes: 2 additions & 0 deletions ArduPlane/mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ class ModeAuto : public Mode
void do_nav_delay(const AP_Mission::Mission_Command& cmd);
bool verify_nav_delay(const AP_Mission::Mission_Command& cmd);

void run() override;

protected:

bool _enter() override;
Expand Down
16 changes: 16 additions & 0 deletions ArduPlane/mode_auto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,19 @@ bool ModeAuto::is_landing() const
{
return (plane.flight_stage == AP_FixedWing::FlightStage::LAND);
}

void ModeAuto::run()
{
if (plane.mission.get_current_nav_cmd().id == MAV_CMD_NAV_ALTITUDE_WAIT) {
// Wiggle servos
plane.set_servos_idle();

// Relax attitude control
reset_controllers();

} else {
// Normal flight, run base class
Mode::run();

}
}
8 changes: 0 additions & 8 deletions ArduPlane/servos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ void Plane::set_servos_idle(void)
SRV_Channels::set_output_scaled(SRV_Channel::k_rudder, servo_value);
SRV_Channels::set_output_to_trim(SRV_Channel::k_throttle);

SRV_Channels::output_ch_all();
}


Expand Down Expand Up @@ -815,13 +814,6 @@ void Plane::set_servos(void)
quadplane.update();
#endif

if (control_mode == &mode_auto && auto_state.idle_mode) {
// special handling for balloon launch
set_servos_idle();
servos_output();
return;
}

if (control_mode != &mode_manual) {
set_servos_controlled();
set_takeoff_expected();
Expand Down

0 comments on commit 8061b1b

Please sign in to comment.