Commit Graph

25 Commits

Author SHA1 Message Date
Andrew Tridgell 5f2c5be84a AP_Terrain: added terrain reference adjustment
this restores the terrain adjustment functionality removed in #19946,
but without the problematic approach of always using home (which can
be moved in flight) and with a TERR_OFS_MAX parameter to limit the
amount of adjustment
2022-03-28 16:01:21 +11:00
Andy Piper 176c648156 AP_Terrain: compile fix for gcc 9 2021-01-03 08:57:13 +11:00
Peter Barker 5c4c7b5fd4 AP_Terrain: fix snprintf-overflow compilation error
[451/678] Compiling libraries/AP_Terrain/TerrainIO.cpp
../../libraries/AP_Terrain/TerrainIO.cpp: In member function ‘void AP_Terrain::open_file()’:
../../libraries/AP_Terrain/TerrainIO.cpp:167:35: error: ‘.DAT’ directive output may be truncated writing 4 bytes into a region of size between 2 and 5 [-Werror=format-truncation=]
  167 |     snprintf(p, 13, "/%c%02u%c%03u.DAT",
      |                                   ^~~~
compilation terminated due to -Wfatal-errors.
2020-08-07 12:36:12 +10:00
Andrew Tridgell 227609eef0 AP_Terrain: allow download of terrain data when no GPS lock
this fixes several issues:

 - allows users to download terrain data at home with no GPS lock

 - allows for a TERRAIN_CHECK without GPS lock

 - retries opening of files every 5 seconds to allow for remount of sd
   card after boot
2020-07-28 12:15:43 +10:00
Andrew Tridgell 7b7bf3ef86 AP_Terrain: fixed bug in disk offset calculation
this fixes a problem where two different locations could both be
mapped to the same disk block in the terrain/*.DAT files. That meant
that pre-filled terrain on the microSD card would sometimes require a
download in flight. It also means that a RTL with loss of GCS could
sometimes fly through a region with no terrain data available

Other changes in this patch:

 - allow for a 2cm discrepancy in the lat/lon of the grid
   corners. This is needed to allow for slightly different floating
   point rounding in tools that pre-generate terrain data to load on
   the microSD

 - added TERRAIN_OPTIONS parameter to allow the user to disable
   attempts to download new terrain data. This is mostly useful for
   testing to validate a terrain generator
2020-05-05 11:21:33 +10:00
Andrew Tridgell a4860afd32 AP_Terrain: convert to use AP_Filesystem 2019-08-27 15:40:43 +10:00
Pierre Kancir 6fbcb21ae3 AP_Terrain: use get_distance_NE instead of location_diff 2019-04-08 08:00:52 -07:00
Dr.-Ing. Amilcar do Carmo Lucas 6082b230e8 AP_Terrain: 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
Tom Pittenger f03c73aeff AP_Terrain: compiler warning printing %u with signed value 2018-04-06 07:40:37 +09:00
Peter Barker adde7bc588 AP_Terrain: fix snprintf buffer length warning
Also includes fix from Tridge to use MIN() instead of MAX()
2018-02-02 09:59:06 +09:00
Andrew Tridgell f8542c86b6 AP_Terrain: added support for AP_Terrain for ChibiOS 2018-01-15 11:46:02 +11:00
Peter Barker 698f18566b AP_Terrain: cast to int32_t to avoid warning about signedness
../../libraries/AP_Terrain/TerrainIO.cpp: In member function ‘void
AP_Terrain::open_file()’:
../../libraries/AP_Terrain/TerrainIO.cpp:176:46: warning: format ‘%u’
expects argument of type ‘unsigned int’, but argument 5 has type
‘__gnu_cxx::__enable_if<true, double>::__type {aka double}’ [-Wformat=]
              abs((uint32_t)block.lon_degrees));
                                              ^
../../libraries/AP_Terrain/TerrainIO.cpp:176:46: warning: format ‘%u’
expects argument of type ‘unsigned int’, but argument 7 has type
‘__gnu_cxx::__enable_if<true, double>::__type {aka double}’ [-Wformat=]
2017-09-01 13:30:56 +01:00
Michael du Breuil 3e2b5269a6 AP_Terrain: fix Coverity issue 91367
Also converts to using the get_relative_position_D_home() functions rather then attempting to derive home itself
2017-06-07 19:58:45 +10:00
Lucas De Marchi 4936fd8623 AP_Terrain: add O_CLOEXEC in places missing it
By opening with O_CLOEXEC we make sure we don't leak the file descriptor
when we are exec'ing or calling out subprograms. Right now we currently
don't do it so there's no harm, but it's good practice in Linux to have
it.
2016-11-07 12:37:30 -03: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
Caio Marcelo de Oliveira Filho 0aa520a273 AP_Terrain: use millis/micros/panic functions 2015-11-20 12:34:53 +09:00
Andrew Tridgell 0d26252bdb AP_Terrain: don't allocate cache array when terrain not enabled
this makes it easy to save 22k of ram when running other experiments
2015-09-23 08:31:17 +10:00
Gustavo Jose de Sousa fcd1d4938a AP_Terrain: 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:38:24 +10:00
Andrew Tridgell 1296da56bb AP_Terrain: fixed terrain path handling 2015-06-30 15:08:10 +10:00
Víctor Mayoral Vilches f592981a60 TerrainIO: Support custom_terrain_directory 2015-06-30 14:36:43 +10:00
Lucas De Marchi 6ae2591cad AP_Terrain: use functor macros
Functor is not yet being used but let's make is macro fallback to the
previous Delegate implementation for easy of transition between the two.
2015-05-26 13:46:54 +10:00
Andrew Tridgell e6c6fe095f AP_Terrain: fixed a warning 2014-10-22 18:27:20 +11:00
Andrew Tridgell 3faafc9644 AP_Terrain: replace HAVE_AP_TERRAIN with AP_TERRAIN_AVAILABLE 2014-07-25 07:59:48 +10:00
Andrew Tridgell db506b76fa AP_Terrain: split up code into separate cpp files
this should make it a bit easier to review
2014-07-24 21:50:19 +10:00