-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
Tradheli: fix yaw attitude error corrections while rotors turning on the ground #28690
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -132,10 +132,17 @@ void ModeLoiter::run() | |
break; | ||
|
||
case AltHoldModeState::Landed_Ground_Idle: | ||
attitude_control->reset_yaw_target_and_rate(); | ||
FALLTHROUGH; | ||
attitude_control->reset_yaw_target_and_rate(false); | ||
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. Why wouldn't we want to reset_rate on landed ground idle? 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 provides some damping to the tail if it gets pushed by a gust or something but will stay close to zero as long as we keep the integrator zero. |
||
attitude_control->reset_rate_controller_I_terms_smoothly(); | ||
loiter_nav->init_target(); | ||
attitude_control->input_thrust_vector_rate_heading(loiter_nav->get_thrust_vector(), target_yaw_rate, false); | ||
pos_control->relax_z_controller(0.0f); // forces throttle output to decay to zero | ||
break; | ||
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 a fairly significant change in behaviour by removing the fall through. We would at least want to keep the loiter_nav->init_target()? 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. Yep, we need to add the loiter_nav->init_target(); I think we can move this to the bottom: attitude_control->input_thrust_vector_rate_heading(loiter_nav->get_thrust_vector(), target_yaw_rate, false); 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. @lthall I think I need to move all of the lines in the pretakeoff state up to the landed ground idle since I removed the fall through. |
||
|
||
case AltHoldModeState::Landed_Pre_Takeoff: | ||
if (!motors->using_hdg_error_correction()) { | ||
attitude_control->reset_target_and_rate(false); | ||
} | ||
attitude_control->reset_rate_controller_I_terms_smoothly(); | ||
loiter_nav->init_target(); | ||
attitude_control->input_thrust_vector_rate_heading(loiter_nav->get_thrust_vector(), target_yaw_rate, false); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,11 +138,15 @@ class AP_MotorsHeli : public AP_Motors { | |
|
||
// enum for heli optional features | ||
enum class HeliOption { | ||
USE_LEAKY_I = (1<<0), // 1 | ||
USE_LEAKY_I = (1<<0), | ||
USE_HDG_CORRECTION = (1<<1), | ||
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. I do not want to feature creep this PR, so I am just saying this as a recommendation for future work. I think it is weird that we ask AP_Motors whether we should be using leaky I and now this heading correction. I understand that it is a hang over because most of the heli specific code lives in motors, but in the future I would like to move the heli option param out of motors and up to the vehicle(copter) level. This adds to my point below as to why I would rather we didn't make it a virtual function. |
||
}; | ||
|
||
// use leaking integrator management scheme | ||
bool using_leaky_integrator() const { return heli_option(HeliOption::USE_LEAKY_I); } | ||
bool using_leaky_integrator() const override { return heli_option(HeliOption::USE_LEAKY_I); } | ||
|
||
// use heading error correction | ||
bool using_hdg_error_correction() const override { return heli_option(HeliOption::USE_HDG_CORRECTION); } | ||
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. Do we need this as an option? What is the use case that users will be trying to drive yaw whilst on the ground? |
||
|
||
// Run arming checks | ||
bool arming_checks(size_t buflen, char *buffer) const override; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,6 +258,10 @@ class AP_Motors { | |
// This function required for tradheli. Tradheli initializes targets when going from unarmed to armed state. | ||
// This function is overriden in motors_heli class. Always true for multicopters. | ||
virtual bool init_targets_on_arming() const { return true; } | ||
// use leaking integrator management scheme is always false for multirotors | ||
virtual bool using_leaky_integrator() const { return false; } | ||
// use heading error correction which is always true for multirotors | ||
virtual bool using_hdg_error_correction() const { return true; } | ||
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. I do not think we should not be making these virtuals in AP_Motors_Class. We are taking something that is a heli-only option and making visible in the multi-copter code. Instead we should keep it in AP_MotorsHeli and use defines for the option, as we do else where in the code. 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 have been trying to remove the hash defines in the shared code and instead make it flexible enough to cover all the hovering aircraft. The aspirational goal is to not have any Heli specific code in the shared code base and instead have optional behaviour that is defined by the vehicle. 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. ok, that is fair enough. I can certainly get on board with that! |
||
|
||
// returns true if the configured PWM type is digital and should have fixed endpoints | ||
bool is_digital_pwm_type() const; | ||
|
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.
Changing this from false to true here will remove all counter talk on the tail rotor. If you can be still spinning down in this phase of flight this will let the tail move more than it would do now.
Low risk but something to consider.
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.
@lthall What do you mean by counter talk? I think the issue here is that when disarmed, there won't be any target reset that would cause an issue with trying to fly disarmed. I know this sounds crazy but I believe that this was intentional by my predecessor to allow users to fly in acro if the aircraft disarms unexpectedly, like due to code bug. I think that this should true so that the attitude errors are reset. However I may make this change in a separate PR to make this more visible as an intentional 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.
@Ferruccio1984 What do you think of having the attitude error correction (pitch and roll) removed for the disarmed state in acro. This means that when you move the pitch and roll stick that the swashplate will not react while disarmed which is what you probably saw in your flight today. I think it is a good idea because it would keep users from moving the swashplate while disarmed and then being surprised on spool up if the swash was not centered. I think the idea of ever having to fly in a disarmed state is very low risk.
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 personally like that we can do "control surface" checks when on the ground. Making sure that all of the servos and swash are moving and in the correct direction is a good pre-flight check.
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.
@MattKear i think my comment was not completely accurate. In acro currently, if you move the sticks, the commanded attitude is tracked and you could end up having 90 deg commanded while on the ground and disarmed. With ths new implementation, you should still see movement of rhe swash because you are commanding rates and it will always center itself when you center the stick (zero rates) where it does not do that currently. So you can stick check controls on the ground while disarmed. Again this is only in acro. Stabilize should not change except for yaw and that should react to rate requests also.