Skip to content
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: remove global ap.new_radio_frame state #28355

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ArduCopter/Copter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,13 +772,15 @@ void Copter::update_simple_mode(void)
{
float rollx, pitchx;

// exit immediately if no new radio frame or not in simple mode
if (simple_mode == SimpleMode::NONE || !ap.new_radio_frame) {
// exit immediately if not in simple mode:
if (simple_mode == SimpleMode::NONE) {
return;
}

// mark radio frame as consumed
ap.new_radio_frame = false;
// exit immediately if RC input is invalid:
if (!rc().has_valid_input()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the same; RC input would come in at maybe 50Hz, this method is called at the main loop rate, so we'd start to do these transforms much faster than required in the case someone's using simple mode. The method is also not idempotent, so pretty much completely broken.

We probably want to unconditionally call this method when a new radio frame is received instead.

return;
}

if (simple_mode == SimpleMode::SIMPLE) {
// rotate roll, pitch input by -initial simple heading (i.e. north facing)
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/Copter.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class Copter : public AP_Vehicle {
bool auto_armed; // 5 stops auto missions from beginning until throttle is raised
bool unused_log_started; // 6
bool land_complete; // 7 true if we have detected a landing
bool new_radio_frame; // 8 Set true if we have new PWM data to act on from the Radio
bool unused_new_radio_frame; // 8 was: Set true if we have new PWM data to act on from the Radio
bool unused_usb_connected; // 9
bool unused_receiver_present; // 10
bool compass_mot; // 11 true if we are currently performing compassmot calibration
Expand Down
2 changes: 0 additions & 2 deletions ArduCopter/radio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ void Copter::read_radio()
const uint32_t tnow_ms = millis();

if (rc().read_input()) {
ap.new_radio_frame = true;

set_throttle_and_failsafe(channel_throttle->get_radio_in());
set_throttle_zero_flag(channel_throttle->get_control_in());

Expand Down
Loading