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: Payload Place: Fix first run abort #27548

Merged
merged 1 commit into from
Jul 16, 2024
Merged
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
20 changes: 12 additions & 8 deletions ArduCopter/mode_auto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1255,13 +1255,21 @@ void PayloadPlace::run()
const uint32_t descent_thrust_cal_duration_ms = 2000; // milliseconds
const uint32_t placed_check_duration_ms = 500; // how long we have to be below a throttle threshold before considering placed

// Vertical thrust is taken from the attitude controller before angle boost is added
auto &g2 = copter.g2;
const auto &g = copter.g;
auto &inertial_nav = copter.inertial_nav;
auto *attitude_control = copter.attitude_control;
const auto &pos_control = copter.pos_control;
const auto &wp_nav = copter.wp_nav;

// Vertical thrust is taken from the attitude controller before angle boost is added
const float thrust_level = attitude_control->get_throttle_in();
const uint32_t now_ms = AP_HAL::millis();

// relax position target if we might be landed
// if we discover we've landed then immediately release the load:
if (copter.ap.land_complete || copter.ap.land_complete_maybe) {
pos_control->soften_for_landing_xy();
switch (state) {
case State::FlyToLocation:
// this is handled in wp_run()
Expand Down Expand Up @@ -1289,7 +1297,9 @@ void PayloadPlace::run()
switch (state) {
case State::FlyToLocation:
case State::Descent_Start:
gcs().send_text(MAV_SEVERITY_INFO, "%s Manual release", prefix_str);
gcs().send_text(MAV_SEVERITY_INFO, "%s Abort: Gripper Open", prefix_str);
// Descent_Start has not run so we must also initalise descent_start_altitude_cm
descent_start_altitude_cm = inertial_nav.get_position_z_up_cm();
state = State::Done;
break;
case State::Descent:
Expand All @@ -1307,12 +1317,6 @@ void PayloadPlace::run()
}
#endif

auto &inertial_nav = copter.inertial_nav;
auto &g2 = copter.g2;
const auto &g = copter.g;
const auto &wp_nav = copter.wp_nav;
const auto &pos_control = copter.pos_control;

switch (state) {
case State::FlyToLocation:
if (copter.wp_nav->reached_wp_destination()) {
Expand Down
Loading