#include <AP_MSP/msp.h>
#include "AP_GPS_MSP.h"
#if HAL_MSP_GPS_ENABLED
bool AP_GPS_MSP::read(void)
{
if (new_data) {
new_data = false;
return true;
}
return false;
}
void AP_GPS_MSP::handle_msp(const MSP::msp_gps_data_message_t &pkt)
{
check_new_itow(pkt.ms_tow, sizeof(pkt));
state.time_week = pkt.gps_week;
state.time_week_ms = pkt.ms_tow;
state.status = (AP_GPS::GPS_Status)pkt.fix_type;
state.num_sats = pkt.satellites_in_view;
state.location = {
pkt.latitude,
pkt.longitude,
pkt.msl_altitude,
Location::AltFrame::ABSOLUTE
};
state.hdop = pkt.hdop;
state.vdop = GPS_UNKNOWN_DOP;
state.have_vertical_velocity = true;
Vector3f vel;
vel.x = pkt.ned_vel_north * 0.01;
vel.y = pkt.ned_vel_east * 0.01;
vel.z = pkt.ned_vel_down * 0.01;
state.velocity = vel;
velocity_to_speed_course(state);
state.have_speed_accuracy = true;
state.have_horizontal_accuracy = true;
state.have_vertical_accuracy = true;
state.have_vertical_velocity = true;
state.horizontal_accuracy = pkt.horizontal_pos_accuracy * 0.01;
state.vertical_accuracy = pkt.vertical_pos_accuracy * 0.01;
state.speed_accuracy = pkt.horizontal_vel_accuracy * 0.01;
state.last_gps_time_ms = AP_HAL::millis();
if (pkt.true_yaw != 65535) {
state.gps_yaw = wrap_360(pkt.true_yaw*0.01);
state.have_gps_yaw = true;
state.gps_yaw_time_ms = state.last_gps_time_ms;
}
new_data = pkt.fix_type>0;
}
bool AP_GPS_MSP::get_lag(float &lag_sec) const
{
lag_sec = 0.11;
return true;
}
#endif