예제 #1
0
int  GpsSync::PositionChange_Handler(CPhidgetGPSHandle gps, double latitude, double longitude, double altitude)
{
    // Set time for reference
    if(!this->is_signal_acquired)
    {
        this->time_ref = std::chrono::high_resolution_clock::now();
        this->is_signal_acquired=true;
    }

    // Set data -> Update values
    this->latitude=latitude;
    this->longitude=longitude;
    this->altitude=altitude;

    // Heading and Velocity
    // TODO check! The first time it gives a bad value
    if(is_position_acquired)
    {
        CPhidgetGPS_getHeading(gps, &heading);
        CPhidgetGPS_getVelocity(gps, &velocity);
    }

    // Check
    if(!std::isnan(this->latitude) && !std::isnan(this->longitude) && !std::isnan(this->altitude))
    {
        is_position_acquired=true;
    }

    return 1;
}
예제 #2
0
int CCONV gps_on_position_change(CPhidgetGPSHandle gps, void *userptr, double latitude, double longitude, double altitude) {
  PhidgetInfo *info = userptr;
  GpsInfo *gps_info = info->type_info;

  // Calculate the sample time:
  sample_tick(gps_info->sample_rate, NULL);

  // Get the GPS time:
	GPSDate date;
	GPSTime time;

	if ( (CPhidgetGPS_getDate(gps, &date) == EPHIDGET_OK) && 
    (CPhidgetGPS_getTime(gps, &time) == EPHIDGET_OK) ) {
    gps_info->now_at_utc.tm_sec = time.tm_sec;
    gps_info->now_at_utc.tm_min = time.tm_min;
    gps_info->now_at_utc.tm_hour = time.tm_hour;
    gps_info->now_at_utc.tm_mday = date.tm_mday;
    gps_info->now_at_utc.tm_mon = date.tm_mon;
    gps_info->now_at_utc.tm_year = date.tm_year;
    gps_info->now_at_utc_ms = (time.tm_ms >= 1000) ? 0 : time.tm_ms;
    gps_info->is_now_at_utc_known = true;
  } else
    gps_info->is_now_at_utc_known = false;
  
  // Get Position values:
  if (gps_info->latitude != PUNK_DBL) {
    gps_info->is_latitude_known = true;
    gps_info->latitude = latitude;
  } else
    gps_info->is_latitude_known = false;

  if (gps_info->longitude != PUNK_DBL) {
    gps_info->is_longitude_known = true;
    gps_info->longitude = longitude;
  } else
    gps_info->is_longitude_known = false;

  if (gps_info->altitude != PUNK_DBL) {
    gps_info->is_altitude_known = true;
    gps_info->altitude = altitude;
  } else
    gps_info->is_altitude_known = false;

  double heading, velocity;
  if (CPhidgetGPS_getHeading(gps, &heading) == EPHIDGET_OK) {
    gps_info->heading = heading;
    gps_info->is_heading_known = true;
  } else
    gps_info->is_heading_known = false;

  if (CPhidgetGPS_getVelocity(gps, &velocity) == EPHIDGET_OK) {
    gps_info->velocity = velocity;
    gps_info->is_velocity_known = true;
  } else
    gps_info->is_velocity_known = false;

	return 0;
}
예제 #3
0
int  GpsAsync::PositionChange_Handler(CPhidgetGPSHandle gps, double latitude, double longitude, double altitude)
{

    double heading, velocity;

    GPSDate date;
    GPSTime time;

    NMEAData NMEAdata;


    // Heading and Velocity
    // TODO check
    CPhidgetGPS_getHeading(gps, &heading);
    CPhidgetGPS_getVelocity(gps, &velocity);


    // Date and time
    // TODO check
    CPhidgetGPS_getDate(gps, &date);
    CPhidgetGPS_getTime(gps, &time);

    // NMEA data
    // TODO check
    CPhidgetGPS_getNMEAData(gps, &NMEAdata);


    // Function to use the data
    this->positionHandler(latitude, longitude, altitude);
    this->headingHandler(heading);
    this->velocityHandler(velocity);

    this->dateAndTimeHandler(date, time);
    this->nmeaDataHandler(NMEAdata);


    return 1;
}