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

Sub: limit poshold xy velocity to PILOT_SPEED to avoid bounceback #28205

Merged
merged 4 commits into from
Feb 3, 2025

Conversation

clydemcqueen
Copy link
Contributor

This PR limits horizontal velocity in poshold mode, even when the pilot is using the forward and lateral sticks to reposition the sub. This eliminates the possibility of a PSC-caused bounceback. This is verified by an autotest.

The PR also adds a PILOT_SPEED parameter, so there are now 3 WPNAV_SPEED* parameters and 3 PILOT_SPEED* parameters. Previously, poshold was using WPNAV_SPEED for xy and PILOT_SPEED_UP/DN for z, this PR changes it to use PILOT_SPEED* for both xy and z.

(Circle mode also uses WPNAV_SPEED for xy and PILOT_SPEED_UP/DN for z, but I would argue that it should be using WPNAV_SPEED* for both xy and z. This can be a separate PR.)

There are 2 additional small fixes:

  • removes unused variable Sub::desired_climb_rate
  • ModePoshold::requires_GPS returns true, so Sub::set_mode will call sub.position_ok before accepting a mode switch. (ModePoshold::init() function also calls sub.position_ok, so this doesn't change behavior.)

This should probably be tested on real hardware.

Fixes #28120

Copy link
Contributor

@Williangalvani Williangalvani left a comment

Choose a reason for hiding this comment

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

looking good! I'll try to do some real-life testing tomorrow. thanks for the fix!

}

// behavior is similar to Sub::get_pilot_desired_climb_rate
float Sub::get_pilot_desired_horizontal_rate(RC_Channel *channel) const
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't it make sense to keep it alongside get_pilot_desired_climbrate() in attitude.cpp ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll move it.

@@ -406,6 +403,7 @@ class Sub : public AP_Vehicle {
float get_roi_yaw();
float get_look_ahead_yaw();
float get_pilot_desired_climb_rate(float throttle_control);
float get_pilot_desired_horizontal_rate(RC_Channel *channel) const;
Copy link
Contributor

@rmackay9 rmackay9 Sep 23, 2024

Choose a reason for hiding this comment

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

not a blocker of course but personally I'd stick with the word "speed". introducing a synonym, "horizontal rate" just adds confusion

position_control->update_xy_controller();
}

motors.set_forward(forward_out);
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a good change to me because previously the pilot input was essentially added on top of the position controller output. That would lead to the position controller fighting the user which is terrible and a pattern we try to avoid.

The change in behaviour for users is that they won't be able to control the vehicle laterally in poshold mode anymore unless the EKF has a good position estimate.

Still, looks like an improvement!

Copy link
Contributor

Choose a reason for hiding this comment

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

The change in behaviour for users is that they won't be able to control the vehicle laterally in poshold mode anymore unless the EKF has a good position estimate.

That's an interesting point. what if we move body_rates_cm_s up one level and apply that to thrusters if posititon_ok() is false?

Sensors are not perfect and I think users should keep control when they fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's an interesting point. what if we move body_rates_cm_s up one level and apply that to thrusters if posititon_ok() is false?

Ah, good catch, and good idea. Let me play around with this a bit.

@Williangalvani
Copy link
Contributor

tested and working well on my pool. but I'm concerned about more challenging conditions for DVLs

@clydemcqueen
Copy link
Contributor Author

tested and working well on my pool. but I'm concerned about more challenging conditions for DVLs

Thanks for testing! It is good to know that the pilot experience feels good when the sensor is working. I'll work on the sensor failure case a bit.

@rmackay9
Copy link
Contributor

In other vehicles the way we handle loss of position estimate is to change the flight mode. So when the EKF failsafe triggers, the vehicle can be switched to Land, AltHold, etc. We don't expect a mode to be controlled both with and without a position sensor.

@clydemcqueen
Copy link
Contributor Author

The code now falls back to manual control (limited by PILOT_SPEED) if positioning fails. I tested this in SITL param set SIM_GPS_DISABLE 1 and it works as expected.

The position estimates can get a little wonky just before the EKF failsafe triggers, but this is the current behavior.

All-in-all I think that this is an improvement over the current situation. LMK what you think.

@rmackay9
Copy link
Contributor

It's up to you guys of course. Rover's Acro mode for skid steering vehicle also does this kind of thing where the throttle is completely manual if the vehicle doesn't have a good position estimate, otherwise it runs the forward-back speed controller.

@clydemcqueen
Copy link
Contributor Author

I tested this on a DVL-rigged ROV last week and it worked well.

The A50 is rock solid in all of the situations we dive in, so I didn't see the failsafe kick in.

LMK if you'd like to see additional changes. Thanks.

@Williangalvani Williangalvani self-requested a review January 29, 2025 15:21
Copy link
Contributor

@Williangalvani Williangalvani left a comment

Choose a reason for hiding this comment

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

lgtm!

just tested and behaves as expected. I also disabled the dvl driver while in poshold, and retained control.

@Williangalvani Williangalvani merged commit 1df6744 into ArduPilot:master Feb 3, 2025
62 checks passed
@clydemcqueen clydemcqueen deleted the sub_poshold_bounce branch February 3, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sub: pilot override in POSHOLD mode results in "bounce back"
3 participants