Exemplo n.º 1
0
/*
  log terrain data to dataflash log
 */
void AP_Terrain::log_terrain_data(DataFlash_Class &dataflash)
{
    if (!enable) {
        return;
    }
    Location loc;
    if (!ahrs.get_position(loc)) {
        // we don't know where we are
        return;
    }
    float terrain_height = 0;
    float current_height = 0;
    uint16_t pending, loaded;

    height_amsl(loc, terrain_height);
    height_above_terrain(current_height, true);
    get_statistics(pending, loaded);

    struct log_TERRAIN pkt = {
        LOG_PACKET_HEADER_INIT(LOG_TERRAIN_MSG),
        time_us        : hal.scheduler->micros64(),
        status         : (uint8_t)status(),
        lat            : loc.lat,
        lng            : loc.lng,
        spacing        : (uint16_t)grid_spacing,
        terrain_height : terrain_height,
        current_height : current_height,
        pending        : pending,
        loaded         : loaded
    };
Exemplo n.º 2
0
/* 
   alternative interface to height_above_terrain where
   relative_altitude is taken from loc.alt (in centimeters)
*/
bool AP_Terrain::height_above_terrain(const Location &loc, float &terrain_altitude)
{
    float relative_home_altitude = loc.alt*0.01f;
    if (!loc.flags.relative_alt) {
        // loc.alt has home altitude added, remove it
        relative_home_altitude -= ahrs.get_home().alt*0.01f;
    }
    return height_above_terrain(loc, relative_home_altitude, terrain_altitude);
}