Commit Graph

180 Commits

Author SHA1 Message Date
James O'Shannessy f6231db618 AC_Fence: Add breach calculation variant to use LLA
Adds a parameter to make selection between vector pos_cm from origin and lat/lng.
2021-03-04 10:31:58 +11:00
murata 3824277d11 AC_Fence: Add Smart RTL or LAND to the fence action 2021-03-03 07:59:03 +09:00
Peter Barker a0172fd2ca AC_Fence: emit a FENCE_STATUS message if we newly-breach the fences
This should resolve a problem in autotest where we don't detect the
fence as being breached as ArduPilot never announces the fact it has
breached - it just changes mode to RTL but the interval on the
FENCE_STATUS message never aligns with the time the vehicle is breached.
2021-02-23 08:28:02 +09:00
Patrick José Pereira 345fe1a9e4 AC_Fence: Add missing const in member functions
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2021-02-03 18:45:14 +11:00
Peter Barker c787231435 AC_Fence: remove timeout for waiting on fence semaphore, make nonblocking
Also move where we indicate we've attempted a load.
2020-11-11 18:46:22 +09:00
Peter Barker 53553c7c71 AC_Fence: remove dead and misleading assignment
This is never used again.  Presumably this was factored out of something
else where it might have mattered.
2020-08-06 17:02:12 +10:00
Rishabh 85692312ac AC_Fence: Add Pre-Arm check for margin < radius 2020-08-05 15:37:04 +09:00
murata b12fcff89a AC_Fence: Matching Message Style 2020-07-04 22:55:35 +10:00
Peter Barker 799c538c3e AC_Fence: ALT_MAX is Copter-and-Sub only 2020-06-16 11:21:47 +10:00
Rishabh b3a2b360e6 AC_Fence: clear breach if breached fence is not enabled 2020-06-16 08:27:19 +09:00
Peter Barker 973b103a4a AC_Fence: write log event when fence enabled or disabled 2020-06-09 10:52:19 +10:00
Peter Barker 069bd04bdc AC_Fence: create and use INTERNAL_ERROR macro so we get line numbers 2020-04-30 13:21:36 +10:00
Peter Barker e545a429a0 AC_Fence: rename APMrover2 to Rover 2020-04-14 09:50:34 +09:00
Tatsuya Yamaguchi 5688031f02 AC_Fence: add the description of FENCE_ACTION in Rover 2020-02-05 14:58:56 +09:00
Randy Mackay 9e51731bae AC_Fence: turn off debug msg re memory allocation 2019-12-10 08:51:19 +11:00
Randy Mackay 7c034990b5 AC_Fence: relax sys-status healthy reporting 2019-11-11 07:55:50 +08:00
Peter Barker 714a3e2462 AC_Fence: support for multiple polygon fences
AC_Fence: add interface for retrieving exclusion polygons

AC_Fence: add interface to get exlusion polygons to polyfence loader

AC_Fence: add suport for inclusion circles

AC_Fence: add option for compiling-out FENCE_POINT protocol support

AC_Fence: get_exclusion_polygon and get_boundary_points set num_points to zero on failure

AC_Fence: use Debug(...) to hide debug messages

AC_PolyFence_loader: add methods to retrieve all inclusion zones

AC_PolyFence_loader: valid simply returns true if a polygon boundary can be returned

AC_Fence: add get_exclusion_circle

AC_Fence: add get_exclusion_circle_update_ms accessor

AC_Fence: PolyFence_loader gets inclusion circle accessors

AC_PolyFence_loader: add and use semaphore to protect loaded fence

AC_Fence: move fence breach check below fence type checks

This allows us to provide more information to the user about why they
are breached.

For example, if the radius is negative you are considered in breach of
it - but we'd tell you you were breached, not that your radius was
invalid

AC_Fence: clear the fence if we discover the user has set the fence count to zero
2019-09-28 07:58:48 +09:00
Peter Barker ff37590776 AC_Fence: move polygon points into AC_Fence_Polygon 2019-09-28 07:58:48 +09:00
Peter Barker a5ec64fc99 AC_Fence: tidy get_breach_distance
The polygon fence will soon be able to supply a breach distance -
prepare for that.
2019-08-08 16:47:41 +09:00
Peter Barker 6a241cc3e9 AC_Fence: remove pointless sanity check 2019-08-08 16:47:41 +09:00
Pierre Kancir bf74cb4e99 AC_Fence: pass mavlink_message_t by const reference 2019-07-16 20:51:42 +10:00
Randy Mackay beb9ecbdcb AC_Fence: add get_boundary_update_ms
this allows callers to detect changes in the underlying polygon fence
2019-06-11 13:13:22 +09:00
Randy Mackay 0f6e61bc33 AC_Fence: add is_polygon_valid accessor 2019-06-11 13:13:22 +09:00
Peter Barker 062ee71135 AC_Fence: simplify fence loading
There's only one caller to this, who didn't force loading - so remove
the unused parameter.

Also remove the _boundary_loaded boolean; it was only set to true in one
place - just before the sole caller called the function!
2019-05-30 16:03:58 +09:00
Peter Barker 2822c635ec AC_Fence: correct get_boundary_points to account for closing point
Also rename from get_polygon_points
2019-05-29 15:34:02 +10:00
Pierre Kancir 4dbac3de60 GCS_Common: remove mavlink send_buf usage 2019-04-23 09:41:00 +10:00
Pierre Kancir e4987f17b9 AC_Fence: use get_distance_NE instead of location_diff 2019-04-08 08:00:52 -07:00
Peter Barker 3629273959 AC_Fence: use enum class for AltFrame enumeration 2019-03-19 10:31:18 +11:00
Michael du Breuil 281d3b1189 AC_Fence: check the return value of fetching the EKF origin 2019-03-12 08:27:42 +09:00
Peter Barker 8991fd8fcf AC_Fence: clear breaches if boundary invalid etc 2019-03-08 08:57:27 +09:00
Peter Barker 434f22cf40 AC_Fence: correct fence upload reload boundary trigger
The check in AC_Fence::check_fence_polygon is for boundary points, not
boundary loaded
2019-03-08 08:57:27 +09:00
Peter Barker c04d2145a1 AC_Fence: correct fence pre-arm position check 2019-03-07 11:42:39 +09:00
Dr.-Ing. Amilcar do Carmo Lucas f2ca3556cd AC_Fence: replace location_offset() and get_distance() function calls with Location object member function calls
This allows removing duplicated code
2019-02-28 11:44:09 +11:00
Peter Barker 7198234a44 AC_Fence: clean headers 2019-02-19 09:16:26 +11:00
Peter Barker 4c3a93d8ca AC_Fence: remove keywords.txt 2019-02-17 00:29:38 -08:00
Peter Barker 5448cfda80 AC_Fence: remove always-true contains_return_point parameter 2019-02-04 16:52:42 +09:00
Peter Barker a52a1f710f AC_Fence: add singleton (AP::fence()) 2019-01-31 13:44:29 +09:00
Peter Barker 6313cbca0b AC_Fence: stop taking reference to AHRS in constructor 2019-01-31 11:25:38 +09:00
chobitsfan e7f87f767a AC_Fence: add SmartRTL and Brake actions 2019-01-25 15:43:18 +09:00
Peter Barker 9deee2a805 AP_Fence: adjust for Location_Class and Location unification 2019-01-16 11:45:29 +11:00
Peter Barker c4bee518bb AC_Fence: rename send_extended_status1 to send_sys_status 2018-12-10 12:52:41 +09:00
Peter Barker 9c0bb9c47d AC_Fence: do not enable altitude fence on Rover by default 2018-10-30 12:10:42 +11:00
Randy Mackay 06aa29eb2a AC_Fence: get_polygon_points does not include return point 2018-10-26 14:38:04 +09:00
Raouf e55369b1c8 AC_Fence: add always land option 2018-07-26 10:08:45 +09:00
Steven Josefs e8debde4b7 AC_Fence: hide ALT_MAX parameter from Rover 2018-01-22 20:42:31 +09:00
Peter Barker c8e0ae6890 AC_Fence: adjust fence sys_status failed based on position and parameters 2018-01-09 17:15:19 +00:00
Peter Barker e30a6bbce3 AC_Fence: rename sys_status methods from geofence_ to sys_status_ 2018-01-09 17:15:19 +00:00
Peter Barker a5aafab7ff AC_Fence: use pre-arm checks for sanity checks
Magically resetting people's parameters not a great look.
2018-01-09 17:15:19 +00:00
Peter Barker 155407956c AC_Fence: add a pre-arm check for polygon fence validity
Also change SYS_STATUS bit to be unhealthy if boundary invalid
2018-01-09 17:15:19 +00:00
Peter Barker 588b0c17c8 AC_Fence: remove AC_FENCE_TYPE_NONE define
0 is the appropriate value for a bitmask which is empty
2017-12-28 15:38:37 +00:00
Peter Barker aa482bae40 AC_Fence: remove argument to check()
Also, rename check_fence() to check()
2017-12-28 15:38:37 +00:00
Peter Barker 0f94fde434 AC_Fence: get home distance directly from ahrs 2017-12-15 01:42:49 +00:00
Peter Barker 20e295c23a AC_Fence: check supplied location within fence rather than current loc 2017-12-15 01:24:13 +00:00
Andrew Tridgell 25b9a7e711 AC_Fence: removed create() method for objects
See discussion here:

  https://github.com/ArduPilot/ardupilot/issues/7331

we were getting some uninitialised variables. While it only showed up in
AP_SbusOut, it means we can't be sure it won't happen on other objects,
so safest to remove the approach

Thanks to assistance from Lucas, Peter and Francisco
2017-12-14 08:12:28 +11:00
Peter Barker 86fe1671c1 AC_Fence: fix comment 2017-12-13 10:04:50 +09:00
Peter Barker e8151a7ec1 AC_Fence: require home as well as origin for prearm checks 2017-12-13 10:04:50 +09:00
Peter Barker 1ecfdffa76 AC_Fence: methods to help populate SYS_STATUS 2017-12-13 10:04:50 +09:00
Peter Barker ac3f030a34 AC_Fence: factor out check_fence_alt_max
NFC
2017-12-13 10:04:50 +09:00
Peter Barker d04a4dd0f8 AC_Fence: factor out check_fence_circle
NFC
2017-12-13 10:04:50 +09:00
Peter Barker d379c7bbd9 AC_Fence: factor out check_fence_polygon
NFC
2017-12-13 10:04:50 +09:00
Peter Barker 518399c13a AC_Fence: stop looking at EKF filter status
Fence has no business looking at what the filter status is.

Fence should only care whether it can currently get a position.
2017-12-13 10:04:50 +09:00
khancyr 65373b85f0 AC_Fence: replace AP_InertialNav by AHRS 2017-12-13 10:04:50 +09:00
Michael du Breuil 983a330cd5 AC_Fence: Remove unused duplicate methods
The Vector2l methods completely duplicate the code of the Vector2f
methods, but aren't used anywhere. They are therefore subject to bitrot
and aren't adding any value. (Also shrinks the build by 8 bytes for some
reason, given that it's unused code I expected to see no difference in
binary size).
2017-11-21 17:04:11 +09:00
Lucas De Marchi 52686ec838 AC_Fence: add static create method 2017-09-26 03:01:21 +01:00
khancyr f583121433 AC_Fence: reset fences breach on disable
Also rename enable function parameter
2017-07-27 20:41:40 +09:00
Peter Barker ae6df4fc04 AC_Fence: remove global static send_statustext_chan 2017-07-11 23:53:53 +01:00
Dr.-Ing. Amilcar Do Carmo Lucas 9ac429ab13 AC_Fence: Use SI units conventions in parameter units
Follow the rules from:
http://physics.nist.gov/cuu/Units/units.html
http://physics.nist.gov/cuu/Units/outside.html
and
http://physics.nist.gov/cuu/Units/checklist.html
one further constrain is that only printable (7bit) ASCII characters are allowed
2017-05-17 18:07:25 +10:00
Randy Mackay c1a25c25f7 AC_Fence: return failure message 2017-03-25 10:50:58 +09:00
Randy Mackay 8171645876 AC_Fence: pre-arm check requires GPS if polygon fence enabled 2017-03-25 10:50:58 +09:00
Jacob Walser 3c6df7cc0e AC_Fence: Add minimum altitude limit
get_safe_alt() -> get_safe_alt_max() and get_safe_alt_min()
2017-02-21 11:26:14 +11:00
murata 0f486aeecb AC_Fence: shorten calculation of return value 2016-12-15 10:42:48 +09:00
murata b48ea53f60 Revert "AC_Fence: Activate the create flag."
This reverts commit c63a6a2738.
2016-12-09 23:55:29 +00:00
murata c63a6a2738 AC_Fence: Activate the create flag. 2016-12-09 17:25:27 +00:00
murata c808ee2f49 Global: To nullptr from NULL.
RC_Channel: To nullptr from NULL.

AC_Fence: To nullptr from NULL.

AC_Avoidance: To nullptr from NULL.

AC_PrecLand: To nullptr from NULL.

DataFlash: To nullptr from NULL.

SITL: To nullptr from NULL.

GCS_MAVLink: To nullptr from NULL.

DataFlash: To nullptr from NULL.

AP_Compass: To nullptr from NULL.

Global: To nullptr from NULL.

Global: To nullptr from NULL.
2016-11-02 16:04:47 -02:00
Mathieu OTHACEHE 152edf7189 Global: remove mode line from headers
Using a global .dir-locals.el file is a better alternative than
reincluding the same emacs header in every file of the project.
2016-10-24 09:42:01 -02:00
Peter Barker d188504b8b AC_Fence: remove unused variable _boundary_revalidate 2016-10-24 08:57:56 -02:00
Randy Mackay e7020b218a AC_Fence: revert param Enable to be FLAG_ENABLE
This reverts commit 5e811b8463.
2016-08-31 08:55:31 +09:00
Tom Pittenger 5e811b8463 AC_Fence: set param "Enable" to be FLAG_ENABLE 2016-08-04 11:29:30 -07:00
murata b6c27b58a8 AC_Fence: magic number 4 changed to size of uint32_t 2016-08-04 15:26:18 +09:00
Randy Mackay e820506c5a AC_Fence: add polygon fence check to check_destination_within_fence 2016-07-04 18:25:03 +09:00
Randy Mackay a9d1dcd6ac AC_Fence: trigger reloading of polygon fence if update from GCS
The GCS can either modify a point with a mavlink message or directly change the FENCE_TOTAL parameter value
2016-07-04 18:25:03 +09:00
Randy Mackay 5153c3d195 AC_Fence: merge with add polygon support 2016-06-25 15:55:55 +09:00
Randy Mackay d91805edbf AC_Fence: add support for polygon fences 2016-06-25 15:55:55 +09:00
Randy Mackay f0bb1ac1d2 AC_Fence: AC_Polygon_loader loads points from eeprom
Thanks to Peter Barker for his work to library-ify Plane's geofence which was the basis for this work.
2016-06-25 15:55:55 +09:00
Daniel Ricketts e60710332b AC_Fence: add accessors to return radius and safety margin 2016-06-22 11:38:15 +09:00
Randy Mackay 4829dbb55d AC_Fence: rename check_destination_within_fence and accept distances in meters 2016-05-21 09:56:12 +09:00
Saloni Jain ff843448aa AC_Fence: Added a new function to check whether the guided waypoint is within the fence 2016-05-21 09:56:12 +09:00
Lucas De Marchi 7dc3942ad4 AC_Fence: replace header guard with pragma once 2016-03-16 18:40:39 +11:00
Lucas De Marchi 2591261af6 Global: rename min and max macros to uppercase
The problem with using min() and max() is that they conflict with some
C++ headers. Name the macros in uppercase instead. We may go case by
case later converting them to be typesafe.

Changes generated with:

	git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)max(/\1MAX(/g'
	git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)min(/\1MIN(/g'
2015-12-01 16:28:09 -02:00
Caio Marcelo de Oliveira Filho ccd03bcf60 AC_Fence: use millis/micros/panic functions 2015-11-20 12:27:11 +09:00
Lucas De Marchi 831d8acca5 Remove use of PROGMEM
Now variables don't have to be declared with PROGMEM anymore, so remove
them. This was automated with:

    git grep -l -z PROGMEM | xargs -0 sed -i 's/ PROGMEM / /g'
    git grep -l -z PROGMEM | xargs -0 sed -i 's/PROGMEM//g'

The 2 commands were done so we don't leave behind spurious spaces.

AVR-specific places were not changed.
2015-10-30 14:35:16 +09:00
Gustavo Jose de Sousa d030e817d9 AC_Fence: standardize inclusion of libaries headers
This commit changes the way libraries headers are included in source files:

 - If the header is in the same directory the source belongs to, so the
 notation '#include ""' is used with the path relative to the directory
 containing the source.

 - If the header is outside the directory containing the source, then we use
 the notation '#include <>' with the path relative to libraries folder.

Some of the advantages of such approach:

 - Only one search path for libraries headers.

 - OSs like Windows may have a better lookup time.
2015-08-11 16:28:41 +10:00
Andrew Tridgell aa1bfb1ca7 AC_Fence: revert AP_Math class change 2015-05-05 13:27:04 +10:00
Tom Pittenger 94ffc9b942 AC_Fence: compiler warnings: apply is_zero(float) or is_equal(float) 2015-05-05 13:26:55 +10:00
Randy Mackay f06c859d93 AC_Fence: add comment re check_fence method 2015-04-14 16:10:09 +09:00
Jonathan Challinger 05fda4ee4c AC_Fence: accept curr_alt parameter instead of getting alt from inav 2015-04-14 16:10:07 +09:00
Jonathan Challinger f06cc5d0c1 AC_Fence: change inav to const reference 2015-04-14 16:10:02 +09:00
Randy Mackay 9aba885231 AC_Fence: fix prearm check
before arming the EKF's pred_horiz_pos_abs flag should be used
2015-03-18 21:25:47 +09:00
Randy Mackay 4754ecc9e2 AC_Fence: remove example sketch
This only tested compiling anyway
2015-03-13 16:40:52 +09:00
Randy Mackay 99046ebda6 AC_Fence: fix example sketch 2015-01-28 17:15:32 +09:00