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

FW attitude control scaling fixes and cleanup #15256

Merged
merged 3 commits into from
Jul 10, 2020

Conversation

supergra
Copy link
Contributor

@supergra supergra commented Jul 4, 2020

This commit aligns the scaling better with the derivations in
https://dev.px4.io/master/en/flight_stack/controller_diagrams.html#airspeed-scaling

Integrator terms now scale with IAS^2 (all three axes)

To match the roll and pitch controllers:

  • Yaw integrator scale is now applied during accumulation, not to
    integral value (so now FW_YR_IMAX is respected more intuitively)
  • Yaw FF term now scale with IAS instead of IAS^2

Also made a number of small changes to make the three files
(roll, pitch, yaw) 3-way diffable to be clearer about what the
differences among them are.

Describe problem solved by this pull request

Note, this does not handle #11975 -- according to the reference document, the FF gains should be scaled with TAS instead of IAS, but that will require some more invasive work.

This commit aligns the scaling better with the derivations in
https://dev.px4.io/master/en/flight_stack/controller_diagrams.html#airspeed-scaling

Integrator terms now scale with IAS^2 (all three axes)

To match the roll and pitch controllers:
- Yaw integrator scale is now applied during accumulation, not to
  integral value (so now FW_YR_IMAX is respected more intuitively)
- Yaw FF term now scale with IAS instead of IAS^2

Also made a number of small changes to make the three files
  (roll, pitch, yaw) 3-way diffable to be clearer about what the
  differences among them are.
@supergra
Copy link
Contributor Author

supergra commented Jul 4, 2020

@bresch FYI, applied some of the scaling fixes as suggested in your reference document.

/* input conditioning */
float airspeed = ctl_data.airspeed;
/* Close the acceleration loop if _coordinated_method wants this: change body_rate setpoint */
if (_coordinated_method == COORD_METHOD_CLOSEACC) {
Copy link
Member

Choose a reason for hiding this comment

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

You could remove _coordinated_method entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

- "Coordination method" open vs. closed code removed, since closed
  is never used and not actually implemented.
- No change to behavior
@supergra
Copy link
Contributor Author

supergra commented Jul 6, 2020

Ultimately, the functionality is trivial enough that it could go in FixedWingAttitudeControl, clearing out all of this. I find the back and forth tough to follow.

@dagar
Copy link
Member

dagar commented Jul 6, 2020

Ultimately, the functionality is trivial enough that it could go in FixedWingAttitudeControl, clearing out all of this. I find the back and forth tough to follow.

The current idea is to absorb ECL_* entirely into FixedwingAttitudeControl at some point. I think the end result would overall be much simpler and easier to follow.

Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

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

Thanks for the fix and cleanup!

@supergra
Copy link
Contributor Author

supergra commented Jul 7, 2020

Not familiar with the CI tests -- one is failing, but doesn't seem like it could possibly be caused by this change:

[Err] [gazebo_mavlink_interface.cpp:1367] Connection closed by client.
 ERROR [px4] Startup script returned with return value: 2
in rc_io initialized

@dagar
Copy link
Member

dagar commented Jul 7, 2020

Not familiar with the CI tests -- one is failing, but doesn't seem like it could possibly be caused by this change:

It actually seems fairly likely given the change modified the FW controller and only the FW mission tests is failing. Unfortunately we didn't even get a log.

Have you tried SITL locally? A simple mission takeoff, waypoint, and planned landing?

@supergra
Copy link
Contributor Author

supergra commented Jul 7, 2020

@dagar I'll try now. Just checking that the CI system isn't known to be fragile, or that this was a common mistake for beginner contributors. (We use a custom SITL in-house, so I'm not familiar with Gazebo.)

@supergra
Copy link
Contributor Author

supergra commented Jul 8, 2020

Apologies, I've had no luck installing Gazebo (tried several methods). On our in-house simulator, these changes fly normally in SITL, but we aren't able to run Firmware/master as-is, and are primarily still on v1.10 so it's not a real test.

I stand by my surprise that removing PX4_WARN statements would cause a test to fail (the tests passed before mylast commit).

I can try reverting the last commit, and see if that was the problem or other commits on master.

@supergra
Copy link
Contributor Author

supergra commented Jul 8, 2020

Ok after reverting, first the MAVROS rover (!) test failed for a while, but now it's passing. Intermittent issue?

I'll add back the last commit.

@supergra
Copy link
Contributor Author

supergra commented Jul 8, 2020

Percussive maintenance successful, ready for review again.

FYI, I notice various MAVROS tests failing on several recent commits. Seems random. They all seem to involve a segfault.

@dagar
Copy link
Member

dagar commented Jul 8, 2020

FYI, I notice various MAVROS tests failing on several recent commits. Seems random. They all seem to involve a segfault.

Where?

@supergra
Copy link
Contributor Author

supergra commented Jul 8, 2020

@supergra
Copy link
Contributor Author

supergra commented Jul 9, 2020

@bresch Made your requested change, and all tests passing.

@dagar
Copy link
Member

dagar commented Jul 9, 2020

@dagar: Other than mine, I see the segfaults on these CI runs:

Thanks for pointing those out. Please create issues for test failures like that as they come up. I'd like to get CI to the point where we can really trust it.

@supergra
Copy link
Contributor Author

supergra commented Jul 9, 2020

Thanks for pointing those out. Please create issues for test failures like that as they come up. I'd like to get CI to the point where we can really trust it.

Opened issue for the CI failures here: #15300

@fury1895
Copy link
Contributor

Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

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

Thanks @fury1895 for the flight tests, I didn't see any issue in the logs.

Thanks for your contribution @supergra !

@bresch bresch merged commit 94326a2 into PX4:master Jul 10, 2020
@supergra supergra deleted the pr-fwatt-fixes branch July 14, 2020 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrator scaling factor (roll/pitch controllers) Yaw Airspeed Scaler Different from Pitch and Roll
4 participants