mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
change to GPS: do not update UAVObject more than 1ce per cycle
This commit is contained in:
parent
0b7538c3fe
commit
88f7567247
@ -1,42 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @addtogroup OpenPilotModules OpenPilot Modules
|
|
||||||
* @{
|
|
||||||
* @addtogroup GSPModule GPS Module
|
|
||||||
* @brief Process GPS information
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
* @file NMEA.h
|
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
||||||
* @brief GPS module, handles GPS and NMEA stream
|
|
||||||
* @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 NMEA_H
|
|
||||||
#define NMEA_H
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define NMEA_MAX_PACKET_LENGTH 96
|
|
||||||
|
|
||||||
extern bool NMEA_update_position(char *nmea_sentence);
|
|
||||||
extern bool NMEA_checksum(char *nmea_sentence);
|
|
||||||
|
|
||||||
#endif /* NMEA_H */
|
|
@ -35,10 +35,6 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "NMEA.h"
|
|
||||||
#include "UBX.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include "gpsposition.h"
|
#include "gpsposition.h"
|
||||||
#include "homelocation.h"
|
#include "homelocation.h"
|
||||||
#include "gpstime.h"
|
#include "gpstime.h"
|
||||||
@ -48,6 +44,9 @@
|
|||||||
#include "CoordinateConversions.h"
|
#include "CoordinateConversions.h"
|
||||||
#include "hwsettings.h"
|
#include "hwsettings.h"
|
||||||
|
|
||||||
|
#include "NMEA.h"
|
||||||
|
#include "UBX.h"
|
||||||
|
|
||||||
|
|
||||||
// ****************
|
// ****************
|
||||||
// Private functions
|
// Private functions
|
||||||
@ -188,6 +187,8 @@ static void gpsTask(void *parameters)
|
|||||||
timeOfLastUpdateMs = timeNowMs;
|
timeOfLastUpdateMs = timeNowMs;
|
||||||
timeOfLastCommandMs = timeNowMs;
|
timeOfLastCommandMs = timeNowMs;
|
||||||
|
|
||||||
|
|
||||||
|
GPSPositionGet(&GpsData);
|
||||||
// Loop forever
|
// Loop forever
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -331,7 +332,7 @@ static void gpsTask(void *parameters)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Valid checksum, use this packet to update the GPS position
|
{ // Valid checksum, use this packet to update the GPS position
|
||||||
if (!NMEA_update_position(&gps_rx_buffer[1])) {
|
if (!NMEA_update_position(&gps_rx_buffer[1],&GpsData)) {
|
||||||
//PIOS_DEBUG_PinHigh(2);
|
//PIOS_DEBUG_PinHigh(2);
|
||||||
++numParsingErrors;
|
++numParsingErrors;
|
||||||
//PIOS_DEBUG_PinLow(2);
|
//PIOS_DEBUG_PinLow(2);
|
||||||
@ -352,7 +353,6 @@ static void gpsTask(void *parameters)
|
|||||||
{ // we have not received any valid GPS sentences for a while.
|
{ // we have not received any valid GPS sentences for a while.
|
||||||
// either the GPS is not plugged in or a hardware problem or the GPS has locked up.
|
// either the GPS is not plugged in or a hardware problem or the GPS has locked up.
|
||||||
|
|
||||||
GPSPositionGet(&GpsData);
|
|
||||||
GpsData.Status = GPSPOSITION_STATUS_NOGPS;
|
GpsData.Status = GPSPOSITION_STATUS_NOGPS;
|
||||||
GPSPositionSet(&GpsData);
|
GPSPositionSet(&GpsData);
|
||||||
AlarmsSet(SYSTEMALARMS_ALARM_GPS, SYSTEMALARMS_ALARM_ERROR);
|
AlarmsSet(SYSTEMALARMS_ALARM_GPS, SYSTEMALARMS_ALARM_ERROR);
|
||||||
@ -361,8 +361,6 @@ static void gpsTask(void *parameters)
|
|||||||
else
|
else
|
||||||
{ // we appear to be receiving GPS sentences OK, we've had an update
|
{ // we appear to be receiving GPS sentences OK, we've had an update
|
||||||
|
|
||||||
GPSPositionGet(&GpsData);
|
|
||||||
|
|
||||||
#ifdef PIOS_GPS_SETS_HOMELOCATION
|
#ifdef PIOS_GPS_SETS_HOMELOCATION
|
||||||
HomeLocationData home;
|
HomeLocationData home;
|
||||||
HomeLocationGet(&home);
|
HomeLocationGet(&home);
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "openpilot.h"
|
#include "openpilot.h"
|
||||||
#include "pios.h"
|
#include "pios.h"
|
||||||
#include "NMEA.h"
|
|
||||||
#include "gpsposition.h"
|
#include "gpsposition.h"
|
||||||
|
#include "NMEA.h"
|
||||||
#include "gpstime.h"
|
#include "gpstime.h"
|
||||||
#include "gpssatellites.h"
|
#include "gpssatellites.h"
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ static bool NMEA_latlon_to_fixed_point(int32_t * latlon, char *nmea_latlon, bool
|
|||||||
* \return true if the sentence was successfully parsed
|
* \return true if the sentence was successfully parsed
|
||||||
* \return false if any errors were encountered with the parsing
|
* \return false if any errors were encountered with the parsing
|
||||||
*/
|
*/
|
||||||
bool NMEA_update_position(char *nmea_sentence)
|
bool NMEA_update_position(char *nmea_sentence, GPSPositionData *GpsData)
|
||||||
{
|
{
|
||||||
char* p = nmea_sentence;
|
char* p = nmea_sentence;
|
||||||
char* params[MAX_NB_PARAMS];
|
char* params[MAX_NB_PARAMS];
|
||||||
@ -340,11 +340,9 @@ bool NMEA_update_position(char *nmea_sentence)
|
|||||||
DEBUG_MSG("%s %d ", params[0], parser->cnt);
|
DEBUG_MSG("%s %d ", params[0], parser->cnt);
|
||||||
#endif
|
#endif
|
||||||
// Send the message to then parser and get it update the GpsData
|
// Send the message to then parser and get it update the GpsData
|
||||||
GPSPositionData GpsData;
|
bool gpsDataUpdated = false;
|
||||||
GPSPositionGet(&GpsData);
|
|
||||||
bool gpsDataUpdated;
|
|
||||||
|
|
||||||
if (!parser->handler(&GpsData, &gpsDataUpdated, params, nbParams)) {
|
if (!parser->handler(GpsData, &gpsDataUpdated, params, nbParams)) {
|
||||||
// Parse failed
|
// Parse failed
|
||||||
DEBUG_MSG("PARSE FAILED (\"%s\")\n", params[0]);
|
DEBUG_MSG("PARSE FAILED (\"%s\")\n", params[0]);
|
||||||
return false;
|
return false;
|
||||||
@ -356,7 +354,7 @@ bool NMEA_update_position(char *nmea_sentence)
|
|||||||
#ifdef DEBUG_MGSID_IN
|
#ifdef DEBUG_MGSID_IN
|
||||||
DEBUG_MSG("U");
|
DEBUG_MSG("U");
|
||||||
#endif
|
#endif
|
||||||
GPSPositionSet(&GpsData);
|
GPSPositionSet(GpsData);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MGSID_IN
|
#ifdef DEBUG_MGSID_IN
|
||||||
@ -431,7 +429,7 @@ static bool nmeaProcessGPRMC(GPSPositionData * GpsData, bool* gpsDataUpdated, ch
|
|||||||
DEBUG_MSG(" DateOfFix=%s\n\n", param[9]);
|
DEBUG_MSG(" DateOfFix=%s\n\n", param[9]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*gpsDataUpdated = true;
|
*gpsDataUpdated = false;
|
||||||
|
|
||||||
#if !defined(PIOS_GPS_MINIMAL)
|
#if !defined(PIOS_GPS_MINIMAL)
|
||||||
GPSTimeData gpst;
|
GPSTimeData gpst;
|
||||||
@ -489,7 +487,7 @@ static bool nmeaProcessGPVTG(GPSPositionData * GpsData, bool* gpsDataUpdated, ch
|
|||||||
DEBUG_MSG(" GroundSpeed=%s %s\n", param[5], param[6]);
|
DEBUG_MSG(" GroundSpeed=%s %s\n", param[5], param[6]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*gpsDataUpdated = true;
|
*gpsDataUpdated = false;
|
||||||
|
|
||||||
GpsData->Heading = NMEA_real_to_float(param[1]);
|
GpsData->Heading = NMEA_real_to_float(param[1]);
|
||||||
GpsData->Groundspeed = NMEA_real_to_float(param[5]) * 0.51444; // to m/s
|
GpsData->Groundspeed = NMEA_real_to_float(param[5]) * 0.51444; // to m/s
|
||||||
@ -555,7 +553,7 @@ static bool nmeaProcessGPGSV(GPSPositionData * GpsData, bool* gpsDataUpdated, ch
|
|||||||
uint8_t nbSentences = atoi(param[1]);
|
uint8_t nbSentences = atoi(param[1]);
|
||||||
uint8_t currSentence = atoi(param[2]);
|
uint8_t currSentence = atoi(param[2]);
|
||||||
|
|
||||||
*gpsDataUpdated = true;
|
*gpsDataUpdated = false;
|
||||||
|
|
||||||
if (nbSentences < 1 || nbSentences > 8 || currSentence < 1 || currSentence > nbSentences)
|
if (nbSentences < 1 || nbSentences > 8 || currSentence < 1 || currSentence > nbSentences)
|
||||||
return false;
|
return false;
|
||||||
@ -639,7 +637,7 @@ static bool nmeaProcessGPGSA(GPSPositionData * GpsData, bool* gpsDataUpdated, ch
|
|||||||
DEBUG_MSG(" VDOP=%s\n", param[17]);
|
DEBUG_MSG(" VDOP=%s\n", param[17]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*gpsDataUpdated = true;
|
*gpsDataUpdated = false;
|
||||||
|
|
||||||
switch (atoi(param[2])) {
|
switch (atoi(param[2])) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
extern bool NMEA_update_position(char *nmea_sentence);
|
extern bool NMEA_update_position(char *nmea_sentence, GPSPositionData *GpsData);
|
||||||
extern bool NMEA_checksum(char *nmea_sentence);
|
extern bool NMEA_checksum(char *nmea_sentence);
|
||||||
|
|
||||||
#endif /* NMEA_H */
|
#endif /* NMEA_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user