Пример #1
0
void LR_MsgHandler_CHEK::process_message(uint8_t *msg)
{
    wait_timestamp_from_msg(msg);
    check_state.time_us = AP_HAL::micros64();
    attitude_from_msg(msg, check_state.euler, "Roll", "Pitch", "Yaw");
    check_state.euler *= radians(1);
    location_from_msg(msg, check_state.pos, "Lat", "Lng", "Alt");
    require_field(msg, "VN", check_state.velocity.x);
    require_field(msg, "VE", check_state.velocity.y);
    require_field(msg, "VD", check_state.velocity.z);
}
Пример #2
0
void LR_MsgHandler_GPS_Base::update_from_msg_gps(uint8_t gps_offset, uint8_t *msg, bool responsible_for_relalt)
{
    uint64_t time_us;
    if (! field_value(msg, "TimeUS", time_us)) {
        uint32_t timestamp;
        require_field(msg, "T", timestamp);
        time_us = timestamp * 1000;
    }
    wait_timestamp_usec(time_us);

    Location loc;
    location_from_msg(msg, loc, "Lat", "Lng", "Alt");
    Vector3f vel;
    ground_vel_from_msg(msg, vel, "Spd", "GCrs", "VZ");

    uint8_t status = require_field_uint8_t(msg, "Status");
    uint8_t hdop = 0;
    if (! field_value(msg, "HDop", hdop) &&
        ! field_value(msg, "HDp", hdop)) {
        hdop = 20;
    }
    uint8_t nsats = 0;
    if (! field_value(msg, "NSats", nsats) &&
        ! field_value(msg, "numSV", nsats)) {
        field_not_found(msg, "NSats");
    }
    gps.setHIL(gps_offset,
               (AP_GPS::GPS_Status)status,
               uint32_t(time_us/1000),
               loc,
               vel,
               nsats,
               hdop,
               require_field_float(msg, "VZ") != 0);
    if (status == AP_GPS::GPS_OK_FIX_3D && ground_alt_cm == 0) {
        ground_alt_cm = require_field_int32_t(msg, "Alt");
    }

    if (responsible_for_relalt) {
        // this could possibly check for the presence of "RelAlt" label?
        int32_t tmp;
        if (! field_value(msg, "RAlt", tmp)) {
            tmp = require_field_int32_t(msg, "RelAlt");
        }
        rel_altitude = 0.01f * tmp;
    }
}
Пример #3
0
void LR_MsgHandler_GPS_Base::update_from_msg_gps(uint8_t gps_offset, uint8_t *msg)
{
    uint64_t time_us;
    if (! field_value(msg, "TimeUS", time_us)) {
        uint32_t timestamp;
        require_field(msg, "T", timestamp);
        time_us = timestamp * 1000;
    }
    wait_timestamp_usec(time_us);

    Location loc;
    location_from_msg(msg, loc, "Lat", "Lng", "Alt");
    Vector3f vel;
    ground_vel_from_msg(msg, vel, "Spd", "GCrs", "VZ");

    uint8_t status = require_field_uint8_t(msg, "Status");
    uint8_t hdop = 0;
    if (! field_value(msg, "HDop", hdop) &&
        ! field_value(msg, "HDp", hdop)) {
        hdop = 20;
    }
    uint8_t nsats = 0;
    if (! field_value(msg, "NSats", nsats) &&
        ! field_value(msg, "numSV", nsats)) {
        field_not_found(msg, "NSats");
    }
    uint16_t GWk;
    uint32_t GMS;
    if (! field_value(msg, "GWk", GWk)) {
        field_not_found(msg, "GWk");
    }
    if (! field_value(msg, "GMS", GMS)) {
        field_not_found(msg, "GMS");
    }
    gps.setHIL(gps_offset,
               (AP_GPS::GPS_Status)status,
               AP_GPS::time_epoch_convert(GWk, GMS),
               loc,
               vel,
               nsats,
               hdop);
    if (status == AP_GPS::GPS_OK_FIX_3D && ground_alt_cm == 0) {
        ground_alt_cm = require_field_int32_t(msg, "Alt");
    }
}