-
Notifications
You must be signed in to change notification settings - Fork 16.8k
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
Plane4.0 QGC4.0 GeoFence not working #13700
Comments
Correct patch is probably to add a line here: https://github.com/ardupilot/ardupilot/blob/master/ArduPlane/GCS_Mavlink.cpp#L1396 and remove the Did you want to make up a Pull Request or shall I do it? |
Thanks for the quick response. You can make a pull request. Thanks! |
@peterbarker |
Are you using mavlink2? |
@peterbarker I used
QGC is reporting mavlink_version 3 (uint8_t) |
On Sat, 29 Feb 2020, nnewsted wrote:
sim_vehicle.py -L KSFO -C --mavversion 2.0
QGC is reporting mavlink_version 3 (uint8_t)
OK, I just had a play here, and my memory is returning.
Plane's geofence stands alone at this point, and given QGC's fence upload
code now solely uses the new protocol, it's not going to work.
You'll need MissionPlanner or MAVProxy or Solex(perhaps?) or some other
GCS which uses the old mission upload protocol to do the upload.
Wrangling things this way did make sense - things do seem to be solid on
the other vehicles. But I should revisit moving Plane to using AC_Fence
for handling its fence.
|
Ah, didn't know that. That said it still leaves the problem of the firmware not sending the AUTOPILOT_VERSION message to the gcs at all even though it acked the request. |
@DonLakeFlyer which version of the firmware isn't sending back the I've expanded our "get capabilities" test to run on all vehicles now, and it does seem to work on Plane; I've attacked a bit of the telemetry log on the PR: #13707 |
@peterbarker That makes sense on why adding capabilities enables fence capability but qgc gets unsupported return. I ran it down to a call somewhere in the GCS library.
|
@peterbarker I was running master ArduCopter and ArduPlane SITL. Important thing to note is you have to use non-mavProxy version of SITL. The command line I'm using is in the QGC issue. If you use the version which runs mavproxy in the middle you don't really get the correct look at how ArduPilot runs with QGC. |
@peterbarker I was also able to reproduce with a USB connection with latest stables 4.0 stable of Plane connected to a PixRacer. |
@rmackay9 I debugged this myself with printfs in the firmware code. The sequence of calls is this:
|
Should have said this is printf testing with ArduPilot master and ArduCopter. The QGC issues is here: mavlink/qgroundcontrol#8440. It has additional details on the command line I'm using to test. |
@DonLakeFlyer I get it just fine with master ArduPlane sitl (and I'm using my GCS and not the mavproxy/sim_vehicle wrapper). A key point though is we don't do anything useful with the first request for some reason:
Note that I had to request it a third time before I actually got a useful response. EDIT: I'm not sure why, that does seem like a bug somewhere in ArduPilot, but we do actually send it out. |
Exactly! If I get a positive ack for the command so I don't retry. Hence QGC pukes on the first one. |
That doesn't make sense though. You have to retry, because the transport mechanism could be a lossy radio link. If you don't retry then you will randomly just get bad information when connecting with a telemetry radio. |
Yup. Realize that now and I'll fix that. That said, there is still the concerning fact that the first request is lost. |
@WickedShell Curious as to what you use for timeout values? Both for retry on you didn't get an ack and retry you got the ack but didn't get the message after that. QGC uses 3 seconds to wait for the ack. Which in turn means since ArduPilot doesn't respond to the first request vehicle connection completion will be delayed by 3 seconds. |
@DonLakeFlyer I actually don't use an explicit timeout, it's part of my connecting state machine though, when I'm in the waiting for |
@WickedShell Ok, interesting. But after how long do you give up and report an error? |
@DonLakeFlyer at that point forever, and I wait for a user to choose to cancel it. I won't actually let you do anything though until after I've received the capabilities bits. This is the only blocker I actually have on connecting. I need to both strictly validate that it's the type of vehicle I expect, and that it can support |
So I fix this and just run into the next problem:
ArduPilot won't report fence/rally support unless QGC switches the link to mavlink 2 prior to asking for capabilities. |
More testing shows this isn't really the case. The fence/rally bits sent to QGC seem to be somewhat random sometimes they say sometimes they are one, sometimes they are off. Not sure what triggers it. @rmackay9 This is likely what you ran into as well with your repro suddenly coming/going. I'm going to just give up on this capability bit crap with respect to fence/rally and hardwire them for ArduPilot in QGC code. |
@DonLakeFlyer |
I'll see if I can track it down. With respect to mavlink 2 capability bit. How am I supposed to use that to determine whether QGC should be sending mavlink 2 or not? The bit seems to be set even when SERIAL0_PROTOCOL is set to mavlink 1. So if this sequence happens:
According to mavlink spec QGC should switch to mavlink 2. Is that correct with respect to ArduPilot? Seems a bit odd if I specifically set SERIAL0_PROTOCOL to mavlink 1. All testing in SITL. |
For the lost capabilities-bits message: #13727 |
Here's the initialisation logic: https://github.com/ardupilot/ardupilot/blob/master/libraries/GCS_MAVLink/GCS_Common.cpp#L149 ... and there's the magic switching logic: https://github.com/ardupilot/ardupilot/blob/master/libraries/GCS_MAVLink/GCS_Common.cpp#L1292 Here's where we set the capability bit: Please note the special exception for CHAN0 - to allow people to recover after bad experiments with mavlink2: https://github.com/ardupilot/ardupilot/blob/master/libraries/GCS_MAVLink/GCS_Common.cpp#L162 My reading is that we should only ever be setting the capability bit if the channel is configured as a mavlink2 channel. Do you have a log showing a channel configured as mavlink1 but indicating it is mavlink2? |
@WickedShell Was saying it is likely related to my SITL testing connection (which is over TCP) is not being related to SERIAL0_PROTOCOL settings. Hence it may just be a SITL artifact and not a real problem. |
@DonLakeFlyer you can probe to see which are the relevant parameters by sending the adjust-streamrates message and seeing which parameters change (e.g. |
K, thanks. Let me try to get some concrete repros. |
@peterbarker I'm currently looking into fences with plane and QGC. Is this something that's being worked on? I've got a very rudimentary version of If it's not something being worked on, I can pull together a PR? QGC support for fences would be great. |
On Sun, 16 Aug 2020, James O wrote:
@peterbarker I'm currently looking into fences with plane and QGC. Is this something that's being worked on? I've got a very rudimentary version of
It isn't something actively being worked on AFAIK.
I really wish I'd worked harder on Plane support when I did the original
polyfence code and someone was happy to pay for that work.
AC_Fence running with plane stable - it currently relies on GEOFENCE_ENABLED being disabled and is only reporting fence breaches.
I do have several branches around here which go part-way to integration
with Plane, taking a more evolutionary approach to the problem than the
one you suggest here. I believe
https://github.com/peterbarker/ardupilot/tree/wip/plane-polyfence-loader
was my most recent attempt at it.
If it's not something being worked on, I can pull together a PR? QGC support for fences would be great.
Would be nice to see a branch, at least. I might say that it's the
integration with Plane which is the hard bit - fencing is one of our most
safety-critical features and present on vast number of safety cases for
companies using ArduPlane so we have to be really, really careful not to
break it :-)
Also note there's no way this goes straight into Plane stable :-)
|
Just taken a quick look at what you have on that Edit: Perhaps the other question here is what does |
On Sun, 16 Aug 2020, James O wrote:
Just taken a quick look at what you have on that wip branch - is there a reason to straight use the AC_PolyFence_loader and not the full AC_Fence class?
Apart from it keeps most of the plane fence implementation the same (which was the biggest issue I ran into)
Exactly the latter. Small-steps was the concept. This would only have
been a stepping-stone to using all of AC_Fence.
Might it be better to just rip the scab off in one go?
|
Good to know we're not opposed to going that route. I'll take a look at pulling a branch together then. :-) Cheers |
It appears Plane and
|
Here's some preliminary work on AC_Fence support in Plane: https://github.com/SYPAQ/ardupilot/tree/wip/plane_ac_fence This work is all being tested on the latest release of QGC (at this time, v4.0.10). Right now, the floor is enabled in The I'll look at adding/updating the autotests to address this too. For testing so far it's been FBW and missions designed to be out of bounds. I've attached the fences and missions I've used. |
On Mon, 24 Aug 2020, James O wrote:
Here's some preliminary work on AC_Fence support in Plane: https://github.com/SYPAQ/ardupilot/tree/wip/plane_ac_fence
Cool!
Right now, the floor is enabled in complete_auto_takeoff and disabled again at the start of the landing sequence do_land - otherwise we're in a situation
being outside the fence on auto-launch, so go straight to Return to fence breach point, etc. Same applies to landing, going below the fence to land
causing a fence breach.
The geofence.cpp used an Autoenable parameter, and a local enabled value, and enabled/disabled fences appropriately during takeoff/landings. How should we
best approach this? It almost makes sense to enable the floor if ALT_MIN is a non-zero value (for vehicles in the sky) but then I'm not sure how that
pertains to Rover/Sub?
Huh. I think you see why I was starting with just using the polyfence
loader rather than trying to attack the logic in Plane :-)
We will need to emulate the existing behaviours and use the autoenable
parameter.
I'll look at adding/updating the autotests to address this too. For testing so far it's been FBW and missions designed to be out of bounds. I've attached
the fences and missions I've used.
Sooner you write these tests the more value you will get out of them.
One thing to also note - we do need the old fencepoint protocol to
continue to work, too. For a year or two at least.
|
:-P I think I'm starting to see why you did too. But that scab has to come off sooner-or-later.
Okay, I'd be looking to extend the current
Fair call - I'll cross-reference the other build variants and see how they're set up to test fences. Need to ensure the additional functionality is well tested. eg. floor,
Could you clarify the |
On Mon, 24 Aug 2020, James O wrote:
Could you clarify the old fencepoint protocol? It looks like the file generated when saving a fence is the same between geofence and AC_Fence.
https://github.com/ardupilot/ardupilot/blob/master/ArduPlane/GCS_Mavlink.cpp#L1173
There is compatability code in place in the base class for that object -
Plane overrides and does its own thing. It will probably need to stop
doing *quite* so much overriding.
|
The more I work on it, the more complex this becomes. I've been looking at autotest, and comparing to ArduCopter as a reference. I've found Copter is using the param Any suggestions on how to move forward on this?
Though I'm leaning toward 3 now, I've concern there's then two parameters to enable/disable the fence. I'm also not sure what to think about Not sure who to ping directly, so thoughts from anyone for any vehicle appreciated! :-) |
tl;dr: What should we use to determine a fence is present? enabled? healthy? Another question, where can I find a description of what eg. I would've said:
|
#15288 has been merged in master, place fences work fine in QGC now. Closing |
Thanks for your support on this one @amilcarlucas and team. |
Bug report
Issue details
ArduPlane 4.0 is not reporting vehicle capabilities correct. Posted on QGC issues
https://github.com/mavlink/qgroundcontrol/issues/8440
Thanks to @DonLakeFlyer.
GCS_Common.cpp
if (AP::fence()) { // FIXME: plane also supports this... ret |= MAV_PROTOCOL_CAPABILITY_MISSION_FENCE; }
I added to GCS_Common.cpp:
capabilities() | MAV_PROTOCOL_CAPABILITY_MISSION_FENCE,
Plane now will report correct capabilities to QGC but still will not ack it received the fence. From QGC:
However, when I built ArduCopter from Plane4.0 I am able to upload fence in QGC. See second log below.
Version
Plane4.0, QGC 4.0
Platform
[ ] All
[ ] AntennaTracker
[ ] Copter
[ x] Plane
[ ] Rover
[ ] Submarine
Airframe type
SITL
Hardware type
SITL
Logs
---PLANE4.0 output----
Waiting for heartbeat from tcp:127.0.0.1:5760
MAV> Got MAVLink msg: COMMAND_ACK {command : 519, result : 3}
APM: ArduPlane V4.0.5beta1 (a194372)
APM: 1b10b0c1bb704959abf84b3ba43aa658
online system 1
INITIALISING> Mode INITIALISING
Received 1200 parameters
Saved 1200 parameters to mav.parm
APM: Barometer 1 calibration complete
APM: Airspeed calibration started
APM: Ground start complete
MANUAL> APM: Throttle failsafe off
APM: GPS 1: detected as u-blox at 115200 baud
APM: EKF2 IMU0 initial yaw alignment complete
APM: EKF2 IMU1 initial yaw alignment complete
Mode MANUAL
APM: Airspeed 1 calibrated
APM: EKF2 IMU0 tilt alignment complete
APM: EKF2 IMU1 tilt alignment complete
APM: EKF2 IMU0 origin set
APM: EKF2 IMU1 origin set
APM: Flight plan received
Got MAVLink msg: MISSION_ACK {target_system : 255, target_component : 190, type : 0, mission_type : 0}
Got MAVLink msg: MISSION_ACK {target_system : 255, target_component : 190, type : 3, mission_type : 1}
Got MAVLink msg: MISSION_ACK {target_system : 255, target_component : 190, type : 0, mission_type : 2}
APM: EKF2 IMU0 is using GPS
APM: EKF2 IMU1 is using GPS
Flight battery 100 percent
---Copter Output---
MAV> APM: Calibrating barometer
Got MAVLink msg: COMMAND_ACK {command : 519, result : 3}
APM: ArduCopter V4.0.2-rc3 (a194372)
APM: 1b10b0c1bb704959abf84b3ba43aa658
APM: Frame: QUAD
online system 1
STABILIZE> Mode STABILIZE
Received 1176 parameters
Saved 1176 parameters to mav.parm
APM: Barometer 1 calibration complete
Init Gyro***
Ready to FLY APM: GPS 1: detected as u-blox at 115200 baud
APM: EKF2 IMU0 initial yaw alignment complete
APM: EKF2 IMU1 initial yaw alignment complete
APM: EKF2 IMU0 tilt alignment complete
APM: EKF2 IMU1 tilt alignment complete
APM: Flight plan received
Got MAVLink msg: MISSION_ACK {target_system : 255, target_component : 190, type : 0, mission_type : 0}
APM: Fence Indexed OK
Got MAVLink msg: MISSION_ACK {target_system : 255, target_component : 190, type : 0, mission_type : 1}
Got MAVLink msg: MISSION_ACK {target_system : 255, target_component : 190, type : 0, mission_type : 2}
APM: EKF2 IMU0 origin set
APM: EKF2 IMU1 origin set
The text was updated successfully, but these errors were encountered: