Commit f57f0bb0 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Extended the features of the GPA driver.

parent c06fc4e2
# driver source files
SET(sources asterx1_gps.cpp)
SET(sources asterx1_gps.cpp stream_gps.cpp)
# application header files
SET(headers asterx1_gps.h)
SET(headers asterx1_gps.h stream_gps.h)
# locate the the necessary dependencies
FIND_PACKAGE(iriutils)
......
This diff is collapsed.
This diff is collapsed.
......@@ -16,119 +16,179 @@ USB any port
*/
#include <stdlib.h>
#include <asterx1_gps.h>
using namespace std;
#include "asterx1_gps.h"
#include "stream_gps.h"
int main(int argc, char **argv)
{
int opt;
int ii;
int retValue;
int nIterations = 10;
int rate = MSEC500; //ONCHANGE, MSEC20, ... , MSEC100, ... SEC1, SEC5
string serial_device="/dev/ttyACM0";
streamsize tsDigits;
CasteRx1 *myGps;
CasteRx1 myGps("gps","/dev/ttyACM0");
CEventServer *event_server=CEventServer::instance();
std::list<std::string> events;
unsigned int i=0,index;
TMeasEpoch meas_epoch;
TMeasExtra meas_extra;
TGPSNav gps_nav;
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;
// Argument management
while ((opt = getopt(argc, argv, "u:n:r:h?"))!= -1)
//cout << "acqPeriodValues[ONCHANGE]: " << acqPeriodValues[ONCHANGE] << endl;
// Argument management
/* 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)
{
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 << " " << ii << ": " << acqPeriodValues[ii] << endl;
}
myGps = new CasteRx1(serial_device,rate);
myGps->setMapOrigin(41.388595, 2.113133, 120, 44.2); //sets map origin for coordinate transformation
//myGps->printTM(); //prints to stdout the transformation matrix
retValue = myGps->openDevice();//open device comm's
retValue = myGps->closeDevice();//close device comm's (stressing tests ...)
retValue = myGps->openDevice();//open device comm's, again
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
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 )
cout << endl;
return 1;
}
}
myGps = new CasteRx1(serial_device,rate);
myGps->setMapOrigin(41.388595, 2.113133, 120, 44.2); //sets map origin for coordinate transformation
//myGps->printTM(); //prints to stdout the transformation matrix
retValue = myGps->openDevice();//open device comm's
retValue = myGps->closeDevice();//close device comm's (stressing tests ...)
retValue = myGps->openDevice();//open device comm's, again
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
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
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 )
{
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();
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();
}
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;