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

Implement ModuleParams inheritance in the MultiCopterLandDetector class. #12356

Merged
merged 3 commits into from
Aug 9, 2019

Conversation

mcsauder
Copy link
Contributor

Describe problem solved by the proposed pull request
This PR implements ModuleParams inheritance in the MultiCopterLandDetector class in following #12209.

Test data / coverage
This PR was test flown on a 250 size quad with pixhawk 4 mini, all tests performed identical to current PX4:master branch land detect behaviors:

  1. https://review.px4.io/plot_app?log=52aafa8a-aa07-4df7-8a3b-8ad48435718c
  2. https://review.px4.io/plot_app?log=2c14b7cd-701a-4247-80f8-3fdbcffa1530
  3. https://review.px4.io/plot_app?log=b571417e-0f10-4449-a4d9-88a6d71af96c

Additional context
This PR follows work in #12209 and streamlines remaining work for #9756.

@bkueng , @dagar . Please let me know if you have any questions on this PR. Thank you!

-Mark

@mcsauder
Copy link
Contributor Author

mcsauder commented Jun 27, 2019

@bkueng or @dagar, would you be willing to advise me on this fmu-v2 error?
error: 'MPC_LAND_SPEED' is not a member of 'px4::params'

UPDATED: I cannot compile fmu-v2_fixedwing or fmu-v2_rover on my local machine either. I am investigating. Thank you for your advice.

NOTE: This issue is occurring because the fixedwing build is not including the mc_pos_control module AND because land_detector_main.cpp IS including "MulticopterLandDetector.h"

This is an issue now because the usage of MPC_LAND_SPEED was previously encapsulated in the translation unit by being located in the *.cpp file. With this PR it fails because DEFINE_PARAMETERS is located in the (included) *.h file.

How can this be addressed?

@dagar
Copy link
Member

dagar commented Jun 28, 2019

This is because MPC_LAND_SPEED comes from the MC position controller, which isn't included in the fixedwing only builds.

Short term the easy workaround is to keep using the old API for that particular param. One idea longer term would be to restructure this so that each vehicle type has a land detector with all the common code moving to a library.

@mcsauder mcsauder force-pushed the multicopter_land_detector_module_params branch 3 times, most recently from 88fee3f to 416da5b Compare June 28, 2019 17:56
@mcsauder
Copy link
Contributor Author

mcsauder commented Jun 28, 2019

Short term the easy workaround is to keep using the old API for that particular param.

@dagar, I've implemented your suggestion, squashed commits, rebased against current upstream, and re-flight tested:

  1. https://review.px4.io/plot_app?log=38dda5c6-dc15-48fa-baa1-73162a69de0b
  2. https://review.px4.io/plot_app?log=06790127-8321-4daa-bb34-7af4c9c29e6b
  3. https://review.px4.io/plot_app?log=98517189-bcc1-4d31-8e9c-f6a420eeaf08

EDIT: All flight tests perform as expected, identical to the current master branch.

if (_param_update_sub.update(&param_update)) {
_update_params();
_freefall_hysteresis.set_hysteresis_time_from(false, (hrt_abstime)(1e6f * _param_lndmc_ffall_ttri.get()));
_param_lndmc_rot_max.set(math::radians(_param_lndmc_rot_max.get()));
Copy link
Member

Choose a reason for hiding this comment

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

I suppose you can get away with this, but it seems kind of shady (remote possibility of accidentally committing the value). I would do the math::radians call at runtime to keep it simple.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, that was wrong. Fixed, rebased against current master and squashed into one commit.

@mcsauder mcsauder force-pushed the multicopter_land_detector_module_params branch from cd634c1 to d5d13e7 Compare June 29, 2019 02:59
@mcsauder mcsauder force-pushed the multicopter_land_detector_module_params branch 2 times, most recently from cdfa90f to b10f096 Compare July 7, 2019 17:22
@@ -213,11 +204,11 @@ bool MulticopterLandDetector::_get_maybe_landed_state()
}

// Next look if all rotation angles are not moving.
float maxRotationScaled = _params.maxRotation_rad_s * landThresholdFactor;
float maxRotationScaled = math::radians(_param_lndmc_rot_max.get()) * landThresholdFactor;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dagar, the issue you highlighted is addressed here.

Copy link
Contributor Author

@mcsauder mcsauder Jul 7, 2019

Choose a reason for hiding this comment

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

Flight test land detection works properly and the value checks out when queried: https://review.px4.io/plot_app?log=9c628e6e-b90e-4d1b-9308-e6b5a8cc15b5

@mcsauder mcsauder force-pushed the multicopter_land_detector_module_params branch from b10f096 to e3d18aa Compare July 8, 2019 18:57
@mcsauder mcsauder force-pushed the multicopter_land_detector_module_params branch 2 times, most recently from 90784f9 to 31817d8 Compare July 16, 2019 18:22
@mcsauder mcsauder force-pushed the multicopter_land_detector_module_params branch from 31817d8 to 4b44ee6 Compare July 25, 2019 22:53
@mcsauder mcsauder force-pushed the multicopter_land_detector_module_params branch from 4b44ee6 to ba3dc67 Compare August 1, 2019 00:22
@mcsauder mcsauder force-pushed the multicopter_land_detector_module_params branch 2 times, most recently from f997b83 to df644a3 Compare August 6, 2019 17:41
@mcsauder
Copy link
Contributor Author

mcsauder commented Aug 6, 2019

Rebased on today's master and flight tested again, detection works as it should and the same as current master:

} _params{};

uORB::Subscription _actuator_controls_sub{ORB_ID(actuator_controls_0)};
uORB::Subscription _battery_sub{ORB_ID(battery_status)};
uORB::Subscription _param_update_sub{ORB_ID(parameter_update)};
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need this? It is handled in the base class already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @bkueng! Removed with upstream merge while resolving conflicts.

@mcsauder
Copy link
Contributor Author

mcsauder commented Aug 7, 2019

Re-flight tested after latest commit: https://review.px4.io/plot_app?log=487a2f0c-d3c1-4c86-8fd4-8d23361b5811

_params.maxRotation_rad_s = math::radians(_params.maxRotation_rad_s);
parameter_update_s param_update;

if (_param_update_sub.update(&param_update)) {
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to check for this, or call _update_params(). It is handled and called from the base class.
You can also keep _param_update_sub private.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great, thanks! That simplifies things. I pushed up that fix.

…tiCopterLandDetector can use it, add #include that appears to have been stripped by latest upstream merge.
@mcsauder mcsauder force-pushed the multicopter_land_detector_module_params branch from 7551aab to 33efd99 Compare August 8, 2019 15:01
@mcsauder
Copy link
Contributor Author

mcsauder commented Aug 8, 2019

Flight tested with latest commit and rebase against master: https://review.px4.io/plot_app?log=3b8762bc-156a-48a5-a5da-69c0425af7a4

@bkueng bkueng merged commit 056c800 into PX4:master Aug 9, 2019
@mcsauder
Copy link
Contributor Author

mcsauder commented Aug 9, 2019

Thank you @bkueng for your review and time spent! I appreciate it!

@mcsauder mcsauder deleted the multicopter_land_detector_module_params branch August 9, 2019 06:57
mcsauder added a commit to mcsauder/PX4-Autopilot that referenced this pull request Aug 9, 2019
bozkurthan pushed a commit to bozkurthan/Firmware that referenced this pull request Sep 4, 2019
bozkurthan pushed a commit to bozkurthan/Firmware that referenced this pull request Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants