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

move hover_thrust_estimator to new module (mc_hover_thrust_estimator) #14182

Merged
merged 8 commits into from
Mar 12, 2020

Conversation

dagar
Copy link
Member

@dagar dagar commented Feb 18, 2020

This is a quick PR that moves the hover_thrust_estimator (#13981) lib and mc_pos_control integration into a new standalone module (now called mc_hover_thrust_estimator for MC grouping).

Pros

  • can be easily included or excluded as needed (flash, systems where it's not needed/wanted for whatever reason)
  • run at lower priority on the side
  • possibly run at a lower rate (decoupled from controllers and real-time requirements)
  • could be updated to operate in stabilized mode as well
  • parameter culling for non-MC builds (tiny benefit)

Cons

  • lost integration with MPC takeoff state
    • possibly questionable coupling with the land detector (I added a reset() if landed or disarmed).
  • a bit more overhead (mainly flash per ModuleBase)

To be honest after having done this I could go either way on this one.

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 a lot! I'll make the required modifications and it should be good to go.

_armed = (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED);
}

if (_armed && !_landed) {
Copy link
Member

Choose a reason for hiding this comment

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

We can add a check here to start the estimator only when the the drone is above 1m AGL or x seconds after !_landed.


_hover_thrust_ekf.predict(dt);

if (PX4_ISFINITE(local_pos.az) && PX4_ISFINITE(local_pos_sp.thrust[2])) {
Copy link
Member

Choose a reason for hiding this comment

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

We could even take the body thrust from the controller outputs and rotate it in local frame so the estimator will be able to run in all modes.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was tempted to do that immediately, but thought it might be safer to first reproduce things as closely as possible outside of mc_pos_control.

Copy link
Member Author

Choose a reason for hiding this comment

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

@bresch
Copy link
Member

bresch commented Feb 24, 2020

The estimator module now constantly publishes an estimate even when the estimator isn't running (on ground) to be a proper substitute of MPC_THR_HOVER for the land detector and the position controller.

Tested in SITL with a wrong initial thrust estimate and changing the weight on the vehicle during flight:
2020-02-24_22-18-15_01_plot

@bresch bresch marked this pull request as ready for review February 24, 2020 21:41
bresch
bresch previously approved these changes Feb 24, 2020
* (EXPERIMENTAL) Set true to use the value computed by the hover thrust estimator
*
* @boolean
* @max 0
Copy link
Member

Choose a reason for hiding this comment

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

@dagar Does that work? Since this is experimental, I would like to have to click on "force save" to enable it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's change the category.

@bresch
Copy link
Member

bresch commented Feb 26, 2020

@PX4/testflights Could you please test this PR on a multicopter in altitude/position and auto mode please?

  • You would need to set MPC_USE_HTE to 1.
  • Make sure that you are ready to switch to stabilized/manual mode if something goes wrong.
  • This PR mostly affects the vertical thrust and the land detector.

@dannyfpv
Copy link

dannyfpv commented Feb 28, 2020

tested on pixhawk4 v5 f-450
Modes Tested*

Position Mode: Good.
Altitude Mode: Good.
Stabilized Mode: Good.
Mission Plan Mode (Automated): Good.
RTL: 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 waypoin activate RTL

Notes:
No issues noted, good flight in general.

Log:

https://review.px4.io/plot_app?log=38b3ef8f-1e04-4464-8220-c867c850645c

@jorge789
Copy link

Tested on PixRacer V4

Tested Modes
Position Mode: Good
Altitude Mode:
Good.
Mission plan mode (automated): good.
RTL (Return To Land): Good.

Process
Arm and take off in position mode, after flying for approximately one minute, switch to Altitude mode and then to mission plan and then make sure that the vehicle follows all the waypoints as shown in QGC, after completing all waypoints and then switch to RTL.
Note:
MPC_USE_HTE parameter was changed from 0 to 1

Logs:
https://review.px4.io/plot_app?log=82ee3e29-5422-450b-8030-df6a93b81a88

https://review.px4.io/plot_app?log=f484d2ef-2e59-442e-aa05-c0ecff3fdf36

Tested on CUAV nano V5

Tested Modes
Position Mode: Good
Altitude mode:
Good.
Mission plan mode (automated): good.
RTL (Return To Land): Good.

Process
Arm and take off in position mode, after flying for approximately one minute, switch to Altitude mode and then to mission plan and then make sure that the vehicle follows all the waypoints as shown in QGC, after completing all waypoints and then switch to RTL.
Note:
MPC_USE_HTE parameter was changed from 0 to 1

Log:
https://review.px4.io/plot_app?log=939dd9d3-8ecb-485a-8144-4d7ee861020b

https://review.px4.io/plot_app?log=1cf3a958-3618-4a06-9ab5-51fd66f00f38

@Junkim3DR
Copy link

Tested on NXP FMUK66 v3

Modes Tested

  • Position Mode: Good.
  • Altitude Mode: Good.
  • Stabilized Mode: Untested.
  • 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.

Logs
https://review.px4.io/plot_app?log=533e3823-11d2-4610-a0b4-b2343a64b5c2

Tested on Pixhawk 3 v4Pro

Modes Tested

  • Position Mode: Good.
  • Altitude Mode: Good.
  • Stabilized Mode: Untested.
  • 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.

Logs
https://review.px4.io/plot_app?log=a9ef5fab-73a6-429e-81e0-41eadc901583

@dagar
Copy link
Member Author

dagar commented Mar 10, 2020

After a merge this is now fitting everywhere (for now at least).

The unit test is failing.
Screenshot from 2020-03-10 10-39-07

@bresch
Copy link
Member

bresch commented Mar 10, 2020

@dagar yes, and the failures are real. I'm currently fixing that

local_position.z is relative to the origin of the EKF while dist_bottom
is above ground
@bresch
Copy link
Member

bresch commented Mar 11, 2020

@dagar Good to be merged now, I'll update the default tuning in a separate PR.

bresch
bresch previously approved these changes Mar 11, 2020
@dagar dagar merged commit f9794e9 into master Mar 12, 2020
@dagar dagar deleted the pr-hte_module branch March 12, 2020 01:20
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.

5 participants