Commit Graph

143 Commits

Author SHA1 Message Date
Asif Khan 11e541f123 AP_Terrain: add get_grid_spacing accessor 2023-11-02 15:54:37 +11:00
Andrew Tridgell 9706a207b1 AP_Terrain: fixed build for periph
needed for SITL periph rangefinder
2023-08-24 13:06:40 +10:00
Andrew Tridgell 3534417a12 AP_Terrain: fixed assumption that HOME is on the ground
this fixes height_above_terrain() to give a correct value when HOME is
not on the ground after the user has done a DO_SET_HOME with a
home position that is not at ground level
2023-08-05 08:31:02 +10:00
Peter Barker 5ee85b82f9 AP_Terrain: assume HAL_BOARD_TERRAIN_DIRECTORY is defined 2023-07-19 17:25:18 +09:00
Peter Barker e8ed94344b AP_Terrain: replace HAVE_FILESYSTEM_SUPPORT with backend defines 2023-05-17 09:40:39 +10:00
Randy Mackay c039c349e3 AP_Terrain: terrain offset max default to 30m 2023-03-14 11:59:49 +11:00
murata f04cab917b AP_Terrain: Explicitly state that they are at the same latitude 2023-02-08 08:54:35 +11:00
Peter Barker 84215ff662 AP_Terrain: only include GCS_MAVLink if terrain is enabled 2023-01-03 10:47:28 +11:00
Peter Barker 241a7b1d78 AP_Terrain: include required AP_Vehicle_Type header 2022-11-02 18:35:48 +11:00
Peter Barker 339dd33240 AP_Terrain: correct compilation with rally disabled 2022-09-27 10:16:47 +10:00
Peter Barker 15a1241d4b AP_Terrain: fold AP_Filesystem_Available.h into AP_Filesystem_config.h 2022-09-15 10:53:02 +10:00
Peter Barker 1e8e100409 AP_Terrain: rename HAL_MISSION_ENABLED to AP_MISSION_ENABLED 2022-08-18 22:49:10 +10:00
Peter Barker 541cfa022b AP_Terrain: fix bad prearms-pass-when-they-shouldn't issue
The squares surrounding the current location were only checked when we went to send a terrain request.  This means it was possible that:
 - the number of pending requests could go to zero
 - prearm checks would pass
 - vehicle arm is attempted by the user (or a script, or ....)
 - the code would call AP_Terrain::send_requests which would create more pending requests
 - the arming sequence would fail

It's also possible for the arming to succeed, and then we're flying in violation of the intended prearm checks.

Doing things in the update function has the additional advantage of making things more efficient as we can push out terrain requests more often.
2022-08-09 14:31:14 +10:00
Peter Barker 4c674b64fb AP_Terrain: correct wait-for-terrain prearm check
looking at pending is insufficient as we may have more mission items to check to see if they need other pieces of terrain.  That is, terr_pending can go to zero momentarily and then go back to a non-zero number as Terrain's update method checks the mission and rally libraries for more terrain requirements.

Without this patch the prearm checks can momentarily pass, allowing the vehicle to arm.  The vehicle could hit a terrain failsafe later if it doesn't manage to get the data while in flight.
2022-08-09 14:31:14 +10:00
Peter Barker d688e6068b AP_Terrain: move terrain prearm checks to AP_Terrain 2022-08-09 14:31:14 +10:00
Iampete1 d03f917ef4 AP_Terrain: params always use set method 2022-08-03 13:43:48 +01:00
Peter Barker a6eec9f063 AP_Terrain: tidy includes 2022-05-03 09:14:58 +10:00
Andrew Tridgell 62dc865321 AP_Terrain: added logging of terrain correction 2022-03-28 16:01:21 +11:00
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
Andrew Tridgell 5d3a0a78cb AP_Terrain: removed terrain home correction 2022-03-10 07:34:20 +11:00
Peter Barker 6b21d117a9 AP_Terrain: stop passing mission in Terrain constructor
Terrain can use the mission singleton

This means Copter can have terrain while compiling mission out
2022-02-08 11:20:20 +11:00
Peter Barker bb42ab3eb3 AP_Terrain: do not use location object if it is zero
This can happen at boot-time if the vehicle has no idea where it is
2022-02-08 10:57:03 +11:00
Peter Barker 5fe91f16af AP_Terrain: avoid direct use of Location alt field 2022-02-08 10:57:03 +11:00
Peter Barker e8e4aef998 AP_Terrain: rename AP_AHRS::get_position to get_location 2022-01-25 10:47:22 +11:00
Peter Barker a4b3c7eb46 AP_Terrain: cast result of labs to unsigned
Fixes:

../../libraries/AP_Terrain/TerrainGCS.cpp: In member function ‘void AP_Terrain::
handle_terrain_data(const mavlink_message_t&)’:
../../libraries/AP_Terrain/AP_Terrain.h:65:55: error: comparison between signed
and unsigned integer expressions [-Werror=sign-compare]
 #define TERRAIN_LATLON_EQUAL(v1, v2) (labs((v1)-(v2)) <= unsigned(margin.get()*
100))
                                       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
../../libraries/AP_Terrain/AP_Terrain.h:65:55: note: in definition of macro ‘TER
RAIN_LATLON_EQUAL’
 #define TERRAIN_LATLON_EQUAL(v1, v2) (labs((v1)-(v2)) <= unsigned(margin.get()*
100))
                                                       ^~
compilation terminated due to -Wfatal-errors.
cc1plus: some warnings being treated as errors

In file included from ../../libraries/AP_Terrain/TerrainUtil.cpp:24:0:
../../libraries/AP_Terrain/TerrainUtil.cpp: In member function ‘AP_Terrain::grid
_cache& AP_Terrain::find_grid_cache(const AP_Terrain::grid_info&)’:
../../libraries/AP_Terrain/AP_Terrain.h:65:55: error: comparison between signed
and unsigned integer expressions [-Werror=sign-compare]
 #define TERRAIN_LATLON_EQUAL(v1, v2) (labs((v1)-(v2)) <= unsigned(margin.get()*
100))
                                       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
~~~~

The return value of labs is signed
2021-11-30 10:16:01 +11:00
Andrew Tridgell a412795045 AP_Terrain: make TERRAIN_MARGIN a float
it turns out very large margins are needed for some locations
2021-08-31 09:25:36 +10:00
Andrew Tridgell 4e98636a53 AP_Terrain: added a TERRAIN_MARGIN parameter
this sets the acceptance margin for GCS generated terrain data. You
can raise this to allow old data generated with the less accurate
longitude scaling to be used
2021-08-22 20:32:46 +10:00
Peter Barker ddb7378bdd AP_Terrain: add setter for terrain-enabled
Currently only useful for unit test
2021-07-12 17:34:44 +10:00
Peter Barker 0a068d4d4b AP_Terrain: default terrain to off in Sub 2021-07-12 17:34:44 +10:00
Peter Barker de404b1999 AP_Terrain: allow AP_TERRAIN_AVAILABLE to be set in hwdef
Use AP_TERRAIN_AVAILABLE instead
2021-07-12 17:34:44 +10:00
Andrew Tridgell 5e820b203b Ap_Terrain: make AP::terrain return a pointer
this is needed for rover and OSD support
2021-04-07 20:56:01 +10: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 fb5a06b8da AP_Terrain: added AP namespace access to terrain 2020-07-10 13:28:38 +10:00
Henry Wurzburg 8e6028ec1a AP_Terrain: Update spacing param description in line with firmware useage 2020-06-30 09:51:30 +10:00
Andrew Tridgell 9f0967eb94 AP_Terrain: added verbose option to terrain tester 2020-06-18 13:29:13 +10:00
Andrew Tridgell d9fc96f971 AP_Terrain: shortcut ocean tile creation 2020-06-08 13:56:42 +10:00
Andrew Tridgell 078de3205c AP_Terrain: added test option to terrain creation script 2020-06-08 13:56:42 +10:00
Andrew Tridgell 15f9f7009c AP_Terrain: fixed filling of all lattitudes in terrain generation script 2020-06-08 13:56:42 +10:00
Andrew Tridgell 8ea433ac21 AP_Terrain: added script for creating terrain *.dat files
useful for pre-populating a microSD card
2020-05-05 11:21:33 +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
Jaaaky e8df08a4d3 AP_Terrain: Avoid update() IO operations when not enabled 2020-01-26 10:35:29 +11:00
Randy Mackay d18432adaa AP_Terrain: leave ENABLE as 1 if memory alloc fails 2019-11-19 10:16:25 +11:00
Randy Mackay 649058adb8 AP_Terrain: add init_failed
allows external caller to determine if terrain database failed to initialise
2019-11-19 10:16:25 +11:00
Randy Mackay 1d5e9ef48b AP_Terrain: constify get_statistics and bitount64 2019-11-19 10:16:25 +11:00
Randy Mackay 0af830bbb7 AP_Terrain: minor comment fix 2019-11-12 09:10:21 +08:00
Michael du Breuil dc0e4bea53 AP_Terrain: Don't include all of AP_FS 2019-11-02 22:52:06 +11:00
Michael du Breuil 04863f858d AP_Terrain: Directly include needed headers 2019-08-28 13:13:03 +10:00
Andrew Tridgell a4860afd32 AP_Terrain: convert to use AP_Filesystem 2019-08-27 15:40:43 +10:00