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

Land Detector Properties instead of one State #13170

Merged
merged 2 commits into from
Oct 16, 2019
Merged

Conversation

MaEtUgR
Copy link
Member

@MaEtUgR MaEtUgR commented Oct 12, 2019

Only look at the last commit: 3d3a57f
I based this pr on a rebased version of #11874 since I don't want to generate any conflicts. It's mergable after #11874.
✔️

Describe problem solved by the proposed pull request
Internally the land detector determines certain properties of the vehicle and some depend on each other e.g. if the vehicle is landed it is also maybe landed but others don't e.g. there can be ground contact but there's still ground effect distorting the barometer. Until now there was one single state determined from all these properties using prioritization and then all the original flags were published but because there the state was in between only one could be true at once. As a result:

  • people had to log or print the state of all the other flags to understand what's going on even though the flags were always there in the uORB message but not filled
  • when you wanted to check e.g. if you are in stage 1 or further in land detection you had to check for land_detected.ground_contact || land_detected.maybe_landed || land_detected.landed even though the first property always holds when the others hold
  • certain combinations like having ground contact but still having additional lift by ground effect were not possible at all

Describe your preferred solution
All properties are published like they are determined. Multiple properties can hold at the same time. Interdependencies of properties are covered by their respective detection functions.

Test data / coverage
I SITL tested and multicopter land detection still works fine:
land_detection_properties
You can see well that the flags turn on one after the other instead of switching on and off again one after the other.

@mcsauder
Copy link
Contributor

This will be an easy diff after #11874 . Looks great so far with the comments above. Nice work @MaEtUgR !

@MaEtUgR MaEtUgR force-pushed the land-detector-properties branch from 3d3a57f to f6dfe90 Compare October 14, 2019 16:50
@MaEtUgR
Copy link
Member Author

MaEtUgR commented Oct 14, 2019

@mcsauder Thanks! Let's get #11874 in then. 👍

@MaEtUgR MaEtUgR force-pushed the land-detector-properties branch from f6dfe90 to 383bd15 Compare October 14, 2019 19:34
@MaEtUgR MaEtUgR marked this pull request as ready for review October 14, 2019 19:42
@MaEtUgR
Copy link
Member Author

MaEtUgR commented Oct 14, 2019

I rebased, now it's the real diff ready for review.

bool freefall # true if vehicle is currently in free-fall
bool ground_contact # true if vehicle has ground contact but is not landed (1. stage)
bool maybe_landed # true if the vehicle might have landed (2. stage)
bool landed # true if vehicle is currently landed on the ground (3. stage)
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the logic ordering you did here.

const bool freefallDetected = _freefall_hysteresis.get_state();
const bool ground_contactDetected = _ground_contact_hysteresis.get_state();
const bool maybe_landedDetected = _maybe_landed_hysteresis.get_state();
const bool landDetected = _landed_hysteresis.get_state();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a great consolidation of logic here from _update_state(). Nice work!

.ground_contact = true,
.maybe_landed = true,
.landed = true,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this was intentional and it is correct to initialize to the new values you have, but just in case it was not intended I wanted to point out the master branch current constructor initialized values:

	_land_detected.ground_contact = false;
	_land_detected.maybe_landed = false;

Copy link
Member Author

Choose a reason for hiding this comment

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

We could leave this initializer like it was, the only place it get published is in the Run() method and there it also overwrites all of the struct content.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's good the way you have it. Just wanted to point it out in case. :)

.maybe_landed = false,
.ground_contact = true,
.maybe_landed = true,
.landed = true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here as previous comment above. I think these new values are the correct states to be initialized to. This looks good to me!

Copy link
Member Author

Choose a reason for hiding this comment

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

Here the initialization is useful since if there was no land detected published the position controller will assume the vehicle is landed and before only one flag was able to be true so it was landed, now it makes sense that landed implies maybe_landed and ground_contact.

Copy link
Contributor

@mcsauder mcsauder left a comment

Choose a reason for hiding this comment

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

Flight tested here on a 250 quad with pixhawk 4 mini. Everything looks to be in order from my viewpoint! Nice work @MaEtUgR !

.ground_contact = true,
.maybe_landed = true,
.landed = true,
};
Copy link
Member

Choose a reason for hiding this comment

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

missing setting of in_ground_effect.
Not used for multicopter, but seems better to set it too.

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 used for multicopter but in the estimator to stop fusing affected baro data into the altitude.

@dagar dagar merged commit 45a5372 into master Oct 16, 2019
@dagar dagar deleted the land-detector-properties branch October 16, 2019 04:50
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.

4 participants