mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-01 07:20:36 +08:00
save gps data so driver can read
This commit is contained in:
@@ -188,6 +188,25 @@ void Simulator::update_sensors(struct sensor_combined_s *sensor, mavlink_hil_sen
|
||||
write_baro_data((void *)&baro);
|
||||
}
|
||||
|
||||
void Simulator::update_gps(mavlink_hil_gps_t *gps_sim) {
|
||||
RawGPSData gps;
|
||||
gps.lat = gps_sim->lat;
|
||||
gps.lon = gps_sim->lon;
|
||||
gps.alt = gps_sim->alt;
|
||||
gps.eph = gps_sim->eph;
|
||||
gps.epv = gps_sim->epv;
|
||||
gps.vel = gps_sim->vel;
|
||||
gps.vn = gps_sim->vn;
|
||||
gps.ve = gps_sim->ve;
|
||||
gps.vd = gps_sim->vd;
|
||||
gps.cog = gps_sim->cog;
|
||||
gps.fix_type = gps_sim->fix_type;
|
||||
gps.satellites_visible = gps_sim->satellites_visible;
|
||||
|
||||
write_gps_data((void *)&gps);
|
||||
|
||||
}
|
||||
|
||||
void Simulator::handle_message(mavlink_message_t *msg) {
|
||||
switch(msg->msgid) {
|
||||
case MAVLINK_MSG_ID_HIL_SENSOR:
|
||||
@@ -196,6 +215,12 @@ void Simulator::handle_message(mavlink_message_t *msg) {
|
||||
update_sensors(&_sensor, &imu);
|
||||
break;
|
||||
|
||||
case MAVLINK_MSG_ID_HIL_GPS:
|
||||
mavlink_hil_gps_t gps_sim;
|
||||
mavlink_msg_hil_gps_decode(msg, &gps_sim);
|
||||
update_gps(&gps_sim);
|
||||
break;
|
||||
|
||||
case MAVLINK_MSG_ID_RC_CHANNELS:
|
||||
|
||||
mavlink_rc_channels_t rc_channels;
|
||||
|
||||
Reference in New Issue
Block a user