1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-25: simplified gps structure

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@404 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
sambas 2010-03-28 14:36:18 +00:00 committed by sambas
parent 5404273e7c
commit 066f42a2c5
3 changed files with 21 additions and 93 deletions

View File

@ -392,23 +392,22 @@ void nmeaProcessGPGGA(char* packet)
// get UTC time [hhmmss.sss]
tokens = strtok_r(NULL, delimiter, &last);
strcpy(GpsInfo.PosLLA.TimeOfFix.c,tokens);
strcpy(GpsInfo.TimeOfFix,tokens);
// next field: latitude
// get latitude [ddmm.mmmmm]
tokens = strtok_r(NULL, delimiter, &last);
//strcpy(GpsInfo.PosLLA.lat.c,token);
if(1) // 5 desimal output
{
deg=strtol (tokens,&pEnd,10);
desim=strtol (pEnd+1,NULL,10);
GpsInfo.PosLLA.lat.i=deg*100000+desim;
GpsInfo.lat=deg*100000+desim;
}
else // 4 desimal output
{
deg=strtol (tokens,&pEnd,10);
desim=strtol (pEnd+1,NULL,10);
GpsInfo.PosLLA.lat.i=deg*10000+desim;
GpsInfo.lat=deg*10000+desim;
}
// convert to pure degrees [dd.dddd] format
/* minutesfrac = modf(GpsInfo.PosLLA.lat.f/100, &degrees);
@ -424,18 +423,17 @@ void nmeaProcessGPGGA(char* packet)
// next field: longitude
// get longitude [ddmm.mmmmm]
tokens = strtok_r(NULL, delimiter, &last);
//strcpy(GpsInfo.PosLLA.lon.c,token);
if(1) // 5 desimal output
{
deg=strtol (tokens,&pEnd,10);
desim=strtol (pEnd+1,NULL,10);
GpsInfo.PosLLA.lon.i=deg*100000+desim;
GpsInfo.lon=deg*100000+desim;
}
else // 4 desimal output
{
deg=strtol (tokens,&pEnd,10);
desim=strtol (pEnd+1,NULL,10);
GpsInfo.PosLLA.lon.i=deg*10000+desim;
GpsInfo.lon=deg*10000+desim;
}
// convert to pure degrees [dd.dddd] format
@ -468,11 +466,10 @@ void nmeaProcessGPGGA(char* packet)
// next field: altitude
// get altitude (in meters mm.m)
tokens = strtok_r(NULL, delimiter, &last);
//strcpy(GpsInfo.PosLLA.alt.c,tokens);
//reuse variables for alt
deg=strtol (tokens,&pEnd,10);
desim=strtol (pEnd+1,NULL,10);
GpsInfo.PosLLA.alt.i=deg*10+desim;
GpsInfo.alt=deg*10+desim;
// next field: altitude units, always 'M'
// next field: geoid seperation
@ -522,7 +519,7 @@ void nmeaProcessGPVTG(char* packet)
// get course (true north ref) in degrees [ddd.dd]
tokens = strtok_r(NULL, delimiter, &last);
strcpy(GpsInfo.VelHS.heading.c,tokens);
strcpy(GpsInfo.heading,tokens);
// next field: 'T'
tokens = strtok_r(NULL, delimiter, &last);
@ -543,10 +540,10 @@ void nmeaProcessGPVTG(char* packet)
// next field: speed (km/h)
// get speed in km/h
tokens = strtok_r(NULL, delimiter, &last);
strcpy(GpsInfo.VelHS.speed.c,tokens);
strcpy(GpsInfo.speed,tokens);
// next field: 'K'
// next field: checksum
GpsInfo.VelHS.updates++;
GpsInfo.updates++;
}

View File

@ -30,89 +30,20 @@
#define GPSINFO_H
// constants/macros/typdefs
typedef union union_float_u32
{
unsigned long i;
unsigned char b[4];
char c[12];
} float_u32;
typedef union union_double_u64
{
double f;
unsigned long long i;
unsigned char b[8];
} double_u64;
struct PositionLLA
{
float_u32 lat;
float_u32 lon;
float_u32 alt;
float_u32 TimeOfFix;
uint16_t updates;
};
struct VelocityENU
{
float_u32 east;
float_u32 north;
float_u32 up;
float_u32 TimeOfFix;
uint16_t updates;
};
struct VelocityHS
{
float_u32 heading;
float_u32 speed;
float_u32 TimeOfFix;
uint16_t updates;
};
struct PositionECEF
{
float_u32 x;
float_u32 y;
float_u32 z;
float_u32 TimeOfFix;
uint16_t updates;
};
struct VelocityECEF
{
float_u32 x;
float_u32 y;
float_u32 z;
float_u32 TimeOfFix;
uint16_t updates;
};
struct UTCtime
{
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t min;
uint8_t sec;
uint8_t offset;
};
typedef struct struct_GpsInfo
{
float_u32 TimeOfWeek;
uint16_t WeekNum;
float_u32 UtcOffset;
uint8_t numSVs;
signed long lat;
signed long lon;
signed int alt;
char TimeOfFix[12];
// make these to values
char heading[12];
char speed[12];
uint16_t updates;
struct PositionLLA PosLLA;
struct PositionECEF PosECEF;
struct VelocityECEF VelECEF;
struct VelocityENU VelENU;
struct VelocityHS VelHS;
struct UTCtime UTC;
} GpsInfoType;

View File

@ -137,10 +137,10 @@ static void TaskTick(void *pvParameters)
for(;;)
{
/*PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"utc: %s alt:%u\r\n",GpsInfo.PosLLA.TimeOfFix.c,GpsInfo.PosLLA.alt.i);
PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"lat: %u lon:%u\r\n",GpsInfo.PosLLA.lat.i,GpsInfo.PosLLA.lon.i);
/*PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"utc: %s alt:%u\r\n",GpsInfo.TimeOfFix,GpsInfo.alt);
PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"lat: %u lon:%u\r\n",GpsInfo.lat,GpsInfo.lon);
PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"SV: %u\r\n",GpsInfo.numSVs);
PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"Heading: %s Speed: %s\r\n",GpsInfo.VelHS.heading.c,GpsInfo.VelHS.speed.c);
PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"Heading: %s Speed: %s\r\n",GpsInfo.heading,GpsInfo.speed);
*/
PIOS_LED_Toggle(LED1);
vTaskDelayUntil(&xLastExecutionTime, 1000 / portTICK_RATE_MS);