-
Notifications
You must be signed in to change notification settings - Fork 16.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copter: refactoring about control_mode #13431
Changes from all commits
a30f7d8
29fb6a1
e802404
4a932de
15fb6bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,7 @@ void AP_AdvancedFailsafe_Copter::setup_IO_failsafe(void) | |
*/ | ||
AP_AdvancedFailsafe::control_mode AP_AdvancedFailsafe_Copter::afs_mode(void) | ||
{ | ||
switch (copter.control_mode) { | ||
switch (copter.flightmode->mode_number()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't your bug. But |
||
case Mode::Number::AUTO: | ||
case Mode::Number::GUIDED: | ||
case Mode::Number::RTL: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,15 +20,15 @@ MAV_COLLISION_ACTION AP_Avoidance_Copter::handle_avoidance(const AP_Avoidance::O | |
copter.failsafe.adsb = true; | ||
failsafe_state_change = true; | ||
// record flight mode in case it's required for the recovery | ||
prev_control_mode = copter.control_mode; | ||
prev_control_mode = copter.flightmode->mode_number(); | ||
} | ||
|
||
// take no action in some flight modes | ||
if (copter.control_mode == Mode::Number::LAND || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also not your bug, but this should be asking if the vehicle is landing for any reason ( Perhaps a future PR... |
||
if (copter.flightmode->mode_number() == Mode::Number::LAND || | ||
#if MODE_THROW_ENABLED == ENABLED | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should retaining the |
||
copter.control_mode == Mode::Number::THROW || | ||
copter.flightmode->mode_number() == Mode::Number::THROW || | ||
#endif | ||
copter.control_mode == Mode::Number::FLIP) { | ||
copter.flightmode->mode_number() == Mode::Number::FLIP) { | ||
actual_action = MAV_COLLISION_ACTION_NONE; | ||
} | ||
|
||
|
@@ -158,15 +158,15 @@ int16_t AP_Avoidance_Copter::get_altitude_minimum() const | |
bool AP_Avoidance_Copter::check_flightmode(bool allow_mode_change) | ||
{ | ||
// ensure copter is in avoid_adsb mode | ||
if (allow_mode_change && copter.control_mode != Mode::Number::AVOID_ADSB) { | ||
if (allow_mode_change && copter.flightmode->mode_number() != Mode::Number::AVOID_ADSB) { | ||
if (!copter.set_mode(Mode::Number::AVOID_ADSB, ModeReason::AVOIDANCE)) { | ||
// failed to set mode so exit immediately | ||
return false; | ||
} | ||
} | ||
|
||
// check flight mode | ||
return (copter.control_mode == Mode::Number::AVOID_ADSB); | ||
return (copter.flightmode->mode_number() == Mode::Number::AVOID_ADSB); | ||
} | ||
|
||
bool AP_Avoidance_Copter::handle_avoidance_vertical(const AP_Avoidance::Obstacle *obstacle, bool allow_mode_change) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I not sure that this removal don't have side effect. I will check that.