Skip to content
Snippets Groups Projects
Commit f57f0bb0 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Extended the features of the GPA driver.

parent c06fc4e2
No related branches found
No related tags found
No related merge requests found
# driver source files # driver source files
SET(sources asterx1_gps.cpp) SET(sources asterx1_gps.cpp stream_gps.cpp)
# application header files # application header files
SET(headers asterx1_gps.h) SET(headers asterx1_gps.h stream_gps.h)
# locate the the necessary dependencies # locate the the necessary dependencies
FIND_PACKAGE(iriutils) FIND_PACKAGE(iriutils)
......
This diff is collapsed.
This diff is collapsed.
...@@ -16,119 +16,179 @@ USB any port ...@@ -16,119 +16,179 @@ USB any port
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <asterx1_gps.h> #include "asterx1_gps.h"
#include "stream_gps.h"
using namespace std;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int opt; CasteRx1 myGps("gps","/dev/ttyACM0");
int ii; CEventServer *event_server=CEventServer::instance();
int retValue; std::list<std::string> events;
int nIterations = 10; unsigned int i=0,index;
int rate = MSEC500; //ONCHANGE, MSEC20, ... , MSEC100, ... SEC1, SEC5 TMeasEpoch meas_epoch;
string serial_device="/dev/ttyACM0"; TMeasExtra meas_extra;
streamsize tsDigits; TGPSNav gps_nav;
CasteRx1 *myGps; TGPSAlm gps_alm;
TGPSIon gps_ion;
TGPSUtc gps_utc;
TPVTCartesian pvt_cartesian;
TPVTGeodetic pvt_geodetic;
TPVTCov pvt_pos_cov_cartesian;
TPVTCov pvt_vel_cov_cartesian;
TPVTCov pvt_pos_cov_geodetic;
TPVTCov pvt_vel_cov_geodetic;
TPVTDOP pvt_dop;
std::cout << "\n\n TEST AsteRx1 GPS RECEIVER \n\n" << std::endl;
cout << "\n\n TEST AsteRx1 GPS RECEIVER \n\n" << endl; try{
myGps.openDevice();
events.push_back(myGps.get_new_meas_data_event_id());
events.push_back(myGps.get_new_gps_nav_data_event_id());
events.push_back(myGps.get_new_gps_alm_data_event_id());
events.push_back(myGps.get_new_gps_ion_data_event_id());
events.push_back(myGps.get_new_gps_utc_data_event_id());
events.push_back(myGps.get_new_pvt_data_event_id());
myGps.startAcquisition();
//for(i=0;i<100;i++)
for(;;)
{
index=event_server->wait_first(events,10000);
if(index==0)
{
myGps.get_meas_data(meas_epoch,meas_extra);
// std::cout << meas_epoch << std::endl;
// std::cout << meas_extra << std::endl;
}
else if(index==1)
{
myGps.get_gps_nav_data(gps_nav);
std::cout << gps_nav << std::endl;
}
else if(index==2)
{
myGps.get_gps_alm_data(gps_alm);
std::cout << gps_alm << std::endl;
}
else if(index==3)
{
myGps.get_gps_ion_data(gps_ion);
std::cout << gps_ion << std::endl;
}
else if(index==4)
{
myGps.get_gps_utc_data(gps_utc);
std::cout << gps_utc << std::endl;
}
else if(index==5)
{
std::cout << "GPS PVT" << std::endl;
myGps.get_pvt_data(pvt_cartesian,pvt_geodetic);
myGps.get_pvt_cov_data(pvt_pos_cov_cartesian,pvt_pos_cov_geodetic,pvt_vel_cov_cartesian,pvt_vel_cov_geodetic);
myGps.get_pvt_dop_data(pvt_dop);
}
}
myGps.stopAcquisition();
}catch(CException &e){
std::cout << e.what() << std::endl;
}
//cout << "acqPeriodValues[ONCHANGE]: " << acqPeriodValues[ONCHANGE] << endl; //cout << "acqPeriodValues[ONCHANGE]: " << acqPeriodValues[ONCHANGE] << endl;
// Argument management // Argument management
while ((opt = getopt(argc, argv, "u:n:r:h?"))!= -1) /* while ((opt = getopt(argc, argv, "u:n:r:h?"))!= -1)
{
switch (opt)
{
case 'u': // change USB device
serial_device = optarg;
break;
case 'n':
nIterations = atoi(optarg);
break;
case 'r':
rate = atoi(optarg);
break;
case '?': // help
case 'h':
default:
cout << " USAGE" << endl
<< " " << argv[0] << " [options]" << endl
<< " OPTIONS" << endl
<< " -u SERIAL_DEVICE (default: " << serial_device << ")" << endl
<< " -n NUMBER OF ITERATIONS (default: " << nIterations << ")" << endl
<< " -r ACQUISITION RATE: (default: " << rate << ")" << endl;
for (ii=0; ii<10; ii++)
{ {
switch (opt) cout << " " << ii << ": " << acqPeriodValues[ii] << endl;
{
case 'u': // change USB device
serial_device = optarg;
break;
case 'n':
nIterations = atoi(optarg);
break;
case 'r':
rate = atoi(optarg);
break;
case '?': // help
case 'h':
default:
cout << " USAGE" << endl
<< " " << argv[0] << " [options]" << endl
<< " OPTIONS" << endl
<< " -u SERIAL_DEVICE (default: " << serial_device << ")" << endl
<< " -n NUMBER OF ITERATIONS (default: " << nIterations << ")" << endl
<< " -r ACQUISITION RATE: (default: " << rate << ")" << endl;
for (ii=0; ii<10; ii++)
{
cout << " " << ii << ": " << acqPeriodValues[ii] << endl;
}
cout << endl;
return 1;
}
} }
cout << endl;
myGps = new CasteRx1(serial_device,rate); return 1;
}
myGps->setMapOrigin(41.388595, 2.113133, 120, 44.2); //sets map origin for coordinate transformation }
//myGps->printTM(); //prints to stdout the transformation matrix
myGps = new CasteRx1(serial_device,rate);
retValue = myGps->openDevice();//open device comm's
myGps->setMapOrigin(41.388595, 2.113133, 120, 44.2); //sets map origin for coordinate transformation
retValue = myGps->closeDevice();//close device comm's (stressing tests ...) //myGps->printTM(); //prints to stdout the transformation matrix
retValue = myGps->openDevice();//open device comm's, again
retValue = myGps->openDevice();//open device comm's
myGps->setPortName("/dev/ttyS1"); //checking that when device is open, port configuration can't be achieved
myGps->setAcquisitionRate(56); //checking that when invalid rate indexes prdouces an error and don't change the rate retValue = myGps->closeDevice();//close device comm's (stressing tests ...)
myGps->setAcquisitionRate(SEC2); //checking that when device is open rate configuration can be achieved retValue = myGps->openDevice();//open device comm's, again
myGps->setAcquisitionRate(rate); //checking that when device is open rate configuration can be achieved
myGps->setPortName("/dev/ttyS1"); //checking that when device is open, port configuration can't be achieved
if ( retValue == BASIC_SUCCESS ) myGps->setAcquisitionRate(56); //checking that when invalid rate indexes prdouces an error and don't change the rate
myGps->setAcquisitionRate(SEC2); //checking that when device is open rate configuration can be achieved
myGps->setAcquisitionRate(rate); //checking that when device is open rate configuration can be achieved
if ( retValue == BASIC_SUCCESS )
{
retValue = myGps->startAcquisition();//start data acquisition
retValue = myGps->stopAcquisition();//stop data acquisition (stressing tests ...)
retValue = myGps->startAcquisition();//start data acquisition, again
if ( retValue == BASIC_SUCCESS )
{
for (ii=0; ii<nIterations; ii++)
{
cout << endl;
myGps->readDataFromDevice();
//myGps->printData(cout); //prints to cout all current data in a single row. (cout can be repolaced by another ostream object reference)
cout << "Status = " << myGps->getStatus() << endl;
tsDigits=cout.precision(12);
cout << "TimeStamp = " << myGps->getTimeStamp() << endl;
cout.precision(tsDigits);
cout << "PVT error = " << myGps->getPVTerror() << endl;
cout << "TOW = " << myGps->getTow() << endl;
if ( myGps->getStatus() == ALL_OK )
{ {
retValue = myGps->startAcquisition();//start data acquisition cout << "Num Of Satellites = " << myGps->getNumSatellites() << endl;
retValue = myGps->stopAcquisition();//stop data acquisition (stressing tests ...) tsDigits=cout.precision(12);
retValue = myGps->startAcquisition();//start data acquisition, again cout << "lat = " << myGps->getLat(inDEGREES) << endl;
if ( retValue == BASIC_SUCCESS ) cout << "lon = " << myGps->getLon(inDEGREES) << endl;
{ cout.precision(tsDigits);
for (ii=0; ii<nIterations; ii++) cout << "alt = " << myGps->getAlt() << endl;
{ cout << "xWgs = " << myGps->getXWgs() << endl;
cout << endl; cout << "yWgs = " << myGps->getYWgs() << endl;
myGps->readDataFromDevice(); cout << "zWgs = " << myGps->getZWgs() << endl;
//myGps->printData(cout); //prints to cout all current data in a single row. (cout can be repolaced by another ostream object reference) cout << "xMap = " << myGps->getXMap() << endl;
cout << "Status = " << myGps->getStatus() << endl; cout << "yMap = " << myGps->getYMap() << endl;
tsDigits=cout.precision(12); cout << "zMap = " << myGps->getZMap() << endl;
cout << "TimeStamp = " << myGps->getTimeStamp() << endl; cout << "vxMap = " << myGps->getVxMap() << endl;
cout.precision(tsDigits); cout << "vyMap = " << myGps->getVyMap() << endl;
cout << "PVT error = " << myGps->getPVTerror() << endl; cout << "vzMap = " << myGps->getVzMap() << endl;
cout << "TOW = " << myGps->getTow() << endl; cout << "PDOP = " << myGps->getPDOP() << endl;
if ( myGps->getStatus() == ALL_OK )
{
cout << "Num Of Satellites = " << myGps->getNumSatellites() << endl;
tsDigits=cout.precision(12);
cout << "lat = " << myGps->getLat(inDEGREES) << endl;
cout << "lon = " << myGps->getLon(inDEGREES) << endl;
cout.precision(tsDigits);
cout << "alt = " << myGps->getAlt() << endl;
cout << "xWgs = " << myGps->getXWgs() << endl;
cout << "yWgs = " << myGps->getYWgs() << endl;
cout << "zWgs = " << myGps->getZWgs() << endl;
cout << "xMap = " << myGps->getXMap() << endl;
cout << "yMap = " << myGps->getYMap() << endl;
cout << "zMap = " << myGps->getZMap() << endl;
cout << "vxMap = " << myGps->getVxMap() << endl;
cout << "vyMap = " << myGps->getVyMap() << endl;
cout << "vzMap = " << myGps->getVzMap() << endl;
cout << "PDOP = " << myGps->getPDOP() << endl;
}
}
retValue = myGps->stopAcquisition();
}
retValue = myGps->closeDevice();
} }
}
retValue = myGps->stopAcquisition();
}
retValue = myGps->closeDevice();
}
delete myGps;*/
delete myGps; return 0;
return 0;
} }
#ifndef _GPS_TYPES_H
#define _GPS_TYPES_H
// global satellite information
typedef struct{
unsigned int tow;
unsigned short int wnc;
}TBlockTimeStamp;
// User data structures
typedef enum {elev_setting=0,elev_rising=1,elev_unknown=3} rise_set_t;
typedef enum {health_unknown=0, healthy=1, unhealthy=3} health_t;
typedef enum {track_idle=0, track_search=1, track_sync=2, tracking=3} track_status_t;
typedef enum {pvt_not_used=0, pvt_waiting=1,pvt_used=2, pvt_rejected=3} pvt_status_t;
typedef enum {main_antenna=0,aux1_antenna=1,aux2_antenna=2} antenna_t;
typedef struct {
antenna_t antenna_id;
track_status_t track_status;
pvt_status_t pvt_status;
}TChannelStateInfo;
typedef struct {
int sat_id;
unsigned int azimuth;
rise_set_t rise_set;
health_t health;
int elevation;
std::vector<TChannelStateInfo> state;
}TChannelSatInfo;
typedef struct {
TBlockTimeStamp gps_timestamp;
double local_timestamp;
std::vector<TChannelSatInfo> info;
}TChannelStatus;
typedef enum {gps_sbas_galileo_l1=0,glonass_l1=1,galileo_e6=2,gps_l2=3,glonass_l2=4,gps_sbas_galileo_l5_e5a=5,galileo_e5b=6,galileo_e5a_b=7} frontend_t;
enum {vbat_ok=0x00000001,
antenna_connected=0x00000001,
ext_ref=0x00000002,
pps_in=0x00000004,
wn_set=0x00000008,
tow_set=0x00000010,
fine_time=0x00000020,
disk_activity=0x00000040,
disk_full=0x00000080,
disk_mounted=0x00000100};
enum {nvram=0x00000001,
baseband=0x00000002,
rtc=0x00000004,
software=0x00000008,
watchdog=0x00000010,
antenna_ok=0x00000020,
congestion=0x00000040,
sis_error=0x00000080,
missed_event=0x00000100,
cpu_overload=0x00000200,
invalid_config=0x00000400};
typedef struct {
frontend_t frontend_id;
antenna_t antenna_id;
int gain;
int sample_var;
int blanking_stat;
}TAGCData;
typedef struct {
TBlockTimeStamp gps_timestamp;
double local_timestamp;
unsigned int cpu_load;
unsigned int up_time;
unsigned int state;
unsigned int error;
std::vector<TAGCData> agc;
}TReceiverStatus;
typedef enum {almanac=1, ephemeris=2, unkown_info=255} sat_info_t;
typedef struct {
TBlockTimeStamp gps_timestamp;
double local_timestamp;
unsigned int sat_id;
double azimuth;
double elevation;
rise_set_t rise_set;
sat_info_t sat_info;
}TSatInfo;
typedef enum {GPS_L1_CA=0,GPS_L1_PY=1,GPS_L2_PY=2,GPS_L2C=3,GPS_L5=4,GLO_L1_CA=8,GLO_L1_P=9,GLO_L2_P=10,GLO_L2_CA=11,GAL_L1A=16,
GAL_L1BC=17,GAL_E6B=18,GAL_E6BC=19,GAL_E5a=20,GAL_E5b=21,GAL_E5=22,GEO_L1CA=24} signal_t;
const std::string signal_type_name[] = {"GPS_L1_CA (1575.42 MHz)",
"GPS_L1_P(Y) (1575.42 MHz)",
"GPS_L2_P(Y) (1227.60 MHz)",
"GPS_L2C (1227.60 MHz)",
"GPS_L5 (1176.45 MHz)",
"",
"",
"",
"GLO_L1_CA",
"GLO_L1_P",
"GLO_L2_P",
"GLO_L1_CA",
"",
"",
"",
"",
"GAL_L1A (1575.42 MHz)",
"GAL_L1BC (1575.42 MHz)",
"GAL_E6A (1278.75 MHz)",
"GAL_E6BC (1278.75 MHz)",
"GAL_E5a (1176.45 MHz)",
"GAL_E5b (1207.14 MHz)",
"GAL_E5 (1191.795 MHz)",
"",
"GEO_L1CA (1575.42 MHz)"};
typedef struct{
signal_t signal_type;
antenna_t antenna_id;
unsigned int lock_time;
double cn0;
double pseudo_range;
double doppler;
double carrier_phase;
bool pseudorange_smoothed;
bool smoothing_int_reached;
bool half_cycle_ambiguity;
}TMeasEpochType2;
typedef struct{
unsigned int rx_channel;
signal_t signal_type;
antenna_t antenna_id;
unsigned int sat_id;
double pseudo_range;
double doppler;
double carrier_phase;
double cn0;
unsigned int lock_time;
bool pseudorange_smoothed;
bool smoothing_int_reached;
bool half_cycle_ambiguity;
std::vector<TMeasEpochType2> type2_data;
}TMeasEpochType1;
enum {multipath_mitigation=0x01,smoothing_of_code=0x02};
typedef struct{
TBlockTimeStamp gps_timestamp;
double local_timestamp;
unsigned int flags;
std::vector<TMeasEpochType1> type1_data;
}TMeasEpoch;
typedef struct{
unsigned int rx_channel;
signal_t signal_type;
antenna_t antenna_id;
int mp_correction;
int smoothing_correction;
unsigned int code_var;
unsigned int carrier_var;
unsigned int lock_time;
unsigned int cum_lost_cont;
}TMeasExtraBlock;
typedef struct{
TBlockTimeStamp gps_timestamp;
double local_timestamp;
float doppler_var_factor;
std::vector<TMeasExtraBlock> blocks;
}TMeasExtra;
typedef struct{
TBlockTimeStamp gps_timestamp;
double local_timestamp;
unsigned int sat_id;
int wn;
unsigned int ca_or_pon_l2;
unsigned int ura;
unsigned int health;
unsigned int l2_data_flag;
unsigned int iodc;
unsigned int iode2;
unsigned int iode3;
unsigned int fit_int_flag;
double t_gd;
unsigned int t_oc;
double a_f2;
double a_f1;
double a_f0;
double c_rs;
double delta_n;
double m_0;
double c_uc;
double e;
double c_us;
double sqrt_a;
unsigned int t_oe;
double c_ic;
double omega_0;
double c_is;
double i_0;
double c_rc;
double omega;
double omega_dot;
double i_dot;
unsigned int wnt_oc;
unsigned int wnt_oe;
}TGPSNav;
typedef struct{
TBlockTimeStamp gps_timestamp;
double local_timestamp;
unsigned int sat_id;
double e;
unsigned int t_oa;
double delta_i;
double omega_dot;
double sqrt_a;
double omega_0;
double omega;
double m_0;
double a_f1;
double a_f0;
unsigned int wn_a;
unsigned int as_config;
unsigned int health8;
unsigned int health6;
}TGPSAlm;
typedef struct{
TBlockTimeStamp gps_timestamp;
double local_timestamp;
unsigned int sat_id;
double alpha_0;
double alpha_1;
double alpha_2;
double alpha_3;
double beta_0;
double beta_1;
double beta_2;
double beta_3;
}TGPSIon;
typedef struct{
TBlockTimeStamp gps_timestamp;
double local_timestamp;
unsigned int sat_id;
double a_1;
double a_0;
unsigned int t_ot;
unsigned int wn_t;
int del_t_ls;
unsigned int wn_lsf;
unsigned int dn;
int del_t_lsf;
}TGPSUtc;
typedef enum {no_pvt=0,stand_alone_pvt=1,diff_pvt=2,fixed_loc=3,rtk_fixed_amb=4,rtk_float_amb=5,sbas_pvt=6} pvt_mode_t;
typedef enum {pvt_3d=0,pvt_2d=1} solution_t;
enum {no_error=0,not_enough_meas=1,not_enough_eph=2,dop_too_large=3,res_too_large=4,no_conv=5,not_enough_meas_outliers=6,export_laws=7,not_enough_diff_corr=8,no_base_coord=9};
typedef enum {gps_time=0,galileo_time=1} sys_time_t;
typedef enum {wgs_84=0,galileo=1,pz_90_02=2,user_datum1=250,user_datum2=251} datum_t;
typedef struct{
TBlockTimeStamp gps_timestamp;
double local_timestamp;
pvt_mode_t mode;
solution_t solution;
unsigned int error;
double x;
double y;
double z;
double undulation;
double vx;
double vy;
double vz;
double cog;
double rx_clk_bias;
double rx_clk_drift;
sys_time_t time_system;
datum_t datum;
unsigned int num_sat;
unsigned int wa_corr_info;
bool orbit_sat_clock_corr;
bool range_corr_info;
bool ion_info;
bool orbit_accuracy_info;
bool DO299_used;
unsigned int reference_id;
unsigned int mean_corr_age;
unsigned int signal_info;
bool integrity_mon;
bool integrity_failed_RAIM;
bool integrity_failed_HPCA;
}TPVTCartesian;
typedef struct{
TBlockTimeStamp gps_timestamp;
double local_timestamp;
pvt_mode_t mode;
solution_t solution;
unsigned int error;
double latitude;
double longitude;
double h;
double undulation;
double vn;
double ve;
double vu;
double cog;
double rx_clk_bias;
double rx_clk_drift;
sys_time_t time_system;
datum_t datum;
unsigned int num_sat;
unsigned int wa_corr_info;
bool orbit_sat_clock_corr;
bool range_corr_info;
bool ion_info;
bool orbit_accuracy_info;
bool DO299_used;
unsigned int reference_id;
unsigned int mean_corr_age;
unsigned int signal_info;
bool integrity_mon;
bool integrity_failed_RAIM;
bool integrity_failed_HPCA;
}TPVTGeodetic;
typedef struct{
TBlockTimeStamp gps_timestamp;
double local_timestamp;
pvt_mode_t mode;
solution_t solution;
unsigned int error;
double cov_00;
double cov_11;
double cov_22;
double cov_33;
double cov_01;
double cov_02;
double cov_03;
double cov_12;
double cov_13;
double cov_23;
}TPVTCov;
typedef struct
{
TBlockTimeStamp gps_timestamp;
double local_timestamp;
unsigned int num_sat;
unsigned int p_dop;
unsigned int t_dop;
unsigned int h_dop;
unsigned int v_dop;
double hpl;
double vpl;
}TPVTDOP;
// these precompiler commands force the byte aligment in memory of the data structures
//#pragma pack (push, 1)
//#pragma pack (pop)
// block ID structure
#pragma pack (push, 1)
typedef struct{
uint16_t id:13;
uint16_t rev:3;
}TGPSBlockId;
#pragma pack (pop)
// header structure
#pragma pack (push, 1)
typedef struct{
uint8_t sync[2];
uint16_t crc;
TGPSBlockId id;
uint16_t length;
}TGPSBlockHeader;
#pragma pack (pop)
// block time stamp structure
#pragma pack (push, 1)
typedef struct{
uint32_t tow;
uint16_t wnc;
}TGPSBlockTimeStamp;
#pragma pack (pop)
// Measure Epoch structure
#pragma pack (push, 1)
typedef struct{
uint8_t master_signal_type:5;
uint8_t antenna_id:3;
}TGPSMeasBlockType;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
uint8_t smoothed:1;
uint8_t smoothing_int_reached:1;
uint8_t phase_ambiguity:1;
uint8_t freq_nr:5;
}TGPSMeasBlockObsInfo;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
uint8_t code_offset_msb:3;
uint8_t doppler_offset_msb:5;
}TGPSMeasBlockType2Offsets;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
TGPSMeasBlockType type;
uint8_t lock_time;
uint8_t cn0;
TGPSMeasBlockType2Offsets offsets_msb;
int8_t carrier_msb;
TGPSMeasBlockObsInfo info;
uint16_t code_offset_lsb;
uint16_t carrier_lsb;
uint16_t doppler_offset_lsb;
}TGPSMeasBlockType2;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
uint8_t msb:4;
uint8_t reserved:4;
uint32_t lsb;
}TGPSMeasBlockType1Code;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
uint16_t lsb;
int8_t msb;
}TGPSMeasBlockType1Carrier;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
uint8_t rx_channel;
TGPSMeasBlockType type;
uint8_t svid;
TGPSMeasBlockType1Code code;
int32_t doppler;
TGPSMeasBlockType1Carrier carrier;
uint8_t cn0;
uint16_t lock_time;
TGPSMeasBlockObsInfo info;
uint8_t num_type2;
}TGPSMeasBlockType1;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
uint8_t num_type1;
uint8_t length_type1;
uint8_t length_type2;
uint8_t common_flags;
uint8_t reserved[2];
}TGPSMeasEpoch;
#pragma pack (pop)
// Measurement extra structure
#pragma pack (push, 1)
typedef struct{
uint8_t rx_channel;
TGPSMeasBlockType type;
int16_t mp_correction;
int16_t smoothing_correction;
uint16_t code_var;
uint16_t carrier_var;
uint16_t lock_time;
uint8_t cum_lost_cont;
uint8_t reserved[3];
}TGPSMeasExtraBlock;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
uint8_t num_blocks;
uint8_t length_blocks;
float doppler_var_factor;
}TGPSMeasExtra;
#pragma pack (pop)
// measurement end structure
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
}TGPSEndOfMeas;
#pragma pack (pop)
// GPS NAV structure
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
uint8_t prn;
uint8_t reserved1;
int16_t wn;
uint8_t ca_or_pon_l2;
uint8_t ura;
uint8_t health;
uint8_t l2_data_flag;
uint16_t iodc;
uint8_t iode2;
uint8_t iode3;
uint8_t fit_int_flag;
uint8_t reserved2;
float t_gd;
uint32_t t_oc;
float a_f2;
float a_f1;
float a_f0;
float c_rs;
float delta_n;
double m_0;
float c_uc;
double e;
float c_us;
double sqrt_a;
uint32_t t_oe;
float c_ic;
double omega_0;
float c_is;
double i_0;
float c_rc;
double omega;
float omega_dot;
float i_dot;
uint16_t wnt_oc;
uint16_t wnt_oe;
}TGPSGPSNav;
#pragma pack (pop)
// APG Alm structure
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
uint8_t prn;
uint8_t reserved1;
float e;
uint32_t t_oa;
float delta_i;
float omega_dot;
float sqrt_a;
float omega_0;
float omega;
float m_0;
float a_f1;
float a_f0;
uint8_t wn_a;
uint8_t as_config;
uint8_t health8;
uint8_t health6;
}TGPSGPSAlm;
#pragma pack (pop)
// GPS Ion structure
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
uint8_t prn;
uint8_t reserved1;
float alpha_0;
float alpha_1;
float alpha_2;
float alpha_3;
float beta_0;
float beta_1;
float beta_2;
float beta_3;
}TGPSGPSIon;
#pragma pack (pop)
// GPs UTC structure
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
uint8_t prn;
uint8_t reserved1;
float a_1;
double a_0;
uint32_t t_ot;
uint8_t wn_t;
int8_t del_t_ls;
uint8_t wn_lsf;
uint8_t dn;
int8_t del_t_lsf;
}TGPSGPSUtc;
#pragma pack (pop)
// Position, velocity and time Cartesian structure
#pragma pack (push, 1)
typedef struct{
uint8_t mode:4;
uint8_t reserved:3;
uint8_t solution_type:1;
}TGPSPVTMode;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
uint8_t orbit_clock_corr:1;
uint8_t range_corr:1;
uint8_t ion_info:1;
uint8_t orbit_acc_info:1;
uint8_t do229_mode:1;
uint8_t reserver:3;
}TGPSPVTInfo;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
uint8_t int_mon:1;
uint8_t int_failed_raim:1;
uint8_t int_failed_hpca:1;
uint8_t galileo_storm_flag:1;
uint8_t reserved:4;
}TGPSPVTAlert;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
TGPSPVTMode mode;
uint8_t error;
double x;
double y;
double z;
float undulation;
float vx;
float vy;
float vz;
float cog;
double rx_clk_bias;
float rx_clk_drift;
uint8_t time_system;
uint8_t datum;
uint8_t num_sat;
uint8_t wa_corr_info;
TGPSPVTInfo corr_info;
uint16_t reference_id;
uint16_t mean_corr_age;
uint32_t signal_info;
TGPSPVTAlert alert_flag;
uint8_t reserved[3];
}TGPSPVTCartesian;
#pragma pack (pop)
// Position, velocity and time Geodetic structure
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
TGPSPVTMode mode;
uint8_t error;
double latitude;
double longitude;
double h;
float undulation;
float vn;
float ve;
float vu;
float cog;
double rx_clk_bias;
float rx_clk_drift;
uint8_t time_system;
uint8_t datum;
uint8_t num_sat;
uint8_t wa_corr_info;
TGPSPVTInfo corr_info;
uint16_t reference_id;
uint16_t mean_corr_age;
uint32_t signal_info;
TGPSPVTAlert alert_flag;
uint8_t reserved[3];
}TGPSPVTGeodetic;
#pragma pack (pop)
// Position, velocity and time Covariance Cartesian structure
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
TGPSPVTMode mode;
uint8_t error;
float cov_00;
float cov_11;
float cov_22;
float cov_33;
float cov_01;
float cov_02;
float cov_03;
float cov_12;
float cov_13;
float cov_23;
}TGPSPVTCov;
#pragma pack (pop)
// Position, velocity and time DOP structure
#pragma pack (push, 1)
typedef struct
{
TGPSBlockTimeStamp timestamp;
uint8_t num_sat;
uint8_t reserved;
uint16_t p_dop;
uint16_t t_dop;
uint16_t h_dop;
uint16_t v_dop;
float hpl;
float vpl;
}TGPSPVTDOP;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
}TGPSEndOfPVT;
#pragma pack (pop)
// channel status structure
#pragma pack (push, 1)
typedef struct{
uint8_t antenna;
uint8_t reserved;
uint16_t tracking_status;
uint16_t pvt_status;
uint16_t pvy_info;
}TGPSChannelStateInfo;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
uint16_t azimuth:9;
uint16_t reserved:5;
uint16_t rise_set:2;
}TGPSAzimuthRiseSet;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
uint8_t sat_id;
uint8_t freq_nr;
uint16_t reserved1;
TGPSAzimuthRiseSet azimuth_rise_set;
uint16_t health;
int8_t elevation;
uint8_t num_state_info;
uint8_t rx_channel;
uint8_t reserved2;
}TGPSChannelSatInfo;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
uint8_t num_ch;
uint8_t length_ch_sat_info;
uint8_t length_ch_state_info;
uint8_t reserved[3];
}TGPSChannelStatus;
#pragma pack (pop)
// Receiver status structure
#pragma pack (push, 1)
typedef struct{
uint32_t vbat_ok:1;
uint32_t antenna_connected:1;
uint32_t ext_ref:1;
uint32_t pps_in:1;
uint32_t wn_set:1;
uint32_t tow_set:1;
uint32_t fine_time:1;
uint32_t disk_activity:1;
uint32_t disk_full:1;
uint32_t disk_mounted:1;
uint32_t reserved:22;
}TGPSReceiverStatusRxState;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
uint32_t nvram:1;
uint32_t baseband:1;
uint32_t rtc:1;
uint32_t software:1;
uint32_t watchdog:1;
uint32_t antenna_ok:1;
uint32_t congestion:1;
uint32_t sis_error:1;
uint32_t missed_event:1;
uint32_t cpu_overload:1;
uint32_t invalid_config:1;
uint32_t reserved:21;
}TGPSReceiverStatusRxError;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
uint8_t code:4;
uint8_t antenna_id:4;
}TGPSAGCDataFrontendId;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
TGPSAGCDataFrontendId frontend_id;
int8_t gain;
uint8_t sample_var;
uint8_t blanking_stat;
}TGPSAGCData;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
uint8_t cpu_load;
uint8_t reserved1;
uint32_t up_time;
TGPSReceiverStatusRxState rx_state;
TGPSReceiverStatusRxError rx_error;
uint8_t num_agc_states;
uint8_t length_agc_states;
uint8_t reserved2[2];
}TGPSReceiverStatus;
#pragma pack (pop)
// satellite visibility structure
#pragma pack (push, 1)
typedef struct{
uint8_t sat_id;
uint8_t freq_nr;
uint16_t azimuth;
int16_t elevation;
uint8_t rise_set;
uint8_t sat_info;
}TGPSSatInfo;
#pragma pack (pop)
#pragma pack (push, 1)
typedef struct{
TGPSBlockTimeStamp timestamp;
uint8_t num_sat;
uint8_t length_sat;
}TGPSSatVisibility;
#pragma pack (pop)
#endif
#include "stream_gps.h"
std::ostream& operator<< (std::ostream& out, TMeasEpoch &meas_epoch)
{
unsigned int i,j;
out << "Common flags: " << std::endl;
if(meas_epoch.flags&multipath_mitigation)
out << " Multipath mitigation enabled" << std::endl;
else
out << " Multipath mitigation disabled" << std::endl;
if(meas_epoch.flags&smoothing_of_code)
out << " At least one of the code measurements is smoothed" << std::endl;
else
out << " None of the code measurements are smoothed" << std::endl;
for(i=0;i<meas_epoch.type1_data.size();i++)
{
out << "Sattelite " << meas_epoch.type1_data[i].sat_id << " on channel " << meas_epoch.type1_data[i].rx_channel << std::endl;
out << " Master signal: " << signal_type_name[meas_epoch.type1_data[i].signal_type] << std::endl;
out << " Antenna: " << (int)meas_epoch.type1_data[i].antenna_id << std::endl;
out << " Pseudo range: " << meas_epoch.type1_data[i].pseudo_range << " m" << std::endl;
out << " Doppler: " << meas_epoch.type1_data[i].doppler << " Hz" << std::endl;
out << " Carrier phase: " << meas_epoch.type1_data[i].carrier_phase << " cycles" << std::endl;
out << " Carrier/noise ratio: " << meas_epoch.type1_data[i].cn0 << " dB-Hz" << std::endl;
out << " Lock time: " << meas_epoch.type1_data[i].lock_time << " s" << std::endl;
if(meas_epoch.type1_data[i].pseudorange_smoothed)
out << " Pseudo ranfe measurement is smoothed" << std::endl;
else
out << " Pseudo ranfe measurement is not smoothed" << std::endl;
if(meas_epoch.type1_data[i].smoothing_int_reached)
out << " The smoothing filter has reached the requested smoothing interval" << std::endl;
else
out << " The smoothing filter has not reached the requested smoothing interval" << std::endl;
if(meas_epoch.type1_data[i].half_cycle_ambiguity)
out << " Carrier phase has a half-cycle ambiguity" << std::endl;
else
out << " Carrier phase does not have a half-cycle ambiguity" << std::endl;
if(meas_epoch.type1_data[i].type2_data.size()>0)
{
for(j=0;j<meas_epoch.type1_data[i].type2_data.size();j++)
{
out << " Inter-channel differences" << std::endl;
out << " Master signal: " << signal_type_name[meas_epoch.type1_data[i].type2_data[j].signal_type] << std::endl;
out << " Antenna: " << (int)meas_epoch.type1_data[i].type2_data[j].antenna_id << std::endl;
out << " Pseudo range: " << meas_epoch.type1_data[i].type2_data[j].pseudo_range << " m" << std::endl;
out << " Doppler: " << meas_epoch.type1_data[i].type2_data[j].doppler << " Hz" << std::endl;
out << " Carrier phase: " << meas_epoch.type1_data[i].type2_data[j].carrier_phase << " cycles" << std::endl;
out << " Carrier/noise ratio: " << meas_epoch.type1_data[i].type2_data[j].cn0 << " dB-Hz" << std::endl;
out << " Lock time: " << meas_epoch.type1_data[i].type2_data[j].lock_time << " s" << std::endl;
if(meas_epoch.type1_data[i].type2_data[j].pseudorange_smoothed)
out << " Pseudo ranfe measurement is smoothed" << std::endl;
else
out << " Pseudo ranfe measurement is not smoothed" << std::endl;
if(meas_epoch.type1_data[i].type2_data[j].smoothing_int_reached)
out << " The smoothing filter has reached the requested smoothing interval" << std::endl;
else
out << " The smoothing filter has not reached the requested smoothing interval" << std::endl;
if(meas_epoch.type1_data[i].type2_data[j].half_cycle_ambiguity)
out << " Carrier phase has a half-cycle ambiguity" << std::endl;
else
out << " Carrier phase does not have a half-cycle ambiguity" << std::endl;
}
}
}
return out;
}
std::ostream& operator<< (std::ostream& out, TMeasExtra &meas_extra)
{
unsigned int i;
out << "Doppler variance factor: " << meas_extra.doppler_var_factor << " Hz2/cycles2" << std::endl;
for(i=0;i<meas_extra.blocks.size();i++)
{
out << "Block:" << std::endl;
out << " Receiver channel: " << meas_extra.blocks[i].rx_channel << std::endl;
out << " Master signal: " << signal_type_name[meas_extra.blocks[i].signal_type] << std::endl;
out << " Antenna: " << meas_extra.blocks[i].antenna_id << std::endl;
out << " Multipath correction: " << meas_extra.blocks[i].mp_correction << " m" << std::endl;
out << " Smoothing correction: " << meas_extra.blocks[i].smoothing_correction << " m" << std::endl;
out << " Code tracking noise variance: " << meas_extra.blocks[i].code_var << " m2" << std::endl;
out << " Carrier tracking noise variance: " << meas_extra.blocks[i].carrier_var << " mcycle2" << std::endl;
out << " Lock time: " << meas_extra.blocks[i].lock_time << " s" << std::endl;
}
return out;
}
std::ostream& operator<< (std::ostream& out, TGPSNav &gps_nav)
{
out << "GPSNav block for satellite " << gps_nav.sat_id << std::endl;
out << " Code on L2 channel: " << gps_nav.ca_or_pon_l2 << std::endl;
out << " User range accuracy index: " << gps_nav.ura << std::endl;
out << " Health: " << gps_nav.health << std::endl;
out << " Data flag for L2 p-code: " << gps_nav.l2_data_flag << std::endl;
out << " Issue of data, clock: " << gps_nav.iodc << std::endl;
out << " Issue of data, ephemeris (subframe 2): " << gps_nav.iode2 << std::endl;
out << " Issue of data, ephemeris (subframe 3): " << gps_nav.iode3 << std::endl;
out << " Curve fit interval: " << gps_nav.fit_int_flag << std::endl;
out << " Estimated group delay differential (Tgd): " << gps_nav.t_gd << " s" << std::endl;
out << " Clock data reference time (Toc): " << gps_nav.t_oc << " s" << std::endl;
out << " SV clock aging" << gps_nav.a_f2 << " s/s2" << std::endl;
out << " SV clock drift: " << gps_nav.a_f1 << " s/s" << std::endl;
out << " SV clock bias: " << gps_nav.a_f0 << " s" << std::endl;
out << " Amplitude of the sine harmonic correction term to the orbit radius (Crs): " << gps_nav.c_rs << " m" << std::endl;
out << " Mean motion difference: " << gps_nav.delta_n << " semi-circle/s" << std::endl;
out << " Mean anomaly at reference time: " << gps_nav.m_0 << " semi-circle" << std::endl;
out << " Amplitude of the cosine harmonic correction term to the argument of latitude (Cuc): " << gps_nav.c_uc << " rad" << std::endl;
out << " Eccentricity: " << gps_nav.e << std::endl;
out << " Amplitude of the cosine harmonic correction term to the argument of latitude (Cus): " << gps_nav.c_us << " rad" << std::endl;
out << " Square root of the semi-major axis: " << gps_nav.sqrt_a << " m1/2" << std::endl;
out << " Reference time ephemeris (Toe): " << gps_nav.t_oe << " s" << std::endl;
out << " Amplitude of the cosine harmonic correction term to the angle of inclination (Cic): " << gps_nav.c_ic << " rad" << std::endl;
out << " Longitude of ascending node of orbit plane at weekly epoch: " << gps_nav.omega_0 << " semi-circle" << std::endl;
out << " Amplitude of the sine harmonic correction term to the angle of inclination (Cis): " << gps_nav.c_is << " rad" << std::endl;
out << " Inclination angle at reference time: " << gps_nav.i_0 << " semi-circle" << std::endl;
out << " Amplitude of the cosine harmonic correction term to the orbit radius (Crc): " << gps_nav.c_rc << " m" << std::endl;
out << " Argument of peregee: " << gps_nav.omega << " semi-circle" << std::endl;
out << " Rate of right ascension: " << gps_nav.omega_dot << " semi-circle/s" << std::endl;
out << " Rate of inclination angle: " << gps_nav.i_dot << " semi-circle/s" << std::endl;
return out;
}
std::ostream& operator<< (std::ostream& out, TGPSAlm &gps_alm)
{
out << "GPSAlm block for satellite: " << gps_alm.sat_id << std::endl;
out << "Eccentricity: " << gps_alm.e << std::endl;
out << "Almanac reference time of week (Toa): " << gps_alm.t_oa << " s" << std::endl;
out << "Inclinationa ngle at reference time: " << gps_alm.delta_i << " semi-circle" << std::endl;
out << "Rate of right ascension: " << gps_alm.omega_dot << " semi-circle/s" << std::endl;
out << "Square root of the semi-major axis: " << gps_alm.sqrt_a << " m1/2" << std::endl;
out << "Longitude of ascending node of orbit plane at weekly epoch: " << gps_alm.omega_0 << " semi-circle" << std::endl;
out << "Argument of peregee: " << gps_alm.omega << " semi-circle" << std::endl;
out << "Mean anomaly at reference time: " << gps_alm.m_0 << " semi-circle" << std::endl;
out << "SV clock drift: " << gps_alm.a_f1 << " s/s" << std::endl;
out << "SV clock bias: " << gps_alm.a_f0 << " s" << std::endl;
return out;
}
std::ostream& operator<< (std::ostream& out, TGPSIon &gps_ion)
{
out << "GPSIon block for satellite: " << gps_ion.sat_id << std::endl;
out << "Vertical delay coefficient 0: " << gps_ion.alpha_0 << " s" << std::endl;
out << "Vertical delay coefficient 1: " << gps_ion.alpha_1 << " s/semi-circle" << std::endl;
out << "Vertical delay coefficient 2: " << gps_ion.alpha_2 << " s/semi-circle2" << std::endl;
out << "Vertical delay coefficient 3: " << gps_ion.alpha_3 << " s/semi-circle3" << std::endl;
out << "Model period coefficient 0: " << gps_ion.beta_0 << " s" << std::endl;
out << "Model period coefficient 1: " << gps_ion.beta_1 << " s/semi-circle" << std::endl;
out << "Model period coefficient 2: " << gps_ion.beta_2 << " s/semi-circle2" << std::endl;
out << "Model period coefficient 3: " << gps_ion.beta_3 << " s/semi-circle3" << std::endl;
return out;
}
std::ostream& operator<< (std::ostream& out, TGPSUtc &gps_utc)
{
out << "GPSUtc block for satellite: " << gps_utc.sat_id << std::endl;
out << "First order term of polynomial: " << gps_utc.a_1 << " s/s" << std::endl;
out << "constant term of polynomial: " << gps_utc.a_0 << " s" << std::endl;
out << "Reference time for UTC data (Tot): " << gps_utc.t_ot << " s" << std::endl;
out << "Delta time due to leap seconds when effectivity time is not in the past: " << gps_utc.del_t_ls << " s" << std::endl;
out << "Effectivity time of leap seconds (week): " << gps_utc.wn_lsf << " weelk" << std::endl;
out << "Effectivity time of leap seconds (day): " << gps_utc.dn << " day" << std::endl;
out << "Delta time due to leap seconds when effectivity time is not in the past: " << gps_utc.del_t_lsf << " s" << std::endl;
return out;
}
// ChannelStatus
/* std::cout << "gps timestamp: " << this->channel_status.gps_timestamp << std::endl;
std::cout << "num channles: " << this->channel_status.info.size() << std::endl;
for(i=0;i<this->channel_status.info.size();i++)
{
std::cout << " Sat ID: " << (int)this->channel_status.info[i].sat_id << std::endl;
std::cout << " Azimuth: " << this->channel_status.info[i].azimuth << std::endl;
std::cout << " rise/set: " << this->channel_status.info[i].rise_set << std::endl;
std::cout << " Health: " << this->channel_status.info[i].health << std::endl;
std::cout << " Elevation: " << this->channel_status.info[i].elevation << std::endl;
for(j=0;j<this->channel_status.info[i].state.size();j++)
{
std::cout << " Antenna ID: " << (int)this->channel_status.info[i].state[j].antenna_id << std::endl;
std::cout << " Tracking status: " << this->channel_status.info[i].state[j].track_status << std::endl;
std::cout << " PVT status: " << this->channel_status.info[i].state[j].pvt_status << std::endl;
}
}*/
//ReceiverStatus
/* std::cout << "gps timestamp: " << this->receiver_status.gps_timestamp << std::endl;
std::cout << "CPU load: " << this->receiver_status.cpu_load << std::endl;
std::cout << "up time: " << this->receiver_status.up_time << std::endl;
for(i=0;i<this->receiver_status.agc.size();i++)
{
std::cout << " Frontend: " << this->receiver_status.agc[i].frontend_id << std::endl;;
std::cout << " Antenna: " << this->receiver_status.agc[i].antenna_id << std::endl;;
std::cout << " Gain: " << this->receiver_status.agc[i].gain << std::endl;;
std::cout << " Sample var: " << this->receiver_status.agc[i].sample_var << std::endl;;
std::cout << " Blanking stat: " << this->receiver_status.agc[i].blanking_stat << std::endl;;
}*/
// SatVisibility
/* std::cout << "Num sat: " << this->sat_info.size() << std::endl;
for(i=0;i<this->sat_info.size();i++)
{
std::cout << "Sat ID: " << this->sat_info[i].sat_id << std::endl;
std::cout << "Azmimuth: " << this->sat_info[i].azimuth << std::endl;
std::cout << "Elevation: " << this->sat_info[i].elevation << std::endl;
std::cout << "rise/set: " << this->sat_info[i].rise_set << std::endl;
std::cout << "Sat info: " << this->sat_info[i].sat_info << std::endl;
}*/
#ifndef _STREAM_GPS_H
#define _STREAM_GPS_H
#include <iostream>
#include <vector>
#include <stdint.h>
#include "gps_types.h"
std::ostream& operator<< (std::ostream& out, TMeasEpoch &meas_epoch);
std::ostream& operator<< (std::ostream& out, TMeasExtra &meas_extra);
std::ostream& operator<< (std::ostream& out, TGPSNav &gps_nav);
std::ostream& operator<< (std::ostream& out, TGPSAlm &gps_alm);
std::ostream& operator<< (std::ostream& out, TGPSIon &gps_ion);
std::ostream& operator<< (std::ostream& out, TGPSUtc &gps_utc);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment