Closed andyp1per closed 9 months ago
@hamishwillee can you have a quick look - I think this is good to go, if you agree I'll pull it across to mavlink/mavlink
@auturgy Looks good to me. Once this is in mavlink/mavlink there might be differing opinions.
@hamishwillee
So just to clear, the intent is that if this appears in a mission, all subsequent geofences of the specified type(s) will be enabled/disabled until the next occurrence of the mission item, or the mission ends?
Yes, although that's not actually the problem I am trying to solve
What's the use case you're trying to solve?
The main issue is that ALT_MIN fences cannot be simply enabled and disabled at the same time as all the others. If you are on the ground you only want to enable the fences that make sense (for instance). In the air you might want something different. A single big fat enable flag makes all of this logic extremely convoluted - you have to have all kinds of exceptions to things. This allows the mavlink commands to actually DWIS as well as DWIM
It is a pity we can't get rid of that param1 value of 2 and have a more consistent command.
Yes I agree, but history
Not for this PR but we should probably change the description to remove the explicit mention of "mission command". YOu could reasonably use this in a command to enable or disable the default system geofence too.
Ah, so geofences are all default on. Your first mission item might be to disable the minimum alt fence. Then once flying enable all, and disable just the minimum fence again to land?
For takeoff I guess you might have some rule that says minimum fences don't apply until you have first exceeded them, but you'd still need some way to turn them off again in order to land. So this makes sense.
@auturgy I'm good with this.
So if we want to change the fence type (e.g. turn off CIRCLE
and turn on POLYGON
), we need to send two messages?
MAV_CMD_DO_FENCE_ENABLE(p1=DISABLE, p2=FENCE_TYPE_CIRCLE)
MAV_CMD_DO_FENCE_ENABLE(p1=ENABLE, p2=FENCE_TYPE_POLYGON)
Should we also add a new value to p1
called e.g. SET_FROM_BITMASK
such that we could combine the above into:
MAV_CMD_DO_FENCE_ENABLE(p1=SET_FROM_BITMASK, p2=FENCE_TYPE_POLYGON)
@auturgy @andyp1per I don't believe this particular implementation to address the stated use case is necessary.
Something more useful would be an approach for enabling/disabling an arbitrary set of inclusion and/or exclusion fences. We might do this using an approach similar to inclusion groups. Essentially you could give any type of fence you want to enable/disable a group number like MAV_CMD_NAV_FENCE_POLYGON_VERTEX_INCLUSION and then send a command to enable/disable that particular group.
I don't believe this particular implementation to address the stated use case is necessary.
Disagree. We would use something similar to https://github.com/ArduPilot/mavlink/pull/349#discussion_r1489982474 during flight testing is this was available:
Something more useful would be an approach for enabling/disabling an arbitrary set of inclusion and/or exclusion fences.
Yes, that would be more useful, but that capability doesn't exist now. I don't think you should reject a solution that works because there might be a better solution in the future.
Thanks. I'll make the upstream PR unless someone else beats me to it.
Thanks all!
Allows a bitmask to be passed to the fence enable function to specify individual fences to enable or disable
This has been done so that by not providing the second arg you get the current behaviour which is to enable and disable all fences