-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Implements LocationGlobalRelative. #445
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
Conversation
|
@tcr3dr Well, if you get the current location when you're at the home position (immediately after this is set) that should have alt==0. The alt of the home location should be (usually) significantly greater than zero.I can't think of anything else. As noted in #306 this is all reasonable for Copter which only supports global and global relative frames, but may break on Plane, which also supports terrain following mode. It will also break on the local locations because we have no way to specify that a value is relative to the home location or to the vehicle current position. |
|
@hamishwillee So just to be clear:
Bullet #3 seems like it needs to be fixed. What other scenario would need to be correct? I'm also confused about how to behave in Plane but that is probably an omission from the MAVLink message docs. |
|
Hi @tcr3dr We probably need to know more about what ardupilot thinks it is sending. As you say, "is_relative=True means relative to ground" and this is what is returned (GLOBAL_POSITION_INT.relative_alt). But it is possible that ardupilot doesn't know where the ground is by default, so it is actually returning relative to home if it doesn't know height and relative to ground if it does. This would sort out the plane issue for terrain following. All guesses of course ... we need to ask/test. With respect to the other points ...if our global location is fed from GLOBAL_POSITION_INT.alt then yes, is_relative=False (ALT is actually fed from VFR_HUD right - which says it is in MSL?). BUT, why then are we actually seeing values that are relative to home - ie the alt of zero returned when sitting on the home position (which is IMO what we want)? |
|
Considering the difficulty in getting this right, and the testing required, perhaps we want to actually strip the |
|
@tcr3dr IMO We need to do this testing of what is in GLOBAL_POSITION_INT in order to confirm what information is being supplied in the What I hope is really sent in GLOBAL_POSITION_INT is both a relative and MSL value as indicated by the mavlink docs. The ideal change to the API would then be to expose both of these (rather than exposing one of them and using Bool to tell us which). The problem of course then being how we set a new location Yes we need to look at frames more broadly, especially in the context of goto functions that support velocity and/or position control, and relative to the vehicle itself. I'd like to do this testing. Can we leave this issue open and unfixed for DKPY2 release until I get around to it? |
|
@hamishwillee Sounds okay. I'd rather remove the |
|
@tcr3dr OK, I have done due diligence and I think we DO need to do "something" for DKPY2.0 because we have changed the meaning of location from DKPY 1 in an unhelpful way. So what we used to have was a In addition, we get the location position from GLOBAL_POSITION_INT but we get the alt (in MSL) from VFR_HUD. This is a bug - we should get the alt from GLOBAL_POSITION_INT, though we might choose to ALSO get it from the VFR_HUD. A little aside here about what the vehicle actually supplies before I explain my proposed solution. The vehicle supplies GLOBAL_POSITION_INT which includes the altitude in both relative and msl terms. The relative_alt is documented as "above the ground". Looking through the ardupilot code I believe that if it has a lidar or a terrain map vs GPS it will give you the actual height above ground. If you don't have those then it isn't so obvious how it works this out - but on Copter it appears that it uses inertial movement the home location ... and there is some other code there which adds and removes home location from the returned alt. I suspect that this is where the idea that the relative_alt is relative to home location comes from. I think the best solution is to give users what they are familiar with. That is, to remove the is_relative flag from |
cbd2fca to
ed7e3b5
Compare
|
Hi @tcr3dr Nicely done. I updated the alt so that the values are divided by 1000 (making them metres as for previous version). I've updated the documentation for all the associated classes in the init.py. Can you please sanity check. Problems:
This update to docs is not comprehensive. I will update everything else when I'm sure that the functionality is confirmed. |
Now investigating |
|
I could not find any plausible condition to detect |
|
I think this PR is in good shape to test again. |
|
Hi @tcr3dr @tcr3dr - This works as stated ... but of course I have more statements/questions. Re ensuring the first value of alt in the global must be non-zero, works fine on SITL. What would happen if you armed at sea level? The location attributes (e.g. Is it possible or a good idea to make I updated simple_goto.py to use global_frame_relative for reporting alt during takeoff. The alt values are all integers - previously these were floats. IMO this is a problem - we need a precision of better than metres. I updated most of the examples but only tested a few of them ... more to do once you come back to me. |
|
@hamishwillee It's speculative but the altitude value seems to vary pretty quickly—I suppose if someone were arming at sea level and had a perfect barometer, we would have issues. But otherwise the error threshold gets crossed in under a half second. Also, we can address this bug properly in the future pending more investigation. I'm good with creating *_frame and leaving its values unpopulated. If this weren't how we did it on Vehicle, I would say this is a worser design—but we have a precedent and Python is lenient. I'm not sure about populating .lat and .lon without .alt. Example: we can only emit one event for "global_frame". Is that when we have a 2D or 3D fix? Given our high-level abstraction I think it breaks the contract that a Frame should always be populated. I think having a global_2d_frame would be better if one wanted to deal with that case. The floats issue is a bug and we can test for regressions. |
Yes, looking forward to your fix for the integer alt! Thanks! |
|
@hamishwillee This PR is updated. Location objects always exist and just have None values when not populated. This actually has the side effect of .lat and .lon being populated independent of .alt, but the event is only emitted if we have all three. I think this is fine and we should document accordingly—the notification event is emitted only when we have a complete location. Take a look and lmk if this is good to merge. |
|
@tcr3dr Yes, this PR looking good. I've updated the docs appropriately. Feel free to merge. Note, this was quite a big change, affecting lots of examples. In particular, breaking compatibility might have got us. I won't feel confident on this until I retest all the examples. |
Implements LocationGlobalRelative.
See #306.
@hamishwillee What is a good test here, other than checking (on copter) that is_relative is False for
.location.global_frameand True for.home_location?