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

Add acceptance_radius back to MissionItem #1443

Merged
merged 9 commits into from
May 28, 2021

Conversation

bazfp
Copy link
Collaborator

@bazfp bazfp commented May 24, 2021

Appears this added in a previous PR but disappeared during a refactor. It's a useful option to have as sometimes the defaults are causing some items to never be achieved in our SITL testing (We've now swapped to MissionRaw)

Happy to update the factory funcs + proto to include this, unless there's a reason it was removed :)

Copy link
Collaborator

@JonasVautherin JonasVautherin left a comment

Choose a reason for hiding this comment

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

I am fine with adding it, but you should do it by adding it to the mission.proto definition and generate the code.

E.g. mission.h is not a file you change manually, right?

Copy link
Collaborator

@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.

Oh, did this get lost? I wonder how? Thanks for the contribution @bazfp. And as @JonasVautherin wrote, please change it in the proto repo:
https://github.com/mavlink/MAVSDK-Proto/blob/main/protos/mission/mission.proto#L175

@bazfp
Copy link
Collaborator Author

bazfp commented May 24, 2021

Thanks guys

mavlink/MAVSDK-Proto#229

JonasVautherin
JonasVautherin previously approved these changes May 24, 2021
Copy link
Collaborator

@JonasVautherin JonasVautherin left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a lot!

if (item.is_fly_through) {
if (std::isfinite(item.acceptance_radius_m)) {
acceptance_radius_m = item.acceptance_radius_m;
} else if (item.is_fly_through) {
// _acceptance_radius_m is 0, determine the radius using fly_through
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not related to this PR, but I don't get this comment. @julianoes would you have some insights about it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Me neither 🤔

@JonasVautherin
Copy link
Collaborator

@bazfp: some integration tests are still failing, actually. Please pull my latest changes, I updated your branch and the proto submodule 👍

@bazfp
Copy link
Collaborator Author

bazfp commented May 24, 2021

@bazfp: some integration tests are still failing, actually. Please pull my latest changes, I updated your branch and the proto submodule 👍

Seems to be failing due to the NAN acceptance_radius logic. It sets the radius to 1 or 3 depending on flythrough if we don't explicitly set the acceptance_radius, which means the downloaded mission back doesn't match the one we sent if it was NAN.

I could try and work backwards and set the acceptance_radius to NAN if it's 1 or 3 depending on flythrough, but then you could break it if you set it explicitly to 1!

julianoes
julianoes previously approved these changes May 25, 2021
@JonasVautherin
Copy link
Collaborator

It sets the radius to 1 or 3 depending on flythrough if we don't explicitly set the acceptance_radius, which means the downloaded mission back doesn't match the one we sent if it was NAN.

@julianoes are 1 and 3 some "standard" defaults? I guess MAVSDK does that because sending NAN to PX4 results in an invalid waypoints?

@bazfp would you mind trying to remove the logic that sets it to 1 or 3 and leave it to NAN instead?

I would be tempted to say that if there is a default, it should be set on the PX4 side, not in MAVSDK... 🤔

@bazfp bazfp dismissed stale reviews from julianoes and JonasVautherin via 9ed0a20 May 25, 2021 13:48
@bazfp
Copy link
Collaborator Author

bazfp commented May 25, 2021

I've removed the offending section that was setting the acceptance radius.

I could set the acceptance radius default to be 1.0m in the proto definition. It wouldn't account for flythrough waypoints anymore but that logic could go anywhere else.

@JonasVautherin
Copy link
Collaborator

JonasVautherin commented May 25, 2021

I could set the acceptance radius default to be 1.0m in the proto definition.

I understand the idea, but I still believe that if the user does not set it, then it should be the responsibility of the autopilot to have a sane default (which may differ from a frame to the other). So I would keep it set to NAN and send that to the autopilot.

@julianoes
Copy link
Collaborator

For some reason SitlTest.MissionChangeSpeed is now broken and running indefinitely. It seems like that's actually related to this PR.

@julianoes
Copy link
Collaborator

@bazfp looks like it's still timing out. I'm gonna have a look tomorrow to see what's going on.

@julianoes
Copy link
Collaborator

Ok, I can reproduce it with PX4 v1.10. It looks like it's something that has been fixed on master. It never accepts the first mission item as "reached" although it is basically hovering there.

This reverts commit 9ed0a20.

It turns out these defaults are actually required because PX4 v1.9,
v1.10, v1.11 do not handle NAN properly and will be stuck forever at
a waypoint.

Also, it probably makes sense to keep the current implementation not to
break anyone using it that way.
@julianoes
Copy link
Collaborator

@bazfp I've added the defaults back in. It turns out they are required for PX4 v1.9, v1.10, v1.11 because PX4 gets stuck indefinitely with NAN. In PX4 master/v1.12 the acceptance radius is completely ignored which is wrong in my opinion and I'm going to fix.

@JonasVautherin
Copy link
Collaborator

Oh, my bad then 😅. Do you agree that PX4 should have a sane default if NAN is sent?

@julianoes
Copy link
Collaborator

@JonasVautherin yes, I agree. It should but it will take some time until we can rely on that. Or we need to have a version check to check for it.

@JonasVautherin
Copy link
Collaborator

No need for a version check, but it's good to see that it is fixed upstream. Will come some day 😊

@julianoes
Copy link
Collaborator

Aha, now CI fails because the check back for acceptance radius is not correct. Because we don't know if 1 or 3 meters are set on purpose or because of NAN 🤦. This is harder than expected.

@bazfp
Copy link
Collaborator Author

bazfp commented May 27, 2021

Could set the acceptance radius default to be 1.0m in the proto definition. It wouldn't account for flythrough waypoints anymore but that logic could go anywhere else.

One solution?

@julianoes
Copy link
Collaborator

@JonasVautherin the suggestion by @bazfp would work, right?

@JonasVautherin
Copy link
Collaborator

Yes, we could define to 1 in the proto, and then should we return an error code if the user sets it (explicitly) to NAN, since we know that it crashes on the PX4 side?

@julianoes
Copy link
Collaborator

julianoes commented May 27, 2021

@JonasVautherin hm, I would accept NAN but change it to NAN 1.0 unless we know we are connected to a PX4 new enough?

@JonasVautherin
Copy link
Collaborator

But in that case, should it be a default in the proto definition, or should we just hardcode that behavior? Because it seems like anyway we will hardcode parts of it...

@julianoes
Copy link
Collaborator

Hard-coding like we do right now is fine but the problem is that the test fails which checks if the downloaded items are equal to the ones uploaded.

@JonasVautherin
Copy link
Collaborator

But the proto file won't fix that, right?

@julianoes
Copy link
Collaborator

We would change the test not to use NAN, I suppose, but we could also do that already.

@JonasVautherin
Copy link
Collaborator

I would vote for that: the default in the proto file is "NAN", because it means "let PX4 choose", and that's what we want. And for versions earlier than 1.12, we have a fix that says "if it is NAN, set to 1". And in the test we don't use NAN, I guess we don't have a choice. So:

  • Keep the proto as it is
  • In mission_impl.cpp, change NAN for 1 (bonus: check the PX4 version and do it only if < 1.12)
  • In the tests, don't use NAN

How does that sound?

@julianoes
Copy link
Collaborator

Yes, that's great. I'll make the change.

We need to set the acceptance radius to something other than NAN.
Otherwise, NAN gets converted to a default and then fails the validation
if the mission items are still the same after an upload and download
cycle.
Copy link
Collaborator

@JonasVautherin JonasVautherin left a comment

Choose a reason for hiding this comment

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

Great! Thanks 🚀

@JonasVautherin JonasVautherin merged commit e93f108 into mavlink:main May 28, 2021
@julianoes julianoes added the bug label Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants