mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
nmea: parse GSV sentences and populate GPSSatellites object
This creates a new UAVObject called GPSSatellites to hold information about which satellites the GPS receiver can see and the quality of their signals. NMEA GSV sentences are now parsed. The full set of GSV data may be split across multiple GSV sentences, each containing info for at most 4 satellites. Once an entire set of GSV records has been collected, the GPSSatellites UAVObject is updated. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1453 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
2ead641136
commit
ecac1fb79d
@ -151,6 +151,7 @@ SRC += $(OPUAVOBJ)/objectpersistence.c
|
||||
SRC += $(OPUAVOBJ)/positionactual.c
|
||||
SRC += $(OPUAVOBJ)/gpsposition.c
|
||||
SRC += $(OPUAVOBJ)/gpstime.c
|
||||
SRC += $(OPUAVOBJ)/gpssatellites.c
|
||||
SRC += $(OPUAVOBJ)/gcstelemetrystats.c
|
||||
SRC += $(OPUAVOBJ)/flighttelemetrystats.c
|
||||
SRC += $(OPUAVOBJ)/systemstats.c
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "NMEA.h"
|
||||
#include "gpsposition.h"
|
||||
#include "gpstime.h"
|
||||
#include "gpssatellites.h"
|
||||
|
||||
// Debugging
|
||||
//#define GPSDEBUG
|
||||
@ -12,6 +13,7 @@
|
||||
#define NMEA_DEBUG_VTG ///< define to enable debug of VTG messages
|
||||
#define NMEA_DEBUG_RMC ///< define to enable debug of RMC messages
|
||||
#define NMEA_DEBUG_GSA ///< define to enable debug of GSA messages
|
||||
#define NMEA_DEBUG_GSV ///< define to enable debug of GSV messages
|
||||
#define NMEA_DEBUG_ZDA ///< define to enable debug of ZDA messages
|
||||
#endif
|
||||
|
||||
@ -31,6 +33,7 @@ static bool nmeaProcessGPRMC (GPSPositionData * GpsData, char * sentence);
|
||||
static bool nmeaProcessGPVTG (GPSPositionData * GpsData, char * sentence);
|
||||
static bool nmeaProcessGPGSA (GPSPositionData * GpsData, char * sentence);
|
||||
static bool nmeaProcessGPZDA (GPSPositionData * GpsData, char * sentence);
|
||||
static bool nmeaProcessGPGSV (GPSPositionData * GpsData, char * sentence);
|
||||
|
||||
static struct nmea_parser nmea_parsers[] = {
|
||||
{
|
||||
@ -53,6 +56,10 @@ static struct nmea_parser nmea_parsers[] = {
|
||||
.prefix = "GPZDA",
|
||||
.handler = nmeaProcessGPZDA,
|
||||
},
|
||||
{
|
||||
.prefix = "GPGSV",
|
||||
.handler = nmeaProcessGPGSV,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -415,6 +422,106 @@ static bool nmeaProcessGPZDA (GPSPositionData * GpsData, char * sentence)
|
||||
return true;
|
||||
}
|
||||
|
||||
static GPSSatellitesData gsv_partial;
|
||||
/* Bitmaps of which sentences we're looking for to allow us to handle out-of-order GSVs */
|
||||
static uint8_t gsv_expected_mask;
|
||||
static uint8_t gsv_processed_mask;
|
||||
/* Error counters */
|
||||
static uint16_t gsv_incomplete_error;
|
||||
static uint16_t gsv_duplicate_error;
|
||||
|
||||
static bool nmeaProcessGPGSV (GPSPositionData * GpsData, char * sentence)
|
||||
{
|
||||
char * next = sentence;
|
||||
char * tokens;
|
||||
char * delimiter = ",";
|
||||
|
||||
#ifdef NMEA_DEBUG_GSV
|
||||
PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"$%s\r\n",sentence);
|
||||
#endif
|
||||
|
||||
/* Drop the checksum */
|
||||
char * tmp = sentence;
|
||||
char * tmp_delim = "*";
|
||||
next = strsep(&tmp, tmp_delim);
|
||||
|
||||
/* # of sentences in full GSV data set */
|
||||
tokens = strsep(&next, delimiter);
|
||||
uint8_t total_sentences = atoi(tokens);
|
||||
if ((total_sentences < 1) ||
|
||||
(total_sentences > 8)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Sentence number within the current GSV data set */
|
||||
tokens = strsep(&next, delimiter);
|
||||
uint8_t current_sentence = atoi(tokens);
|
||||
if (current_sentence < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* # of satellites currently in view */
|
||||
tokens = strsep(&next, delimiter);
|
||||
gsv_partial.SatsInView = atoi(tokens);
|
||||
|
||||
/* Find out if this is the first sentence in the GSV set */
|
||||
if (current_sentence == 1) {
|
||||
if (gsv_expected_mask != gsv_processed_mask) {
|
||||
/* We are starting over when we haven't yet finished our previous GSV group */
|
||||
gsv_incomplete_error++;
|
||||
}
|
||||
|
||||
/* First GSV sentence in the sequence, reset our expected_mask */
|
||||
gsv_expected_mask = (1 << total_sentences) - 1;
|
||||
}
|
||||
|
||||
uint8_t current_sentence_id = (1 << (current_sentence - 1));
|
||||
if (gsv_processed_mask & current_sentence_id) {
|
||||
/* Duplicate sentence in this GSV set */
|
||||
gsv_duplicate_error++;
|
||||
} else {
|
||||
/* Note that we've seen this sentence */
|
||||
gsv_processed_mask |= current_sentence_id;
|
||||
}
|
||||
|
||||
/* Make sure this sentence can fit in our GPSSatellites object */
|
||||
if ((current_sentence * 4) <= NELEMENTS(gsv_partial.PRN)) {
|
||||
/* Process 4 blocks of satellite info */
|
||||
for (uint8_t i = 0; next && i < 4; i++) {
|
||||
uint8_t sat_index = ((current_sentence - 1) * 4) + i;
|
||||
|
||||
/* PRN number */
|
||||
tokens = strsep(&next, delimiter);
|
||||
gsv_partial.PRN[sat_index] = atoi(tokens);
|
||||
|
||||
/* Elevation */
|
||||
tokens = strsep(&next, delimiter);
|
||||
gsv_partial.Elevation[sat_index] = NMEA_real_to_float(tokens);
|
||||
|
||||
/* Azimuth */
|
||||
tokens = strsep(&next, delimiter);
|
||||
gsv_partial.Azimuth[sat_index] = NMEA_real_to_float(tokens);
|
||||
|
||||
/* SNR */
|
||||
tokens = strsep(&next, delimiter);
|
||||
gsv_partial.SNR[sat_index] = atoi(tokens);
|
||||
}
|
||||
}
|
||||
|
||||
/* Find out if we're finished processing all GSV sentences in the set */
|
||||
if ((gsv_expected_mask != 0) &&
|
||||
(gsv_processed_mask == gsv_expected_mask)) {
|
||||
/* GSV set has been fully processed. Update the GPSSatellites object. */
|
||||
GPSSatellitesSet (&gsv_partial);
|
||||
memset ((void *)&gsv_partial, 0, sizeof(gsv_partial));
|
||||
gsv_expected_mask = 0;
|
||||
gsv_processed_mask = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse an NMEA GPGSA sentence and update the given UAVObject
|
||||
* \param[in] A pointer to a GPSPosition UAVObject to be updated.
|
||||
|
111
flight/OpenPilot/UAVObjects/gpssatellites.c
Normal file
111
flight/OpenPilot/UAVObjects/gpssatellites.c
Normal file
@ -0,0 +1,111 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup GPSSatellites GPSSatellites
|
||||
* @brief Contains information about the GPS satellites in view from @ref GPSModule.
|
||||
*
|
||||
* Autogenerated files and functions for GPSSatellites Object
|
||||
* @{
|
||||
*
|
||||
* @file gpssatellites.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the GPSSatellites object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: gpssatellites.xml.
|
||||
* This is an automatically generated file.
|
||||
* DO NOT modify manually.
|
||||
*
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "openpilot.h"
|
||||
#include "gpssatellites.h"
|
||||
|
||||
// Private variables
|
||||
static UAVObjHandle handle;
|
||||
|
||||
// Private functions
|
||||
static void setDefaults(UAVObjHandle obj, uint16_t instId);
|
||||
|
||||
/**
|
||||
* Initialize object.
|
||||
* \return 0 Success
|
||||
* \return -1 Failure
|
||||
*/
|
||||
int32_t GPSSatellitesInitialize()
|
||||
{
|
||||
// Register object with the object manager
|
||||
handle = UAVObjRegister(GPSSATELLITES_OBJID, GPSSATELLITES_NAME, GPSSATELLITES_METANAME, 0,
|
||||
GPSSATELLITES_ISSINGLEINST, GPSSATELLITES_ISSETTINGS, GPSSATELLITES_NUMBYTES, &setDefaults);
|
||||
|
||||
// Done
|
||||
if (handle != 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize object fields and metadata with the default values.
|
||||
* If a default value is not specified the object fields
|
||||
* will be initialized to zero.
|
||||
*/
|
||||
static void setDefaults(UAVObjHandle obj, uint16_t instId)
|
||||
{
|
||||
GPSSatellitesData data;
|
||||
UAVObjMetadata metadata;
|
||||
|
||||
// Initialize object fields to their default values
|
||||
UAVObjGetInstanceData(obj, instId, &data);
|
||||
memset(&data, 0, sizeof(GPSSatellitesData));
|
||||
|
||||
UAVObjSetInstanceData(obj, instId, &data);
|
||||
|
||||
// Initialize object metadata to their default values
|
||||
metadata.access = ACCESS_READWRITE;
|
||||
metadata.gcsAccess = ACCESS_READWRITE;
|
||||
metadata.telemetryAcked = 0;
|
||||
metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC;
|
||||
metadata.telemetryUpdatePeriod = 10000;
|
||||
metadata.gcsTelemetryAcked = 0;
|
||||
metadata.gcsTelemetryUpdateMode = UPDATEMODE_MANUAL;
|
||||
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||
metadata.loggingUpdateMode = UPDATEMODE_PERIODIC;
|
||||
metadata.loggingUpdatePeriod = 30000;
|
||||
UAVObjSetMetadata(obj, &metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object handle
|
||||
*/
|
||||
UAVObjHandle GPSSatellitesHandle()
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
107
flight/OpenPilot/UAVObjects/inc/gpssatellites.h
Normal file
107
flight/OpenPilot/UAVObjects/inc/gpssatellites.h
Normal file
@ -0,0 +1,107 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup GPSSatellites GPSSatellites
|
||||
* @brief Contains information about the GPS satellites in view from @ref GPSModule.
|
||||
*
|
||||
* Autogenerated files and functions for GPSSatellites Object
|
||||
|
||||
* @{
|
||||
*
|
||||
* @file gpssatellites.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the GPSSatellites object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: gpssatellites.xml.
|
||||
* This is an automatically generated file.
|
||||
* DO NOT modify manually.
|
||||
*
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef GPSSATELLITES_H
|
||||
#define GPSSATELLITES_H
|
||||
|
||||
// Object constants
|
||||
#define GPSSATELLITES_OBJID 3593446318U
|
||||
#define GPSSATELLITES_NAME "GPSSatellites"
|
||||
#define GPSSATELLITES_METANAME "GPSSatellitesMeta"
|
||||
#define GPSSATELLITES_ISSINGLEINST 1
|
||||
#define GPSSATELLITES_ISSETTINGS 0
|
||||
#define GPSSATELLITES_NUMBYTES sizeof(GPSSatellitesData)
|
||||
|
||||
// Object access macros
|
||||
/**
|
||||
* @function GPSSatellitesGet(dataOut)
|
||||
* @brief Populate a GPSSatellitesData object
|
||||
* @param[out] dataOut
|
||||
*/
|
||||
#define GPSSatellitesGet(dataOut) UAVObjGetData(GPSSatellitesHandle(), dataOut)
|
||||
#define GPSSatellitesSet(dataIn) UAVObjSetData(GPSSatellitesHandle(), dataIn)
|
||||
#define GPSSatellitesInstGet(instId, dataOut) UAVObjGetInstanceData(GPSSatellitesHandle(), instId, dataOut)
|
||||
#define GPSSatellitesInstSet(instId, dataIn) UAVObjSetInstanceData(GPSSatellitesHandle(), instId, dataIn)
|
||||
#define GPSSatellitesConnectQueue(queue) UAVObjConnectQueue(GPSSatellitesHandle(), queue, EV_MASK_ALL_UPDATES)
|
||||
#define GPSSatellitesConnectCallback(cb) UAVObjConnectCallback(GPSSatellitesHandle(), cb, EV_MASK_ALL_UPDATES)
|
||||
#define GPSSatellitesCreateInstance() UAVObjCreateInstance(GPSSatellitesHandle())
|
||||
#define GPSSatellitesRequestUpdate() UAVObjRequestUpdate(GPSSatellitesHandle())
|
||||
#define GPSSatellitesRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(GPSSatellitesHandle(), instId)
|
||||
#define GPSSatellitesUpdated() UAVObjUpdated(GPSSatellitesHandle())
|
||||
#define GPSSatellitesInstUpdated(instId) UAVObjUpdated(GPSSatellitesHandle(), instId)
|
||||
#define GPSSatellitesGetMetadata(dataOut) UAVObjGetMetadata(GPSSatellitesHandle(), dataOut)
|
||||
#define GPSSatellitesSetMetadata(dataIn) UAVObjSetMetadata(GPSSatellitesHandle(), dataIn)
|
||||
#define GPSSatellitesReadOnly(dataIn) UAVObjReadOnly(GPSSatellitesHandle())
|
||||
|
||||
// Object data
|
||||
typedef struct {
|
||||
int8_t SatsInView;
|
||||
int8_t PRN[16];
|
||||
float Elevation[16];
|
||||
float Azimuth[16];
|
||||
int8_t SNR[16];
|
||||
|
||||
} __attribute__((packed)) GPSSatellitesData;
|
||||
|
||||
// Field information
|
||||
// Field SatsInView information
|
||||
// Field PRN information
|
||||
/* Number of elements for field PRN */
|
||||
#define GPSSATELLITES_PRN_NUMELEM 16
|
||||
// Field Elevation information
|
||||
/* Number of elements for field Elevation */
|
||||
#define GPSSATELLITES_ELEVATION_NUMELEM 16
|
||||
// Field Azimuth information
|
||||
/* Number of elements for field Azimuth */
|
||||
#define GPSSATELLITES_AZIMUTH_NUMELEM 16
|
||||
// Field SNR information
|
||||
/* Number of elements for field SNR */
|
||||
#define GPSSATELLITES_SNR_NUMELEM 16
|
||||
|
||||
|
||||
// Generic interface functions
|
||||
int32_t GPSSatellitesInitialize();
|
||||
UAVObjHandle GPSSatellitesHandle();
|
||||
|
||||
#endif // GPSSATELLITES_H
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -46,6 +46,7 @@
|
||||
#include "flighttelemetrystats.h"
|
||||
#include "gcstelemetrystats.h"
|
||||
#include "gpsposition.h"
|
||||
#include "gpssatellites.h"
|
||||
#include "gpstime.h"
|
||||
#include "homelocation.h"
|
||||
#include "manualcontrolcommand.h"
|
||||
@ -85,6 +86,7 @@ void UAVObjectsInitializeAll()
|
||||
FlightTelemetryStatsInitialize();
|
||||
GCSTelemetryStatsInitialize();
|
||||
GPSPositionInitialize();
|
||||
GPSSatellitesInitialize();
|
||||
GPSTimeInitialize();
|
||||
HomeLocationInitialize();
|
||||
ManualControlCommandInitialize();
|
||||
|
200
ground/src/plugins/uavobjects/gpssatellites.cpp
Normal file
200
ground/src/plugins/uavobjects/gpssatellites.cpp
Normal file
@ -0,0 +1,200 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file gpssatellites.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup UAVObjectsPlugin UAVObjects Plugin
|
||||
* @{
|
||||
*
|
||||
* @note Object definition file: gpssatellites.xml.
|
||||
* This is an automatically generated file.
|
||||
* DO NOT modify manually.
|
||||
*
|
||||
* @brief The UAVUObjects GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "gpssatellites.h"
|
||||
#include "uavobjectfield.h"
|
||||
|
||||
const QString GPSSatellites::NAME = QString("GPSSatellites");
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
GPSSatellites::GPSSatellites(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
||||
{
|
||||
// Create fields
|
||||
QList<UAVObjectField*> fields;
|
||||
QStringList SatsInViewElemNames;
|
||||
SatsInViewElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("SatsInView"), QString(""), UAVObjectField::INT8, SatsInViewElemNames, QStringList()) );
|
||||
QStringList PRNElemNames;
|
||||
PRNElemNames.append("0");
|
||||
PRNElemNames.append("1");
|
||||
PRNElemNames.append("2");
|
||||
PRNElemNames.append("3");
|
||||
PRNElemNames.append("4");
|
||||
PRNElemNames.append("5");
|
||||
PRNElemNames.append("6");
|
||||
PRNElemNames.append("7");
|
||||
PRNElemNames.append("8");
|
||||
PRNElemNames.append("9");
|
||||
PRNElemNames.append("10");
|
||||
PRNElemNames.append("11");
|
||||
PRNElemNames.append("12");
|
||||
PRNElemNames.append("13");
|
||||
PRNElemNames.append("14");
|
||||
PRNElemNames.append("15");
|
||||
fields.append( new UAVObjectField(QString("PRN"), QString(""), UAVObjectField::INT8, PRNElemNames, QStringList()) );
|
||||
QStringList ElevationElemNames;
|
||||
ElevationElemNames.append("0");
|
||||
ElevationElemNames.append("1");
|
||||
ElevationElemNames.append("2");
|
||||
ElevationElemNames.append("3");
|
||||
ElevationElemNames.append("4");
|
||||
ElevationElemNames.append("5");
|
||||
ElevationElemNames.append("6");
|
||||
ElevationElemNames.append("7");
|
||||
ElevationElemNames.append("8");
|
||||
ElevationElemNames.append("9");
|
||||
ElevationElemNames.append("10");
|
||||
ElevationElemNames.append("11");
|
||||
ElevationElemNames.append("12");
|
||||
ElevationElemNames.append("13");
|
||||
ElevationElemNames.append("14");
|
||||
ElevationElemNames.append("15");
|
||||
fields.append( new UAVObjectField(QString("Elevation"), QString("degrees"), UAVObjectField::FLOAT32, ElevationElemNames, QStringList()) );
|
||||
QStringList AzimuthElemNames;
|
||||
AzimuthElemNames.append("0");
|
||||
AzimuthElemNames.append("1");
|
||||
AzimuthElemNames.append("2");
|
||||
AzimuthElemNames.append("3");
|
||||
AzimuthElemNames.append("4");
|
||||
AzimuthElemNames.append("5");
|
||||
AzimuthElemNames.append("6");
|
||||
AzimuthElemNames.append("7");
|
||||
AzimuthElemNames.append("8");
|
||||
AzimuthElemNames.append("9");
|
||||
AzimuthElemNames.append("10");
|
||||
AzimuthElemNames.append("11");
|
||||
AzimuthElemNames.append("12");
|
||||
AzimuthElemNames.append("13");
|
||||
AzimuthElemNames.append("14");
|
||||
AzimuthElemNames.append("15");
|
||||
fields.append( new UAVObjectField(QString("Azimuth"), QString("degrees"), UAVObjectField::FLOAT32, AzimuthElemNames, QStringList()) );
|
||||
QStringList SNRElemNames;
|
||||
SNRElemNames.append("0");
|
||||
SNRElemNames.append("1");
|
||||
SNRElemNames.append("2");
|
||||
SNRElemNames.append("3");
|
||||
SNRElemNames.append("4");
|
||||
SNRElemNames.append("5");
|
||||
SNRElemNames.append("6");
|
||||
SNRElemNames.append("7");
|
||||
SNRElemNames.append("8");
|
||||
SNRElemNames.append("9");
|
||||
SNRElemNames.append("10");
|
||||
SNRElemNames.append("11");
|
||||
SNRElemNames.append("12");
|
||||
SNRElemNames.append("13");
|
||||
SNRElemNames.append("14");
|
||||
SNRElemNames.append("15");
|
||||
fields.append( new UAVObjectField(QString("SNR"), QString(""), UAVObjectField::INT8, SNRElemNames, QStringList()) );
|
||||
|
||||
// Initialize object
|
||||
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
||||
// Set the default field values
|
||||
setDefaultFieldValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default metadata for this object
|
||||
*/
|
||||
UAVObject::Metadata GPSSatellites::getDefaultMetadata()
|
||||
{
|
||||
UAVObject::Metadata metadata;
|
||||
metadata.flightAccess = ACCESS_READWRITE;
|
||||
metadata.gcsAccess = ACCESS_READWRITE;
|
||||
metadata.gcsTelemetryAcked = 0;
|
||||
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL;
|
||||
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||
metadata.flightTelemetryAcked = 0;
|
||||
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||
metadata.flightTelemetryUpdatePeriod = 10000;
|
||||
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||
metadata.loggingUpdatePeriod = 30000;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize object fields with the default values.
|
||||
* If a default value is not specified the object fields
|
||||
* will be initialized to zero.
|
||||
*/
|
||||
void GPSSatellites::setDefaultFieldValues()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the object data fields
|
||||
*/
|
||||
GPSSatellites::DataFields GPSSatellites::getData()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the object data fields
|
||||
*/
|
||||
void GPSSatellites::setData(const DataFields& data)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
// Get metadata
|
||||
Metadata mdata = getMetadata();
|
||||
// Update object if the access mode permits
|
||||
if ( mdata.gcsAccess == ACCESS_READWRITE )
|
||||
{
|
||||
this->data = data;
|
||||
emit objectUpdatedAuto(this); // trigger object updated event
|
||||
emit objectUpdated(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a clone of this object, a new instance ID must be specified.
|
||||
* Do not use this function directly to create new instances, the
|
||||
* UAVObjectManager should be used instead.
|
||||
*/
|
||||
UAVDataObject* GPSSatellites::clone(quint32 instID)
|
||||
{
|
||||
GPSSatellites* obj = new GPSSatellites();
|
||||
obj->initialize(instID, this->getMetaObject());
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static function to retrieve an instance of the object.
|
||||
*/
|
||||
GPSSatellites* GPSSatellites::GetInstance(UAVObjectManager* objMngr, quint32 instID)
|
||||
{
|
||||
return dynamic_cast<GPSSatellites*>(objMngr->getObject(GPSSatellites::OBJID, instID));
|
||||
}
|
94
ground/src/plugins/uavobjects/gpssatellites.h
Normal file
94
ground/src/plugins/uavobjects/gpssatellites.h
Normal file
@ -0,0 +1,94 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file gpssatellites.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup UAVObjectsPlugin UAVObjects Plugin
|
||||
* @{
|
||||
*
|
||||
* @note Object definition file: gpssatellites.xml.
|
||||
* This is an automatically generated file.
|
||||
* DO NOT modify manually.
|
||||
*
|
||||
* @brief The UAVUObjects GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef GPSSATELLITES_H
|
||||
#define GPSSATELLITES_H
|
||||
|
||||
#include "uavdataobject.h"
|
||||
#include "uavobjectmanager.h"
|
||||
|
||||
class UAVOBJECTS_EXPORT GPSSatellites: public UAVDataObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Field structure
|
||||
typedef struct {
|
||||
qint8 SatsInView;
|
||||
qint8 PRN[16];
|
||||
float Elevation[16];
|
||||
float Azimuth[16];
|
||||
qint8 SNR[16];
|
||||
|
||||
} __attribute__((packed)) DataFields;
|
||||
|
||||
// Field information
|
||||
// Field SatsInView information
|
||||
// Field PRN information
|
||||
/* Number of elements for field PRN */
|
||||
static const quint32 PRN_NUMELEM = 16;
|
||||
// Field Elevation information
|
||||
/* Number of elements for field Elevation */
|
||||
static const quint32 ELEVATION_NUMELEM = 16;
|
||||
// Field Azimuth information
|
||||
/* Number of elements for field Azimuth */
|
||||
static const quint32 AZIMUTH_NUMELEM = 16;
|
||||
// Field SNR information
|
||||
/* Number of elements for field SNR */
|
||||
static const quint32 SNR_NUMELEM = 16;
|
||||
|
||||
|
||||
// Constants
|
||||
static const quint32 OBJID = 3593446318U;
|
||||
static const QString NAME;
|
||||
static const bool ISSINGLEINST = 1;
|
||||
static const bool ISSETTINGS = 0;
|
||||
static const quint32 NUMBYTES = sizeof(DataFields);
|
||||
|
||||
// Functions
|
||||
GPSSatellites();
|
||||
|
||||
DataFields getData();
|
||||
void setData(const DataFields& data);
|
||||
Metadata getDefaultMetadata();
|
||||
UAVDataObject* clone(quint32 instID);
|
||||
|
||||
static GPSSatellites* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
|
||||
|
||||
private:
|
||||
DataFields data;
|
||||
|
||||
void setDefaultFieldValues();
|
||||
|
||||
};
|
||||
|
||||
#endif // GPSSATELLITES_H
|
186
ground/src/plugins/uavobjects/gpssatellites.py
Normal file
186
ground/src/plugins/uavobjects/gpssatellites.py
Normal file
@ -0,0 +1,186 @@
|
||||
##
|
||||
##############################################################################
|
||||
#
|
||||
# @file gpssatellites.py
|
||||
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
# @brief Implementation of the GPSSatellites object. This file has been
|
||||
# automatically generated by the UAVObjectGenerator.
|
||||
#
|
||||
# @note Object definition file: gpssatellites.xml.
|
||||
# This is an automatically generated file.
|
||||
# DO NOT modify manually.
|
||||
#
|
||||
# @see The GNU Public License (GPL) Version 3
|
||||
#
|
||||
#############################################################################/
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
|
||||
import uavobject
|
||||
|
||||
import struct
|
||||
from collections import namedtuple
|
||||
|
||||
# This is a list of instances of the data fields contained in this object
|
||||
_fields = [ \
|
||||
uavobject.UAVObjectField(
|
||||
'SatsInView',
|
||||
'b',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'PRN',
|
||||
'b',
|
||||
16,
|
||||
[
|
||||
'0',
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'10',
|
||||
'11',
|
||||
'12',
|
||||
'13',
|
||||
'14',
|
||||
'15',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Elevation',
|
||||
'f',
|
||||
16,
|
||||
[
|
||||
'0',
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'10',
|
||||
'11',
|
||||
'12',
|
||||
'13',
|
||||
'14',
|
||||
'15',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Azimuth',
|
||||
'f',
|
||||
16,
|
||||
[
|
||||
'0',
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'10',
|
||||
'11',
|
||||
'12',
|
||||
'13',
|
||||
'14',
|
||||
'15',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'SNR',
|
||||
'b',
|
||||
16,
|
||||
[
|
||||
'0',
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'10',
|
||||
'11',
|
||||
'12',
|
||||
'13',
|
||||
'14',
|
||||
'15',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
class GPSSatellites(uavobject.UAVObject):
|
||||
## Object constants
|
||||
OBJID = 3593446318
|
||||
NAME = "GPSSatellites"
|
||||
METANAME = "GPSSatellitesMeta"
|
||||
ISSINGLEINST = 1
|
||||
ISSETTINGS = 0
|
||||
|
||||
def __init__(self):
|
||||
uavobject.UAVObject.__init__(self,
|
||||
self.OBJID,
|
||||
self.NAME,
|
||||
self.METANAME,
|
||||
0,
|
||||
self.ISSINGLEINST)
|
||||
|
||||
for f in _fields:
|
||||
self.add_field(f)
|
||||
|
||||
def __str__(self):
|
||||
s = ("0x%08X (%10u) %-30s %3u bytes format '%s'\n"
|
||||
% (self.OBJID, self.OBJID, self.NAME, self.get_struct().size, self.get_struct().format))
|
||||
for f in self.get_tuple()._fields:
|
||||
s += ("\t%s\n" % f)
|
||||
return (s)
|
||||
|
||||
def main():
|
||||
# Instantiate the object and dump out some interesting info
|
||||
x = GPSSatellites()
|
||||
print (x)
|
||||
|
||||
if __name__ == "__main__":
|
||||
#import pdb ; pdb.run('main()')
|
||||
main()
|
@ -39,6 +39,7 @@ HEADERS += uavobjects_global.h \
|
||||
navigationdesired.h \
|
||||
gpsposition.h \
|
||||
gpstime.h \
|
||||
gpssatellites.h \
|
||||
positionactual.h \
|
||||
flightbatterystate.h \
|
||||
homelocation.h
|
||||
@ -77,6 +78,7 @@ SOURCES += uavobject.cpp \
|
||||
navigationdesired.cpp \
|
||||
gpsposition.cpp \
|
||||
gpstime.cpp \
|
||||
gpssatellites.cpp \
|
||||
positionactual.cpp \
|
||||
flightbatterystate.cpp \
|
||||
homelocation.cpp
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "flighttelemetrystats.h"
|
||||
#include "gcstelemetrystats.h"
|
||||
#include "gpsposition.h"
|
||||
#include "gpssatellites.h"
|
||||
#include "gpstime.h"
|
||||
#include "homelocation.h"
|
||||
#include "manualcontrolcommand.h"
|
||||
@ -87,6 +88,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
|
||||
objMngr->registerObject( new FlightTelemetryStats() );
|
||||
objMngr->registerObject( new GCSTelemetryStats() );
|
||||
objMngr->registerObject( new GPSPosition() );
|
||||
objMngr->registerObject( new GPSSatellites() );
|
||||
objMngr->registerObject( new GPSTime() );
|
||||
objMngr->registerObject( new HomeLocation() );
|
||||
objMngr->registerObject( new ManualControlCommand() );
|
||||
|
14
ground/src/shared/uavobjectdefinition/gpssatellites.xml
Normal file
14
ground/src/shared/uavobjectdefinition/gpssatellites.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<xml>
|
||||
<object name="GPSSatellites" singleinstance="true" settings="false">
|
||||
<description>Contains information about the GPS satellites in view from @ref GPSModule.</description>
|
||||
<field name="SatsInView" units="" type="int8" elements="1"/>
|
||||
<field name="PRN" units="" type="int8" elements="16"/>
|
||||
<field name="Elevation" units="degrees" type="float" elements="16"/>
|
||||
<field name="Azimuth" units="degrees" type="float" elements="16"/>
|
||||
<field name="SNR" units="" type="int8" elements="16"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="false" updatemode="periodic" period="10000"/>
|
||||
<logging updatemode="periodic" period="30000"/>
|
||||
</object>
|
||||
</xml>
|
Loading…
x
Reference in New Issue
Block a user