qgroundcontrol\src\Vehicle\Vehicle.cc
#include "fstream"
void Vehicle::_handleGpsRawInt(mavlink_message_t& message)
{
mavlink_gps_raw_int_t gpsRawInt;
mavlink_msg_gps_raw_int_decode(&message, &gpsRawInt);
_gpsRawIntMessageAvailable = true;
if (gpsRawInt.fix_type >= GPS_FIX_TYPE_3D_FIX) {
if (!_globalPositionIntMessageAvailable) {
QGeoCoordinate newPosition(gpsRawInt.lat / (double)1E7, gpsRawInt.lon / (double)1E7, gpsRawInt.alt / 1000.0);
if (newPosition != _coordinate) {
_coordinate = newPosition;
emit coordinateChanged(_coordinate);
}
_altitudeAMSLFact.setRawValue(gpsRawInt.alt / 1000.0);
}
}
_gpsFactGroup.lat()->setRawValue(gpsRawInt.lat * 1e-7);
_gpsFactGroup.lon()->setRawValue(gpsRawInt.lon * 1e-7);
_gpsFactGroup.mgrs()->setRawValue(convertGeoToMGRS(QGeoCoordinate(gpsRawInt.lat * 1e-7, gpsRawInt.lon * 1e-7)));
_gpsFactGroup.count()->setRawValue(gpsRawInt.satellites_visible == 255 ? 0 : gpsRawInt.satellites_visible);
_gpsFactGroup.hdop()->setRawValue(gpsRawInt.eph == UINT16_MAX ? std::numeric_limits<double>::quiet_NaN() : gpsRawInt.eph / 100.0);
_gpsFactGroup.vdop()->setRawValue(gpsRawInt.epv == UINT16_MAX ? std::numeric_limits<double>::quiet_NaN() : gpsRawInt.epv / 100.0);
_gpsFactGroup.courseOverGround()->setRawValue(gpsRawInt.cog == UINT16_MAX ? std::numeric_limits<double>::quiet_NaN() : gpsRawInt.cog / 100.0);
_gpsFactGroup.lock()->setRawValue(gpsRawInt.fix_type);
QDateTime datetime;
QString timestr=datetime.currentDateTime().toString("yyyy.MM.dd.HH.mm.ss");
QString day=datetime.currentDateTime().toString("MM.dd.hh");
QString fileName = "你的保存路径" + day+ "gpsQGC.txt";
QFile file(fileName);
file.open(QIODevice::Append | QIODevice::Text );
QTextStream in(&file);
in << timestr;
in <<" lat:"<<QString::number(double (gpsRawInt.lat* 1e-7),'f',7);
in <<" lon:"<<QString::number(double(gpsRawInt.lon* 1e-7),'f',7);
in <<" alt:"<<QString::number(double (gpsRawInt.alt/ 1000.0));
in <<" count:"<<QString::number(gpsRawInt.satellites_visible);
in <<" hdop:"<<QString::number(double(gpsRawInt.eph)/100.0);
// in <<" vdop:"<<QString::number(gpsRawInt.epv);
in <<" fix_type:"<<gpsRawInt.fix_type;
in <<endl;
file.flush();
file.close();
}
效果如下
内容如下,经纬度已经打码