Commit 73ac8a3e authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Added conditional compilation depending on the presence of the GPS tool kit.

parent 55af5a8b
......@@ -17,23 +17,19 @@ USB any port
#include <stdlib.h>
#include "asterx1_gps.h"
#include "asterx1_process.h"
#include "stream_gps.h"
#ifdef HAVE_GPSTK
#include "asterx1_process.h"
#endif
int main(int argc, char **argv)
{
CasteRx1 gps("gps","/dev/ttyACM0");
CAsteRx1Process gps_process;
CEventServer *event_server=CEventServer::instance();
std::list<std::string> events;
unsigned int index;
TMeasEpoch meas_epoch;
TMeasExtra meas_extra;
TGPSNav gps_nav;
TGPSAlm gps_alm;
TGPSIon gps_ion;
TGPSUtc gps_utc;
TGPSFrame gps_frame;
TPVTCartesian pvt_cartesian;
TPVTGeodetic pvt_geodetic;
TPVTCov pvt_pos_cov_cartesian;
......@@ -41,79 +37,120 @@ int main(int argc, char **argv)
TPVTCov pvt_pos_cov_geodetic;
TPVTCov pvt_vel_cov_geodetic;
TPVTDOP pvt_dop;
#ifdef HAVE_GPSTK
CAsteRx1Process gps_process;
TGPSFrame gps_frame;
TGPSNav gps_nav;
#else
TGPSNav gps_nav;
TGPSAlm gps_alm;
TGPSIon gps_ion;
TGPSUtc gps_utc;
#endif
std::cout << "\n\n TEST AsteRx1 GPS RECEIVER \n\n" << std::endl;
try{
gps.openDevice();
events.push_back(gps.get_new_meas_data_event_id());
events.push_back(gps.get_new_gps_nav_data_event_id());
events.push_back(gps.get_new_gps_alm_data_event_id());
events.push_back(gps.get_new_gps_ion_data_event_id());
events.push_back(gps.get_new_gps_utc_data_event_id());
events.push_back(gps.get_new_gps_raw_data_event_id());
events.push_back(gps.get_new_pvt_data_event_id());
#ifdef HAVE_GPSTK
events.push_back(gps.get_new_meas_data_event_id());
events.push_back(gps.get_new_gps_raw_data_event_id());
events.push_back(gps.get_new_pvt_data_event_id());
#else
events.push_back(gps.get_new_meas_data_event_id());
events.push_back(gps.get_new_gps_nav_data_event_id());
events.push_back(gps.get_new_gps_alm_data_event_id());
events.push_back(gps.get_new_gps_ion_data_event_id());
events.push_back(gps.get_new_gps_utc_data_event_id());
events.push_back(gps.get_new_pvt_data_event_id());
#endif
gps.startAcquisition();
for(;;)
{
index=event_server->wait_first(events);
if(index==0)
{
gps.get_meas_data(meas_epoch,meas_extra);
// std::cout << meas_epoch << std::endl;
// std::cout << meas_extra << std::endl;
}
else if(index==1)
{
gps.get_gps_nav_data(gps_nav);
std::cout << gps_nav << std::endl;
}
else if(index==2)
{
gps.get_gps_alm_data(gps_alm);
std::cout << gps_alm << std::endl;
}
else if(index==3)
{
gps.get_gps_ion_data(gps_ion);
std::cout << gps_ion << std::endl;
}
else if(index==4)
{
gps.get_gps_utc_data(gps_utc);
std::cout << gps_utc << std::endl;
}
else if(index==5)
{
gps.get_gps_raw_data(gps_frame);
gps_process.add_subframe(gps_frame);
std::cout << gps_frame << std::endl;
/* if(gps_process.is_new_gps_nav_data_available())
#ifdef HAVE_GPSTK
if(index==0)
{
gps_process.get_gps_nav_data(gps_nav);
if(gps_frame.sat_id==17)
gps.get_meas_data(meas_epoch,meas_extra);
std::cout << meas_epoch << std::endl;
std::cout << meas_extra << std::endl;
}
else if(index==1)
{
gps.get_gps_raw_data(gps_frame);
gps_process.add_subframe(gps_frame);
if(gps_process.is_new_gps_nav_data_available())
{
gps_process.get_gps_nav_data(gps_nav);
std::cout << gps_nav << std::endl;
}*/
}
else if(index==6)
{
gps.get_pvt_data(pvt_cartesian,pvt_geodetic);
gps.get_pvt_cov_data(pvt_pos_cov_cartesian,pvt_pos_cov_geodetic,pvt_vel_cov_cartesian,pvt_vel_cov_geodetic);
/* std::cout << "Cartesian:" << std::endl;
std::cout << pvt_cartesian << std::endl;
std::cout << "Position covariance:" << std::endl;
std::cout << pvt_pos_cov_cartesian << std::endl;
std::cout << "Velocity covariance:" << std::endl;
std::cout << pvt_vel_cov_cartesian << std::endl;
std::cout << "Geodetic:" << std::endl;
std::cout << pvt_geodetic << std::endl;
std::cout << "Position covariance:" << std::endl;
std::cout << pvt_pos_cov_geodetic << std::endl;
std::cout << "Velocity covariance:" << std::endl;
std::cout << pvt_vel_cov_geodetic << std::endl;*/
gps.get_pvt_dop_data(pvt_dop);
// std::cout << pvt_dop << std::endl;
}
}
}
else if(index==2)
{
gps.get_pvt_data(pvt_cartesian,pvt_geodetic);
gps.get_pvt_cov_data(pvt_pos_cov_cartesian,pvt_pos_cov_geodetic,pvt_vel_cov_cartesian,pvt_vel_cov_geodetic);
std::cout << "Cartesian:" << std::endl;
std::cout << pvt_cartesian << std::endl;
std::cout << "Position covariance:" << std::endl;
std::cout << pvt_pos_cov_cartesian << std::endl;
std::cout << "Velocity covariance:" << std::endl;
std::cout << pvt_vel_cov_cartesian << std::endl;
std::cout << "Geodetic:" << std::endl;
std::cout << pvt_geodetic << std::endl;
std::cout << "Position covariance:" << std::endl;
std::cout << pvt_pos_cov_geodetic << std::endl;
std::cout << "Velocity covariance:" << std::endl;
std::cout << pvt_vel_cov_geodetic << std::endl;
gps.get_pvt_dop_data(pvt_dop);
std::cout << pvt_dop << std::endl;
}
#else
if(index==0)
{
gps.get_meas_data(meas_epoch,meas_extra);
std::cout << meas_epoch << std::endl;
std::cout << meas_extra << std::endl;
}
else if(index==1)
{
gps.get_gps_nav_data(gps_nav);
std::cout << gps_nav << std::endl;
}
else if(index==2)
{
gps.get_gps_alm_data(gps_alm);
std::cout << gps_alm << std::endl;
}
else if(index==3)
{
gps.get_gps_ion_data(gps_ion);
std::cout << gps_ion << std::endl;
}
else if(index==4)
{
gps.get_gps_utc_data(gps_utc);
std::cout << gps_utc << std::endl;
}
else if(index==5)
{
gps.get_pvt_data(pvt_cartesian,pvt_geodetic);
gps.get_pvt_cov_data(pvt_pos_cov_cartesian,pvt_pos_cov_geodetic,pvt_vel_cov_cartesian,pvt_vel_cov_geodetic);
std::cout << "Cartesian:" << std::endl;
std::cout << pvt_cartesian << std::endl;
std::cout << "Position covariance:" << std::endl;
std::cout << pvt_pos_cov_cartesian << std::endl;
std::cout << "Velocity covariance:" << std::endl;
std::cout << pvt_vel_cov_cartesian << std::endl;
std::cout << "Geodetic:" << std::endl;
std::cout << pvt_geodetic << std::endl;
std::cout << "Position covariance:" << std::endl;
std::cout << pvt_pos_cov_geodetic << std::endl;
std::cout << "Velocity covariance:" << std::endl;
std::cout << pvt_vel_cov_geodetic << std::endl;
gps.get_pvt_dop_data(pvt_dop);
std::cout << pvt_dop << std::endl;
}
#endif
}
gps.stopAcquisition();
}catch(CException &e){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment