Switch to "nav" (cooked) data to drive FlightGear.
This commit is contained in:
parent
ce4360e157
commit
a0e00e1eaf
2 changed files with 11 additions and 8 deletions
|
@ -120,8 +120,8 @@ void UGEARTrack::parse_msg( const int id, char *buf,
|
||||||
// printf("imu.time = %.4f\n", imupacket->time);
|
// printf("imu.time = %.4f\n", imupacket->time);
|
||||||
} else if ( id == NAV_PACKET ) {
|
} else if ( id == NAV_PACKET ) {
|
||||||
*navpacket = *(struct nav *)buf;
|
*navpacket = *(struct nav *)buf;
|
||||||
navpacket->lon = sg_swap_double( (uint8_t *)buf, 0 );
|
navpacket->lat = sg_swap_double( (uint8_t *)buf, 0 );
|
||||||
navpacket->lat = sg_swap_double( (uint8_t *)buf, 8 );
|
navpacket->lon = sg_swap_double( (uint8_t *)buf, 8 );
|
||||||
navpacket->alt = sg_swap_double( (uint8_t *)buf, 16 );
|
navpacket->alt = sg_swap_double( (uint8_t *)buf, 16 );
|
||||||
navpacket->vn = sg_swap_double( (uint8_t *)buf, 24 );
|
navpacket->vn = sg_swap_double( (uint8_t *)buf, 24 );
|
||||||
navpacket->ve = sg_swap_double( (uint8_t *)buf, 32 );
|
navpacket->ve = sg_swap_double( (uint8_t *)buf, 32 );
|
||||||
|
|
|
@ -121,9 +121,9 @@ static void ugear2fg( gps *gpspacket, imu *imupacket, nav *navpacket,
|
||||||
fdm->version = FG_NET_FDM_VERSION;
|
fdm->version = FG_NET_FDM_VERSION;
|
||||||
|
|
||||||
// Aero parameters
|
// Aero parameters
|
||||||
fdm->longitude = gpspacket->lon * SG_DEGREES_TO_RADIANS;
|
fdm->longitude = navpacket->lon * SG_DEGREES_TO_RADIANS;
|
||||||
fdm->latitude = gpspacket->lat * SG_DEGREES_TO_RADIANS;
|
fdm->latitude = navpacket->lat * SG_DEGREES_TO_RADIANS;
|
||||||
fdm->altitude = gpspacket->alt + alt_offset;
|
fdm->altitude = navpacket->alt + alt_offset;
|
||||||
fdm->agl = -9999.0;
|
fdm->agl = -9999.0;
|
||||||
fdm->psi = imupacket->psi; // heading
|
fdm->psi = imupacket->psi; // heading
|
||||||
fdm->phi = imupacket->phi; // roll
|
fdm->phi = imupacket->phi; // roll
|
||||||
|
@ -140,9 +140,12 @@ static void ugear2fg( gps *gpspacket, imu *imupacket, nav *navpacket,
|
||||||
// double v_ms = dist / (frame_us / 1000000);
|
// double v_ms = dist / (frame_us / 1000000);
|
||||||
// double v_kts = v_ms * SG_METER_TO_NM * 3600;
|
// double v_kts = v_ms * SG_METER_TO_NM * 3600;
|
||||||
// kts_filter = (0.99 * kts_filter) + (0.01 * v_kts);
|
// kts_filter = (0.99 * kts_filter) + (0.01 * v_kts);
|
||||||
double vn = gpspacket->vn;
|
double vn = navpacket->vn;
|
||||||
double ve = gpspacket->ve;
|
double ve = navpacket->ve;
|
||||||
double vd = gpspacket->vd;
|
double vd = navpacket->vd;
|
||||||
|
|
||||||
|
// enable to use ground track heading
|
||||||
|
fdm->psi = atan2(vn, ve); // heading
|
||||||
|
|
||||||
fdm->vcas = sqrt( vn*vn + ve*ve + vd*vd );
|
fdm->vcas = sqrt( vn*vn + ve*ve + vd*vd );
|
||||||
// last_lat = pos.lat_deg;
|
// last_lat = pos.lat_deg;
|
||||||
|
|
Loading…
Add table
Reference in a new issue