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

0 bank angle for GPS failure on landing #13795

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Kjkinney
Copy link
Contributor

Describe problem solved by this pull request
On landing currently if an airplane enters a gps failure state, the plane will enter a fixed bank loiter, beginning a circle while on the landing path. What this does is allows the plane to instead keep the wings level in a failure instead of spiraling away from the land point.

Describe your solution
This commit checks if the plane is landing or not, and in a failure state. If so the navigator publishes a 0 bank angle in order to keep the plane heading towards the land point. Otherwise fixed bank loiter behaves exactly the same.

Describe possible alternatives
I used an alternate way of determining if the plane was landing within navigator_main. This version moves everything into gpsfailure. There might be a redundant boolean within the if statement currently.

Test data / coverage
This was tested in SITL in multiple different stages of flight to confirm nothing was broken when creating this.

https://review.px4.io/plot_app?log=683a837c-86d6-4d17-9330-2a47a87cc89f

Additional context
We have been flying with a different version of this on our own Fixed Wings for 6 months

@Antiheavy

…hicle is on slope for landing and enters a gps failure mode, the vehicle will continue straight ahead with wings level. Otherwise it behaves normally.
//This determines if the fixedwing vehicle is landing or not, and if so it forces the wings level
//Otherwise the plane goes to the parameter set fixed bank loiter setting

if (stat->nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_LANDGPSFAIL
Copy link
Member

Choose a reason for hiding this comment

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


if (stat->nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_LANDGPSFAIL
&& pos_sp_triplet->current.type == position_setpoint_s::SETPOINT_TYPE_LAND) {
att_sp.roll_body = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
att_sp.roll_body = 0;
att_sp.roll_body = 0.0f;

//Otherwise the plane goes to the parameter set fixed bank loiter setting

if (stat->nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_LANDGPSFAIL
&& pos_sp_triplet->current.type == position_setpoint_s::SETPOINT_TYPE_LAND) {
Copy link
Member

Choose a reason for hiding this comment

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

To be paranoid, also check that it's valid

Suggested change
&& pos_sp_triplet->current.type == position_setpoint_s::SETPOINT_TYPE_LAND) {
&& pos_sp_triplet->current.t.valid && (pos_sp_triplet->current.type == position_setpoint_s::SETPOINT_TYPE_LAND)) {

@Kjkinney
Copy link
Contributor Author

Kjkinney commented Jan 2, 2020

Adding the way-point validity check to this breaks it currently. When it enters the fail safe mode, the current waypoint becomes invalid leading to it still using the fixed-bank loiter setting.

@Kjkinney
Copy link
Contributor Author

Kjkinney commented Jan 2, 2020

Here is a log with the waypoint validity check: https://review.px4.io/plot_app?log=9f8842c3-bec7-4984-a6d8-03611e6d47a5

And here is a log without it: https://review.px4.io/plot_app?log=505571cc-7a93-4201-9367-80aa66963dcc

@dagar
Copy link
Member

dagar commented Jan 3, 2020

Adding the way-point validity check to this breaks it currently. When it enters the fail safe mode, the current waypoint becomes invalid leading to it still using the fixed-bank loiter setting.

Ok we'll need to think of something else then. What if you do the check in GpsFailure::on_activation()? Then GpsFailure could store a flag for was_landing and check that in the GPSF_STATE_LOITER case.

@Kjkinney
Copy link
Contributor Author

Kjkinney commented Jan 3, 2020

Could we use Navigator::on_mission_landing() in the GpsFailure::on_activation() to store the was landing flag?

And would we want to do it in the GpsFailure::on_inactive() rather than on_activation() so that we don't run into any invalid issues with the gps failure activating?

EDIT
Just did a quick test using was_landing = _navigator->on_mission_landing(); within GpsFailure::on_inactive() and then checking it in the GPSF_STATE_LOITER case. It is working consistently at the moment.

} else {
att_sp.roll_body = math::radians(_param_nav_gpsf_r.get());
}

att_sp.pitch_body = math::radians(_param_nav_gpsf_p.get());
att_sp.thrust_body[0] = _param_nav_gpsf_tr.get();
Copy link
Member

Choose a reason for hiding this comment

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

Does it still make sense to use the same gps failsafe throttle? This might result in a fly away if misconfigured

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point! Should we also force throttle to 0 if already landing?

Copy link
Contributor

Choose a reason for hiding this comment

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

After thinking about it more I think we should also force throttle to 0. If the vehicle was already landing, the intent is to get on the ground. In this case the best course of action is to continue wings level and cut throttle to ensure the vehicle gets on the ground. @Kjkinney can you add this code and code comments explaining why?

@Kjkinney
Copy link
Contributor Author

Kjkinney commented Jan 9, 2020

I added the changes above. Here is a SITL test log

https://review.px4.io/plot_app?log=aff020ae-2efd-49ad-a207-30879d642283

Antiheavy
Antiheavy previously approved these changes Jan 9, 2020
@Antiheavy
Copy link
Contributor

This PR will close this issue once approved and merged. #10906

@dagar is anything else required?

Copy link
Contributor

@julianoes julianoes left a comment

Choose a reason for hiding this comment

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

I agree with the functional change but not with the implementation.

You are essentially changing the state called GPSF_STATE_LOITER, however, the more appropriate way to implement this would be to add a state, e.g. GPSF_STATE_LAND.

This has the benefit that you can announce the action correctly in on_activation(). Right now, it will display "Global position failure: fixed bank loiter" even though it is about to land which can be confusing for the operator.

I would therefore add a state and then check in advance_gpsf() which state you should go to depending on the was_landing flag. Then you can implement the correct setpoint in the respective state in on_active().

Do you think that would make sense?

@RomanBapst
Copy link
Contributor

I agree that it would make more sense to split the two cases.

@stale
Copy link

stale bot commented Apr 14, 2020

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

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.

6 participants