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

mc_rate_control: use vehicle_angular_acceleration topic #14048

Merged
merged 9 commits into from
Mar 12, 2020

Conversation

dagar
Copy link
Member

@dagar dagar commented Jan 28, 2020

We're computing vehicle_angular_acceleration upstream of the controllers in the sensor pipeline now. Should we use it the multicopter rate controller?

  • allows us to see the data actually used by the controller
  • we'll be able to do a better job filtering data upstream
    • if the mc_rate_controller isn't running synchronized with IMU sampling the upstream vehicle_angular_acceleration will still capture and filter all data
    • in the future we can use the full raw data set (FIFOs) to filter as well
  • angular acceleration only goes through a single lowpass now, instead of applied after the lowpassed angular velocity
  • sample rate used by filter is now correct, especially if the primary gyro changes
  • saves some flash and cpu (minor)
  • downside, param churn: MC_DTERM_CUTOFF replaced by IMU_DGYRO_CUTOFF

@dagar dagar force-pushed the pr-mc_vehicle_angular_acceleration branch from 699d1ea to 6357bd1 Compare January 30, 2020 07:09
jlecoeur
jlecoeur previously approved these changes Jan 30, 2020
Copy link
Contributor

@jlecoeur jlecoeur left a comment

Choose a reason for hiding this comment

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

Sounds good to me.

Another benefit is that angular acceleration may be used for system ID (ex: #13585 ) , so it is better if the same data is used in the controller.

Requires careful flight test.

@@ -147,12 +145,18 @@ MulticopterRateControl::Run()
vehicle_angular_velocity_s angular_velocity;

if (_vehicle_angular_velocity_sub.update(&angular_velocity)) {

// grab corresponding vehicle_angular_acceleration immediately after vehicle_angular_velocity copy
Copy link
Contributor

Choose a reason for hiding this comment

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

We may document on both sides - _mc_rate_control and vehicle_angular_velocity - that velocity is published before accel, and that they should be read in the same order. This is not obvious and may be lost in a future refactoring.

Copy link
Member Author

Choose a reason for hiding this comment

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

The ordering doesn't actually matter because the execution of vehicle_angular_velocity (where both angular velocity and angular acceleration are published) followed by mc_rate_control is serialized. Although there's nothing actually enforcing this implementation.

I'll still add a comment publisher side.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, 👍

@dagar dagar requested a review from a team January 30, 2020 18:53
Copy link
Member

@MaEtUgR MaEtUgR left a comment

Choose a reason for hiding this comment

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

Makes sense from my pespective to handle this on the sensor side and I don't see the problem IF the filtering inside vehicle_angular_acceleration is equivalent which it should be.

Just came to my mind: What happens in the case where the gyro sensor is switched in air and the derivative should not have a jump?

Before we merge this we have to directly compare if it really doesn't change filtering because if there's a difference this could easily flip multicopters on takeoff and/or significantly impair performance.
Also @bkueng should be added as reviewer since he contributed the D-term filtering which was a big improvement.


// grab corresponding vehicle_angular_acceleration immediately after vehicle_angular_velocity copy
vehicle_angular_acceleration_s v_angular_acceleration{};
_vehicle_angular_acceleration_sub.copy(&v_angular_acceleration);
Copy link
Member

Choose a reason for hiding this comment

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

Minor implementation detail but what about using a SubscriptionData and directly fetching the vector using:
const Vector3f angular_accl{_vhicle_angular_acceleration_sub.get().xyz}; ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's pretty minor, but there's no need to store the data because every iteration grabs a new one.

@dagar
Copy link
Member Author

dagar commented Feb 2, 2020

Just came to my mind: What happens in the case where the gyro sensor is switched in air and the derivative should not have a jump?

That's a good point. At the moment the filters aren't explicitly reset on sensor change, but may reset a few iterations later if the sample rate of the new primary is different (eg pixhawk 4 Invensense -> Bosch).

In most real world use the sensor failover is likely to be abrupt due to resetting the bias. This will be addressed once we have an estimator instance per IMU.

@bkueng
Copy link
Member

bkueng commented Feb 3, 2020

I'm ok with the change, but please do:

  • set the default of IMU_DGYRO_CUTOFF to 30
  • improve param documentation:
    • IMU_GYRO_CUTOFF is not applied to the d-term
    • the notch is applied to both
    • transfer current documentation of MC_DTERM_CUTOFF to IMU_DGYRO_CUTOFF (D-Term filter is a generally known term and should be kept).
  • make sure existing param values of MC_DTERM_CUTOFF are moved over to IMU_DGYRO_CUTOFF

@Junkim3DR
Copy link

Tested on NXP FMUK66 v3

Flight Card 1

Flight Card 2

  • Modes Tested
    Mission Plan Mode (Automated): Good.
    RTL (Return To Land): Good.

  • Procedure
    Arm and Take off in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once all waypoints are completed make sure vehicle triggers RTL.

  • Notes
    Good flight in general.

  • Log
    https://review.px4.io/plot_app?log=6efd975c-1a9f-4a29-869f-37e3a69c9c85

Flight Card 3

  • Modes Tested
    Position Mode: Good.
    Mission Plan Mode (Automated): Good.
    RTL (Return To Land): Good.

  • Procedure
    Arm and Take off in position mode, after flying for approximately one minute, switched to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC.

  • Notes
    Good flight in general.

  • Log
    https://review.px4.io/plot_app?log=afd62fec-6ca5-4e2e-99e4-a0d173616bae

@jorge789
Copy link

jorge789 commented Feb 4, 2020

Tested on CUAV nano V5

Flight Card 1

Modes Tested:
Position Mode: Good.
Altitude Mode: Good.
Stabilized Mode: Good.

Procedure:
Arm and Take off in position mode, after flying for approximately one minute, switched to altitude then stabilized mode.

Notes:
No issues were noted, good flight in general.

Logs: https://review.px4.io/plot_app?log=56fcea9c-9ef1-43dd-9356-33a19e8620d4

Flight Card 2

Modes Tested
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure

Armed form QGC.
Took-off on mission plan mode
. Note that commands were sent form QGC (Armed and takeoff)
Once all waypoint completed vehicle switched to RTL and landed as expected.
Good flight in general.
Note:
When the vehicle was landing, it did not descend vertically, moved away with the wind and returned to the takeoff point and landed

Logs: https://review.px4.io/plot_app?log=67168d92-dc09-44fb-b76c-eff8551accaa

Flight Card 3

Modes Tested
Position Mode: Good.
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Take off in position mode, after flying for approximately one minute, switched to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint then trigger RTL.

Good flight in general.

Note:
No issues were noted, good flight in general.

Logs: https://review.px4.io/plot_app?log=b6b3d5e0-e3c7-4b17-8558-7e9b257634cf

Flight Card 4

- Modes Tested
Position Mode: Good.
Failsafe RTL (Return To Land): Not returning after RC shutdown.
- Procedure
Arm and take off in position mode, after flying approximately a few seconds, turned off the RC to activate the fail-safe RTL, wait for the vehicle to return and land.
- Notes
No issue noted, good flight in general.

Logs: https://review.px4.io/plot_app?log=8b4b4dfb-3f95-4ead-99a0-22a2d13a982d

Tested on PixRacer V4

Flight Card 1

Modes Tested:
Position Mode: Good.
Altitude Mode: Good.
Stabilized Mode: Good.

Procedure:
Arm and Take off in position mode, after flying for approximately one minute, switched to altitude then stabilized mode.

Notes:
No issues were noted, good flight in general.

Logs: https://review.px4.io/plot_app?log=11f4eff7-7305-401c-8def-241c373316a9

Flight Card 2

Modes Tested
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure

Armed form QGC.
Took-off on mission plan mode
. Note that commands were sent form QGC (Armed and takeoff)
Once all waypoint completed vehicle switched to RTL and landed as expected.
Good flight in general.
Note:
No issues were noted, good flight in general.

Logs: https://review.px4.io/plot_app?log=668d6d5a-f34e-4e73-a489-7652b6c57936

Flight Card 3

Modes Tested
Position Mode: Good.
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Take off in position mode, after flying for approximately one minute, switched to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint then trigger RTL.
Note:
Good flight in general.

Note:
No issues were noted, good flight in general.

Logs: https://review.px4.io/plot_app?log=a5416a58-52eb-42e8-9d8a-7fce74716653

Flight Card 4

  • Modes Tested
    Position Mode: Good.
    Failsafe RTL (Return To Land): Not returning after RC shutdown.
  • Procedure
    Arm and take off in position mode, after flying approximately a few seconds, turned off the RC to activate the fail-safe RTL, wait for the vehicle to return and land.
  • Notes
    No issue noted, good flight in general.

Logs: https://review.px4.io/plot_app?log=e7f0e0ba-fcec-4ef0-960f-a5520e3ffb96

@dannyfpv
Copy link

dannyfpv commented Feb 4, 2020

Tested on pixhawk4 v5 f-450
Flight Card 1

Modes Tested
Position Mode: Good.
Altitude Mode: Good.
Stabilized Mode: Good.

Procedure
Arm and Take off in position mode, after flying for approximately one minute, switched to altitude then stabilized mode.

Notes
No issues noted, good flight in general.

Log
https://review.px4.io/plot_app?log=1b6c8ecf-11f5-40d9-9e5f-48424de475f7

Flight Card 2

Modes Tested
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Take off in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once all waypoints are completed make sure vehicle triggers RTL.

Notes
Good flight in general.

Log
https://review.px4.io/plot_app?log=bcb3f7ab-dbec-4e3b-8f96-0137c5923038

Flight Card 3

Modes Tested
Position Mode: Good.
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Take off in position mode, after flying for approximately one minute, switched to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC.

Notes
Good flight in general.

Log
https://review.px4.io/plot_app?log=5d23982a-bf11-4a5a-a464-304aaff9f24e

Flight Card 4

Modes Tested
Position Mode: Good.
Failsafe RTL (Return To Land): Not returning after RC shutdown.
Procedure
Arm and take off in position mode, after flying approximately a few seconds, turned off the RC to activate the fail-safe RTL, wait for the vehicle to return and land.
Notes
No issue noted, good flight in general.
Logs:
https://review.px4.io/plot_app?log=daa82187-c213-4a0e-a223-ec0a2e4955fc

@dagar
Copy link
Member Author

dagar commented Feb 6, 2020

Merge conflict resolved. @PX4/testflights could you do another multicopter flight with SDLOG_PROFILE "High rate" enabled. The new data we're talking about using here isn't logged by default. A single thorough multicopter flight on any vehicle with a comparison to master should suffice.

@jorge789
Copy link

jorge789 commented Feb 6, 2020

Tested on PixRacer V4

Flight Card 1

Modes Tested:
Position Mode: Good.
Altitude Mode: Good.
Stabilized Mode: Good.

Procedure:
Arm and Take off in position mode, after flying for approximately one minute, switched to altitude then stabilized mode.

Notes:
No issues were noted, good flight in general.

Logs: https://review.px4.io/plot_app?log=6c33763b-dd5f-4652-849b-d6591b9c74a0

Flight Card 2

Modes Tested
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure

Armed form QGC.
Took-off on mission plan mode
. Note that commands were sent form QGC (Armed and takeoff)
Once all waypoint completed vehicle switched to RTL and landed as expected.
Good flight in general.
Note:
No issues were noted, good flight in general.

Logs: https://review.px4.io/plot_app?log=50319699-7e95-4ae7-9b35-80f6bbded185

Flight Card 3

Modes Tested
Position Mode: Good.
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Take off in position mode, after flying for approximately one minute, switched to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint then trigger RTL.
Note:
Good flight in general.

Note:
No issues were noted, good flight in general.

Logs: https://review.px4.io/plot_app?log=d69037d1-b9ce-41e6-9755-6128d316c38a

Log
Master comparison
https://review.px4.io/plot_app?log=fa512e8c-2c4d-454e-9f45-5a71a2bf66fa

@Junkim3DR
Copy link

Tested on NXP FMUK66 v3

Flight Card 1

Flight Card 2

  • Modes Tested

  • Mission Plan Mode (Automated): Good.

  • RTL (Return To Land): Good.

  • ProcedureArm and Take off in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once all waypoints are completed make sure vehicle triggers RTL.

  • Notes
    Good flight in general.

  • Log
    https://review.px4.io/plot_app?log=75dfd017-3691-48bc-baad-27551c7763c9

Flight Card 3

  • Modes Tested

  • Position Mode: Good.

  • Mission Plan Mode (Automated): Good.

  • RTL (Return To Land): Good.

  • Procedure
    Arm and Take off in position mode, after flying for approximately one minute, switched to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC.

  • Notes
    Good flight in general.

  • Log
    https://review.px4.io/plot_app?log=87d5e48a-9924-4e66-ac93-bd24a820bd94

Comparison Master

  • Modes Tested

  • Position Mode: Good.

  • Altitude Mode: Good.

  • Stabilized Mode: Good.

  • Mission Plan Mode (Automated): Good.

  • RTL (Return To Land): Good.

  • Procedure
    Arm and Take off in position mode, after flying for approximately one minute, switched to altitude then stabilized mode proceed to switch to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint then trigger RTL.

  • Notes
    No issues noted, good flight in general.

  • Log
    https://review.px4.io/plot_app?log=4ae02f40-0287-49ee-a4ab-06d667bafdcb

@dagar
Copy link
Member Author

dagar commented Mar 12, 2020

Are we good to go here?

@jlecoeur
Copy link
Contributor

jlecoeur commented Mar 12, 2020 via email

Copy link
Member

@MaEtUgR MaEtUgR left a comment

Choose a reason for hiding this comment

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

I still consider it useful given the current filter producing the angular acceleration state is configured the same way as the derivative term filter before. Note that there was a sample rate detection (kind of related: #14303).

@dagar
Copy link
Member Author

dagar commented Mar 12, 2020

Thanks everyone. I'll get the documentation updated for the release.

@dagar dagar merged commit 093e9ba into master Mar 12, 2020
@dagar dagar deleted the pr-mc_vehicle_angular_acceleration branch March 12, 2020 19:07
@bkueng
Copy link
Member

bkueng commented Mar 13, 2020

I'm missing the parameter transition support. It would make this considerably more user-friendly.

@dagar
Copy link
Member Author

dagar commented Mar 13, 2020

I'm missing the parameter transition support. It would make this considerably more user-friendly.

Good idea. #14389

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.

7 participants