/** Assemble an NMEA GPVTG message and send it out NMEA USARTs. * NMEA VTG contains course and speed * * \param soln Pointer to gnss_solution struct */ void nmea_gpvtg(const gnss_solution *soln) { /* NMEA Parameters for GPVTG * Ex. * $GPVTG,054.7,T,034.4,M,005.5,N,010.2,K * | | | | | | | | | * Command | 'T' | 'M' | 'N' | 'K' * True Course | Speed (K) | * Mag. course Speed (km/hr) */ float vknots, vkmhr; float x,y,z; x = soln->vel_ned[0]; y = soln->vel_ned[1]; z = soln->vel_ned[2]; float course = atan2(y,x); /* Conversion to magnitue knots */ vknots = MS2KNOTTS(x,y,z); /* Conversion to magnitue km/hr */ vkmhr = MS2KMHR(x,y,z); NMEA_SENTENCE_START(120); NMEA_SENTENCE_PRINTF( "$GPVTG,%05.1f,T," /* Command, course, */ ",M," /* Magnetic Course (omitted) */ "%06.2f,N,%06.2f,K", /* Speed (knots, km/hr) */ course* R2D, vknots, vkmhr); NMEA_SENTENCE_DONE(); }
/** Assemble an NMEA GPVTG message and send it out NMEA USARTs. * NMEA VTG contains course and speed * * \param nav_meas Pointer to navigation_measurement struct. * \param soln Pointer to gnss_solution struct */ void nmea_gpvtg(const navigation_measurement_t *nav_meas, const gnss_solution *soln) { /* NMEA Parameters for GPVTG * Ex. * $GPVTG,054.7,T,034.4,M,005.5,N,010.2,K * | | | | | | | | | * Command | 'T' | 'M' | 'N' | 'K' * True Course | Speed (K) | * Mag. course Speed (km/hr) */ double az, el; wgsecef2azel(nav_meas[0].sat_pos, soln->pos_ecef, &az, &el); float vknots, vkmhr; float x,y,z; x = soln->vel_ned[0]; y = soln->vel_ned[1]; z = soln->vel_ned[2]; float course = atan2(y,x); /* Conversion to magnitue knots */ vknots = MS2KNOTTS(x,y,z); /* Conversion to magnitue km/hr */ vkmhr = MS2KMHR(x,y,z); char buf[80]; u8 n = sprintf(buf, "$GPVTG,%05.1f,T," /* Command, course, */ ",M," /* Magnetic Course (omitted) */ "%06.2f,N,%06.2f,K", /* Speed (knots, km/hr) */ course* R2D, vknots, vkmhr); u8 sum = nmea_checksum(buf); sprintf(buf + n, "*%02X\r\n", sum); nmea_output(buf); }