Add support for AP_Terrain messages
Message below from Tridge on this subject:
The terrain following code is now in master. Both plane and copter will communicate with the GCS to fill the terrain database, but only plane will use the terrain data to follow terrain so far. Rover already has great terrain following, so it didn't need any changes :-)
There are a few more pieces that need to be filled in on ground stations:
- ground stations need to respond to TERRAIN_REQUEST messages. A TERRAIN_REQUEST is a request for a block of 4x4 terrain heights sent from the vehicle to the GCS. The GCS needs to lookup its terrain database and send the data back to the vehicle in a TERRAIN_DATA response.
- ground stations should generate TERRAIN_CHECK messages to ensure the vehicle has terrain data needed for a mission. The vehicle will send a TERRAIN_REPORT in response. If the grid_spacing in the TERRAIN_REPORT is zero then the vehicle doesn't yet have data for that location. The vehicle will automatically start to pull data from the GCS for that location with TERRAIN_REQUEST messages
- ground stations should add the ability to generate terrain following mission items, by setting the frame type of the mission item to MAV_FRAME_GLOBAL_TERRAIN_ALT
- ground stations should show terrain subsystem status, using the MAV_SYS_STATUS_TERRAIN health bits in SYS_STATUS
I've done a new release of MAVProxy with all these elements done, so we can test terrain following now in SITL for plane. To test with mavproxy use:
set terrainalt 1
that will tell mavproxy to create mission items as MAV_FRAME_GLOBAL_TERRAIN_ALT.
You should also set the parameter TERRAIN_FOLLOW:
param set TERRAIN_FOLLOW 1
that tells APM:Plane to use terrain altitude for RTL, CRUISE and FBWB. Use of terrain altitude for mission items and guided mode is controlled by the frame type in the mission item.
Note that terrain following is not available on APM1/APM2. Attempting to upload a terrain mission on APM1/APM2 will fail.
Right now terrain following doesn't do any lookahead. This means it can fly into the ground if the slope is greater than the climb rate the plane can achieve. We can fix that by adding spiral climbs, but that hasn't been done yet.
Cheers, Tridge
I assume the default terrain database is from SRTM. Is there a way to use a custom terrain database?
with what other source?
I've been able to load our own custom imagery as you've shown here: http://vps.oborne.me/gcs/CustomImages.htm We used this method to display a DEM from airborne lidar, since this has higher resolution / higher accuracy than SRTM, especially for planning low altitude surveys over complex terrain.
However, in addition to the visual display of our custom imagery, it would be extremely helpful if Flight Plan could support 2 features:
- using a custom elevation database for the "verify height" function
- view those custom elevation values under the lat/long values in the Action panel.
+1! That would be fantastic.
what format is original source?
This particular dataset is GeoTIFF, but any GIS raster format would suffice.
you cannot pull elevation data from a image like the one in your screenshot. as its been normalized.
the geotiff should work however. what coord system do you normaly use? utm?
We use Geographic more than UTM since the GPS data are usually reported in lat/long format. However, it is no problem for us to convert between various coordinate systems in GIS.
hi Michael, ground stations no longer need to check that the mission has terrain data, as AP_Terrain now does that automatically (and for rally points too)
Now that Automatic Terrain Following is available in APM, it would be extremely helpful to add support for custom terrain databases in Mission Planner. SRTM is still not suitable for some areas.
To illustrate the discrepancies, here's a line-of-sight comparison between SRTM, IfSAR and LiDAR

can you supply one of your images as a sample to test against? I have started to look at geotiff support.
Ok, here is a link to one of the tiles
https://www.dropbox.com/s/aeikpdwhsksy2xw/4QFJ622370_lmsl.tif
This issue is still open. Has there been any progress in supporting custom terrain data? The link to the sample data in my previous post is no longer valid, so here is a new one: https://copy.com/zdXsVik6mtYrphIZ
Perhaps this is falling off the radar because the title of the original issue doesn't match this request. We need a new issue titled something like "Importing custom terrain data (DEM) into Mission Planner". It should reference this discussion and reintroduce the request. Someday we will have flight planning with 3D maps, until then we at least need the ability to import accurate elevations to use with the existing tools.
Yes, closing this item which is complete and adding a new one with the additional request made here. https://github.com/diydrones/MissionPlanner/issues/985
By the way, anyone can add new issues.