-
Notifications
You must be signed in to change notification settings - Fork 18k
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
Plane: Add fwd. throttle cutoff voltage parameter #29080
base: master
Are you sure you want to change the base?
Plane: Add fwd. throttle cutoff voltage parameter #29080
Conversation
Needs library commit split |
Have you considered using scripting for this? |
Would it work as cleanly? This has the advantage that it keeps the aircraft armed. |
You could trigger the E-Stop aux function which will only stop the motors. You could also force override the throttle PWM to 0. Or set the throttle max param to some low value such that you still get a little throttle. The nice thing about scripting is that it keeps it very contained, you only have to consider your use case. For example this PR would be very bad on a hovering quadplane, to get it into the main code you need to deal with that case (and I'm sure we will think of some others). If its just a script then that is not a problem. Another option could be to support glide as a battery fail safe action. We support this already for RC/GCS failsafe. That means you don't have to touch the throttle suppression code which we have to be very careful with. |
Makes sense, thank you! Though I still think it may be valuable to support this as part of the main code, and not as a failsafe action, as I think those are separate. For example, I may want to RTL and then land or to go directly to the landing sequence on battery critical, but to have the throttle shut down either way. What do you think is best? Should I just submit this as a script, or should I flesh out this implementation and get it into the main code? |
Your welcome carry on with the C++ implementation just be warned that we will be quite picky with failsafes and things touching throttle suppression ;) |
d91053b
to
8de814f
Compare
@IamPete1 Is this more reasonable? I have aligned it more closely to my intended use case by making it entirely separate from the battery failsafes. I don't see the need to have this work in forward flight only (and to have exceptions for VTOL) since the whole point is to prevent the motor from wasting power when it can no longer provide any thrust. In a quadplane you'll have this configured based on the forward flight motors, so by the time the voltage is so low those are useless, the hovering capability will already be long gone. |
this is now an ESC voltage cut-off equivalent, I think...will apply only to FW battery IF its the primary battery indx, I think...seems okay to me |
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'm really not a fan of using throttle suppression here. It could cause all sorts of odd stuff, this also needs to use a battery index, just using the first may not be valid.
How about linking into the existing battery voltage compensation code path. Here:
ardupilot/ArduPlane/servos.cpp
Line 408 in 25e1701
void ParametersG2::FWD_BATT_CMP::update() |
It has a index parameter already. There is a function for setting min and max here:
https://github.com/ArduPilot/ardupilot/blob/25e1701447e582bc378c9cd0c7f3f554f424d2de/ArduPlane/servos.cpp#L441C34-L441C47.
So in this new case you could just set both min and max to 0 if under the threshold.
Makes sense but what sort of issues does this cause? For future reference. |
I have no idea off the top of my head, the throttle suppression stuff is used in lots of places. Although I guess your not actually setting the |
8de814f
to
7cc7e75
Compare
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.
Basically looks good. I guess it still works as expected for your use case?
ArduPlane/Parameters.cpp
Outdated
// @Units: V | ||
// @Increment: 0.1 | ||
// @User: Standard | ||
AP_GROUPINFO("FWD_THR_CUTOFF_V", 37, ParametersG2, fwd_batt_cmp.batt_voltage_throttle_cutoff, 0.0f), |
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.
It would be nice to keep the "FWD_BAT_" prefix so the parameters turn up together in a search. Although I can't think of any great options.
"FWD_BAT_THR_CUT" maybe?
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.
Other options that come to mind are FWD_BAT_CUT_VOLT, or to make it more consistent with the other names, FWD_BAT_VOLT_CUT. But I think so far I prefer FWD_BAT_THR_CUT
ArduPlane/servos.cpp
Outdated
@@ -449,7 +457,6 @@ void ParametersG2::FWD_BATT_CMP::apply_min_max(int8_t &min_throttle, int8_t &max | |||
// Ratio will always be >= 1, ensure still within max limits | |||
min_throttle = int8_t(MAX((ratio * (float)min_throttle), -100)); | |||
max_throttle = int8_t(MIN((ratio * (float)max_throttle), 100)); | |||
|
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.
accidental white space 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.
The couple newlines I removed were to improve consistency with the surrounding code. I guess I shouldn't do that? Just so I know for the next time.
To a T, thanks. That one failing plane test is unrelated, right? |
Updated the forward throttle battery voltage compensation feature to disable the throttle entirely when the sag-compensated voltage drops below the new parameter FWD_THR_CUTOFF_V. Key changes: - Added new parameter FWD_THR_CUTOFF_V to control the voltage threshold for this feature. The default value of 0 matches the original behavior of never cutting the throttle due to low voltage. - Modified forward throttle battery voltage compensation logic in the servos code to cut off the throttle if the resting voltage estimate of the FWD_BAT_IDX battery is under FWD_THR_CUTOFF_V.
7cc7e75
to
ae3c5cd
Compare
Plane: Add fwd. throttle cutoff voltage parameter
Updated the forward throttle battery voltage compensation feature to disable the throttle entirely when the sag-compensated voltage drops below the new parameter FWD_BAT_THR_CUT.
Key changes: