Пример #1
0
void checkAndConnect(Hok_t *hok) {
	if (!hok->isWorking) {
		printf("%sHokuyo not connected, trying to connect to %s\n", PREFIX, hok->path);
		int error = urg_connect(hok->urg, hok->path, 115200);
		if (error < 0) {
			printf("%sCan't connect to hokuyo : %s\n", PREFIX, urg_error(hok->urg));
			hok->isWorking = 0;
		} else {
			hok->imin = urg_rad2index(hok->urg, hok->cone_min);
			hok->imax = urg_rad2index(hok->urg, hok->cone_max);

			urg_setCaptureTimes(hok->urg, UrgInfinityTimes);
			error = urg_requestData(hok->urg, URG_MD, hok->imin, hok->imax);
			if (error < 0) {
				printf("%sCan't connect to hokuyo\n", PREFIX);
				hok->isWorking = 0;
			} else {
				printf("%sHokuyo connected\n", PREFIX);
				hok->isWorking = 1;
				printf("%sRequesting data on indexes %d to %d from %s OK\n", PREFIX, hok->imin, hok->imax, hok->path);

				hok->nb_data = urg_dataMax(hok->urg);
				double *angles = malloc(hok->nb_data * sizeof(double));
				int i;
				for (i=0; i<hok->nb_data; i++) {
					angles[i] = modTwoPi(urg_index2rad(hok->urg, i) + hok->orientation);
				}
				hok->fm = initFastmath(hok->nb_data, angles);
				free(angles);
				
				printf("%sCalculted sin/cos data for %s\n", PREFIX, hok->path);
			}
		}
	}
}
Пример #2
0
  static void mdlStart(SimStruct *S)
  {

          ret = urg_connect(&urg, device, 115200);
          if (ret < 0) {
             urg_exit(&urg, "urg_connect()");

            }
          else
             urg_setCaptureTimes(&urg, UrgInfinityTimes);

}
Пример #3
0
int  CSCIPRadarComm::StartRadar(void)
{	
	int ret;	
	ret = urg_connect(&urg, m_comDevice, m_bitRate);	
	if (ret < 0) 
	{		
		return -1;
	}
		
	return 1;
	
}
Пример #4
0
/*-----------------------------------------------------------*/
int init_urg_laser(urg_t **urg,int modality)
{
  int ret;
  
  /*Switching capturing mode*/
  urg_capturing_mode=modality;
  
  /*Memory structure allocation*/
  *urg=malloc(sizeof(urg_t));
  
  /*Printing and signalling allocation error*/
  if (!(*urg)) {
    fprintf(stderr, "Error in urg memory allocation\n");
    return -1;
  }
  /*Urg laser connection (structure, file descriptor, baud rate)*/
  ret = urg_connect(*urg, DEVICE, 115200);
   if (ret < 0) {
    return ret;
  }
  /*Switching on the laser scanner*/
  urg_laserOn(*urg); 
 
  pthread_mutex_init(&mutex_laser_read, NULL);
  /*Getting parameters*/
  if(!parameter)
	parameter=malloc(sizeof(urg_parameter_t));
  urg_parameters(*urg, parameter);
  frontal_index=get_frontal_index(*urg);
  /*Switch to select the laser range finder acquiring mode*/
  switch (urg_capturing_mode)
  {
    case CONTINUOUS:
      /*keep capturing*/
      urg_setCaptureTimes(*urg, UrgInfinityTimes);
      /*request all the data*/
      urg_requestData(*urg, URG_MD, URG_FIRST, URG_LAST);
      break;
    case HYBRID:
      /*keep capturing capture_times*/
      urg_setCaptureTimes(*urg, capture_times);
      /*request data*/
      urg_requestData(*urg, URG_MD, URG_FIRST, URG_LAST);
      break;
    case ON_DEMAND:
      urg_requestData(*urg, URG_GD, URG_FIRST, URG_LAST);
      break;
    default:
      break;
  } 
  return ret;
}
Пример #5
0
//! main
int main(int argc, char *argv[])
{
#ifdef WINDOWS_OS
  const char device[] = "COM3"; /* For Windows */
#else
  const char device[] = "/dev/ttyACM0"; /* For Linux */
#endif

  urg_t urg;
  urg_parameter_t parameters;
  int ret;

  /* Connection */
  urg_initialize(&urg);
  ret = urg_connect(&urg, device, 115200);
  if (ret < 0) {
    urg_exit(&urg, "urg_connect()");
  }

  /* Get sensor parameter */
  ret = urg_parameters(&urg, &parameters);
  printf("urg_getParameters: %s\n", urg_error(&urg));
  if (ret < 0) {
    urg_disconnect(&urg);
    exit(1);
  }

  /* Display */
  printf("distance_min: %ld\n", parameters.distance_min_);
  printf("distance_max: %ld\n", parameters.distance_max_);
  printf("area_total: %d\n", parameters.area_total_);
  printf("area_min: %d\n", parameters.area_min_);
  printf("area_max: %d\n", parameters.area_max_);
  printf("area_front: %d\n", parameters.area_front_);
  printf("scan_rpm: %d\n", parameters.scan_rpm_);
  printf("\n");

  /* Display information from URG structure (same resource as above) */
  printf("urg_getDistanceMax(): %ld\n", urg_maxDistance(&urg));
  printf("urg_getDistanceMin(): %ld\n", urg_minDistance(&urg));
  printf("urg_getScanMsec(): %d\n", urg_scanMsec(&urg));
  printf("urg_getDataMax(): %d\n", urg_dataMax(&urg));

#ifdef MSC
  getchar();
#endif

  return 0;
}
Пример #6
0
 /* Function: mdlStart =======================================================
  * Abstract:
  *    This function is called once at start of model execution. If you
  *    have states that should be initialized once, this is the place
  *    to do it.
  */
 static void mdlStart(SimStruct *S)
 {
   const real_T   *Upos  = (const real_T*) ssGetInputPortSignal(S,1);
   
   ret = urg_connect(&urg, device, 115200);
   if (ret < 0) {
       urg_exit(&urg, "urg_connect()");
   }
   else
       urg_setCaptureTimes(&urg, UrgInfinityTimes);
   
   CPhidgetStepper_create(&stepper);
   stepperConnect(600000, 1214,stepper);
   
   stepperMove(*Upos, stepper);
 }
Пример #7
0
 /* Function: mdlStart =======================================================
  * Abstract:
  *    This function is called once at start of model execution. If you
  *    have states that should be initialized once, this is the place
  *    to do it.
  */
 static void mdlStart(SimStruct *S)
 {
   //Lidar setup
   ret = urg_connect(&urg, device, 115200);
   if (ret < 0) {
       urg_exit(&urg, "urg_connect()");
   }
   else
       urg_setCaptureTimes(&urg, UrgInfinityTimes);
   
   //Stepper Setup
   CPhidgetStepper_create(&stepper);
   stepperConnect(600000, 1214,stepper);
   
   //Zero prameters
   counter = 0;
   
 }
Пример #8
0
 /* Function: mdlStart =======================================================
  * Abstract:
  *    This function is called once at start of model execution. If you
  *    have states that should be initialized once, this is the place
  *    to do it.
  */
 static void mdlStart(SimStruct *S)
 {
   const real_T   *Upos  = (const real_T*) ssGetInputPortSignal(S,1);
   const int32_T   *potVal  = (const int32_T*) ssGetInputPortSignal(S,0);
    
   
   ret = urg_connect(&urg, device, 115200);
   if (ret < 0) {
       urg_exit(&urg, "urg_connect()");
   }
   else
       urg_setCaptureTimes(&urg, UrgInfinityTimes);
   
   CPhidgetStepper_create(&stepper);
   stepperConnect(600000, 1214,stepper);
   
   //Zero prameters
   int zeroPos = 418;
   int dpot;
   int dstep;
   
   //Zero stepper on start
   if (zeroPos > *potVal) {
       zeroPos = 418;
   }
   if (zeroPos < *potVal) {
       zeroPos = 419;
   }
   
   
   printf("potVal:%d\n",*potVal);
   dpot = zeroPos - *potVal;
   printf("Dpot:%d\n",dpot);
   dstep = -1036/45*dpot;
   printf("Dstep:%d\n",dstep);
   //stepperMove(dstep, stepper);
   
   CPhidgetStepper_setCurrentPosition(stepper, 0, 0);
   stepperMove(*Upos, stepper);
   
   
   
 }
Пример #9
0
LaserRangeFinder::LaserRangeFinder(const std::string& device, int baud_rate)
   : m_bufsiz(0), m_retsiz(0), m_buffer(0),
     m_angle_range(0, 0), m_distance_range(-1, -1), m_distances(0)
{
   if (urg_connect(& m_handle, device.c_str(), baud_rate) < 0)
      throw lrf_error(LRF_CONNECTION_FAILURE) ;

   m_bufsiz = urg_getDataMax(& m_handle) ;
   m_buffer = new long[m_bufsiz] ;
   std::fill_n(m_buffer, m_bufsiz, 0) ;

   m_angle_range.reset(urg_index2deg(& m_handle, 0),
                       urg_index2deg(& m_handle, m_bufsiz - 1)) ;
   m_distances = new int[m_angle_range.size()] ;
   std::fill_n(m_distances, m_angle_range.size(), 0) ;

   m_distance_range.reset(static_cast<int>(urg_getDistanceMin(& m_handle)),
                          static_cast<int>(urg_getDistanceMax(& m_handle))) ;
}
Пример #10
0
int main(int argc, char *argv[])
{
  enum {
    LinesMax = 5,
  };

  //const char device[] = "COM3"; /* Example for Windows */
  const char device[] = "/dev/ttyACM0"; /* Example for Linux */

  char buffer[LinesMax][UrgLineWidth];
  char *lines[LinesMax];
  int ret;
  int i;

  /* Connection */
  urg_t urg;
  ret = urg_connect(&urg, device, 115200);
  if (ret < 0) {
    urg_exit(&urg, "urg_connect()");
  }

  /* Get version information */
  for (i = 0; i < LinesMax; ++i) {
    lines[i] = buffer[i];
  }
  ret = urg_versionLines(&urg, lines, LinesMax);
  printf("urg_getVersion: %s\n", urg_error(&urg));
  if (ret < 0) {
    urg_disconnect(&urg);
    exit(1);
  }

  /* Display */
  for (i = 0; i < LinesMax; ++i) {
    printf("%s\n", lines[i]);
  }

  /* Disconnect */
  urg_disconnect(&urg);

  return 0;
}
Пример #11
0
 /* Function: mdlStart =======================================================
  * Abstract:
  *    This function is called once at start of model execution. If you
  *    have states that should be initialized once, this is the place
  *    to do it.
  */
 static void mdlStart(SimStruct *S)
 {
       //Lidar setup
   ret = urg_connect(&urg, device, 115200);
   if (ret < 0) {
       urg_exit(&urg, "urg_connect()");
   }
   else
       urg_setCaptureTimes(&urg, UrgInfinityTimes);
   
   //Stepper Setup
   CPhidgetStepper_create(&stepper);
   stepperConnect(600000, 1214,stepper);
   
   //Zero prameters
   counter = 0;
   
   // Webcam SetUp
   capture1  = cvCaptureFromCAM( -1 ); //Sets up Camera Object
   if ( !capture1 ) 
       fprintf( stderr, "ERROR: capture is NULL \n" );
 }
Пример #12
0
/*! main */
int main(int argc, char *argv[])
{
  enum {
    CaptureTimes = 10,
  };

#ifdef WINDOWS_OS
  const char device[] = "COM3"; /* For Windows */
#else
  const char device[] = "/dev/ttyACM0"; /* For Linux */
#endif

  long timestamp = 0;
  int ret = 0;
  int i;

  /* Connection */
  urg_t urg;
  ret = urg_connect(&urg, device, 115200);
  if (ret < 0) {
    urg_exit(&urg, "urg_connect()");
  }

  /* Transit to timestamp mode and displays time stamp */
  urg_enableTimestampMode(&urg);
  for (i = 0; i < CaptureTimes; ++i) {
    timestamp = urg_currentTimestamp(&urg);
    printf("%02d: timestamp: %ld [msec]\n", i, timestamp);
  }
  urg_disableTimestampMode(&urg);

#ifdef MSC
  getchar();
#endif

  return 0;
}
/* Function: mdlStart =======================================================
 * Abstract:
 *    This function is called once at start of model execution. If you
 *    have states that should be initialized once, this is the place
 *    to do it.
 */
static void mdlStart(SimStruct *S) {
    // Lidar Setup
    ret  = urg_connect(&urg, device, 115200);
    if(ret<0)
        urg_exit(&urg, "urg_connect()");
    else
        urg_setCaptureTimes(&urg, UrgInfinityTimes);
    
    // Stepper Setup
    // Default 1214 Speed before Speed Input
    CPhidgetStepper_create(&stepper);
    stepperConnect(1000000, 1214, stepper);
    
    // Zero Counter variables
    counter = 0;
    camCounter = 0;
    lidarCounter = 0;
    bothCounter = 0;
    
    // Webcam Setup
    capture1  = cvCaptureFromCAM( -1 ); //Sets up Camera Object
    if (!capture1)
        fprintf( stderr, "ERROR: capture is NULL \n" );
}
Пример #14
0
/*-----------激光初始化------------------
入口参数:
     port:激光所用串口   0-6表示COM1-COM7
	 baudrate:串口通讯速率选择  0-2 表示 19200,57600,115200
出口参数:
	 urg_state:激光状态读取地址
     return:激光数据最大量
-----------------------------------------*/
int  Laser_Init(int port,int baudrate,urg_state_t *urg_state)
{
	int i=0;
	const char* com_port[7] ={ "COM1", "COM2", "COM3","COM4","COM5","COM6","COM7" };
	const long com_baudrate[3] ={ 19200, 57600, 115200 };

	int max_size=0,recv_n=0;									//串口大小

	// Connect with URG 
	int ret = urg_connect(urg_state, com_port[port], com_baudrate[baudrate]);
	if (ret < 0) {
		// Show error message and end
		AfxMessageBox("连接激光失败");
		urg_disconnect(); //断开连接
		return 0;
	}else{
		max_size = urg_state->max_size;
		urg_sendMessage("BM", Timeout, &recv_n); //开始接收激光数据

	//	SetTimer(1,100,NULL);
	}

	return max_size;
}
Пример #15
0
/*! main */
int main(int argc, char *argv[])
{
#ifdef WINDOWS_OS
  const char device[] = "COM3"; /* For Windows */
#else
  const char device[] = "/dev/ttyACM0"; /* For Linux */
#endif

  long *data = NULL;
  int data_max;
  int min_length = 0;
  int max_length = 0;
  int ret;
  int n;
  int i;

  /* Connection */
  urg_t urg;
  urg_initialize(&urg);
  ret = urg_connect(&urg, device, 115200);
  if (ret < 0) {
    urg_exit(&urg, "urg_connect()");
  }

  /* Reserve for Reception data */
  data_max = urg_dataMax(&urg);
  data = (long*)malloc(sizeof(long) * data_max);
  if (data == NULL) {
    perror("data buffer");
    exit(1);
  }

  /* Request for GD data */
  ret = urg_requestData(&urg, URG_GD, URG_FIRST, URG_LAST);
  if (ret < 0) {
    urg_exit(&urg, "urg_requestData()");
  }

  /* Reception */
  n = urg_receiveData(&urg, data, data_max);
  if (n < 0) {
    urg_exit(&urg, "urg_receiveData()");
  }

  /* Output as 2 dimensional data */
  /* Consider front of URG as positive direction of X axis */
  min_length = urg_minDistance(&urg);
  max_length = urg_maxDistance(&urg);
  for (i = 0; i < n; ++i) {
    int x, y;
    long length = data[i];

    /* Neglect the out of range values */
    if ((length <= min_length) || (length >= max_length)) {
      continue;
    }

    x = (int)(length * cos(urg_index2rad(&urg, i)));
    y = (int)(length * sin(urg_index2rad(&urg, i)));

    printf("%d\t%d\t# %d, %ld\n", x, y, i, length);
  }

  urg_disconnect(&urg);
  free(data);

#ifdef MSC
  getchar();
#endif

  return 0;
}
Пример #16
0
/*! main */
int main(int argc, char *argv[])
{
  enum {
    CaptureTimes = 10,
  };

#ifdef WINDOWS_OS
  const char device[] = "COM3"; /* For Windows */
#else
  const char device[] = "/dev/ttyACM0"; /* For Linux */
#endif

  int data_max;
  long* data;
  urg_parameter_t parameter;
  int ret;
  int n;
  int i;

  /* Connection */
  urg_t urg;
  ret = urg_connect(&urg, device, 115200);
  if (ret < 0) {
    urg_exit(&urg, "urg_connect()");
  }

  /* Request for Data using GD */
  data_max = urg_dataMax(&urg);
  data = (long*)malloc(sizeof(long) * data_max);
  if (data == NULL) {
    perror("data buffer");
    exit(1);
  }
  urg_parameters(&urg, &parameter);

  /* Request for Data using GD */
  printf("GD capture\n");
  for (i = 0; i < CaptureTimes; ++i) {
    /* Request for data */
    ret = urg_requestData(&urg, URG_GD, URG_FIRST, URG_LAST);
    if (ret < 0) {
      urg_exit(&urg, "urg_requestData()");
    }

    /* Reception */
    n = urg_receiveData(&urg, data, data_max);
    if (n < 0) {
      urg_exit(&urg, "urg_receiveData()");
    }

    /* Display */
    printData(&urg, &parameter, data);
  }
  printf("\n");


  /* Request for Data using MD */
  printf("MD capture\n");

  /* set data acquisition frequency equal to infinity, to get the data more
     than 100 times */
  /* urg_setCaptureTimes(&urg, UrgInfinityTimes); */
  assert(CaptureTimes < 100);
  urg_setCaptureTimes(&urg, CaptureTimes);

  /* Request for data */
  ret = urg_requestData(&urg, URG_MD, URG_FIRST, URG_LAST);
  if (ret < 0) {
    urg_exit(&urg, "urg_requestData()");
  }

  for (i = 0; i < CaptureTimes; ++i) {
    /* Reception */
    n = urg_receiveData(&urg, data, data_max);
    if (n < 0) {
      urg_exit(&urg, "urg_receiveData()");
    }

    /* Display */
    printData(&urg, &parameter, data);
  }

  urg_disconnect(&urg);
  free(data);

#ifdef MSC
  getchar();
#endif

  return 0;
}
Пример #17
0
/*! main */
int main(int argc, char *argv[])
{
  enum {
    Times = 10,
    Urgs = 2,
  };

  urg_t urg[Urgs];
  long *data[Urgs];
  int data_max[Urgs];
  int timestamp;
  int ret;
  int n;
  int i;
  int k;

#ifdef WINDOWS_OS
  const char *devices[] = { "COM3", "COM4" }; /* For Windows */
#else
  const char *devices[] = { "/dev/ttyACM0", "/dev/ttyACM1" }; /* For Linux */
#endif

  /* Connection */
  for (i = 0; i < Urgs; ++i) {
    urg_initialize(&urg[i]);
    ret = urg_connect(&urg[i], devices[i], 115200);
    if (ret < 0) {
      urg_exit(&urg[i], "urg_connect()");
    }
    /* To clear existing MD command*/
    urg_laserOff(&urg[i]);

    /* It will become easy if some frames are skipped. */
    /* If specified skip is 2, then transferred data becomes half. */
    /* urg_setSkipLines(&urg[i], 2); */

    /* Reserve for receive buffer */
    data_max[i] = urg_dataMax(&urg[i]);
    data[i] = (long*)malloc(sizeof(long) * data_max[i]);
    if (data[i] == NULL) {
      perror("data buffer");
      exit(1);
    }
  }

  /* Request for MD data */
  for (i = 0; i < Urgs; ++i) {
    urg_setCaptureTimes(&urg[i], Times);

    /* Request for data */
    ret = urg_requestData(&urg[i], URG_MD, URG_FIRST, URG_LAST);
    if (ret < 0) {
      urg_exit(&urg[i], "urg_requestData()");
    }
  }

  for (k = 0; k < Times; ++k) {
    for (i = 0; i < Urgs; ++i) {
      /* Ends when data reception is completed */
      int remain_times = urg_remainCaptureTimes(&urg[i]);
      printf("    %d: ", i);
      printf("(%03d/%03d): ", remain_times, Times);
      if (remain_times <= 0) {
        printf("\n");
        continue;
      }

      /* Reception */
      n = urg_receiveData(&urg[i], data[i], data_max[i]);
      if (n < 0) {
        /* Continue processing, because there is chances of receiving the
           data next time. */
        printf("%s: %s\n", "urg_receiveData()", urg_error(urg));

      } else {

        /* Display */
        timestamp = urg_recentTimestamp(&urg[i]);
        printf("timestamp: %d, ", timestamp);
#if 0
        {
          int j;
          for (j = 0; j < n; ++j) {
            /* Neglect if distance data is less than urg_minDistance() */
            printf("%d:%ld, ", j, data[i][j]);
          }
          printf("\n");
        }
#endif
        printf("\n");
      }
    }
  }

  /* Disconnect */
  for (i = 0; i < Urgs; ++i) {
    urg_disconnect(&urg[i]);
    free(data[i]);
  }

#ifdef MSC
  getchar();
#endif

  return 0;
}
Пример #18
0
void Hokuyo::open(const char *deviceString, cvg_int bps) {
    close();
    if (urg_connect(&urg, deviceString, bps) < 0)
        outError("Unable to connect to device");
    started = true;
}
Пример #19
0
int main(int argc, char *argv[])
{
#ifdef WINDOWS_OS
    const char device[] = "COM3"; /* For Windows */
#else
    const char device[] = "/dev/ttyACM0"; /* For Linux */
#endif

    int data_max;
    long *data;
    int timestamp;
    int ret;
    int n;
    int i;

    /* Connection */
    urg_t urg;
    urg_initialize(&urg);
    ret = urg_connect(&urg, device, 115200);
    if (ret < 0) {
        urg_exit(&urg, "urg_connect()");
    }

    /* Reserve for reception data */
    data_max = urg_dataMax(&urg);
    data = (long*)malloc(sizeof(long) * data_max);
    if (data == NULL) {
        perror("malloc");
        exit(1);
    }

    /* Request for GD data */
    ret = urg_requestData(&urg, URG_GD, URG_FIRST, URG_LAST);
    if (ret < 0) {
        urg_exit(&urg, "urg_requestData()");
    }

    /* Reception */
    n = urg_receiveData(&urg, data, data_max);
    printf("# n = %d\n", n);
    if (n < 0) {
        urg_exit(&urg, "urg_receiveData()");
    }

    /* Display */
    timestamp = urg_recentTimestamp(&urg);
    printf("# timestamp: %d\n", timestamp);
    for (i = 0; i < n; ++i) {
        /*Neglect the distance less than  urg_minDistance()  */
        printf("%d %ld, ", i, data[i]);
    }
    printf("\n");

    urg_disconnect(&urg);
    free(data);

#ifdef MSC
    getchar();
#endif

    return 0;
}
Пример #20
0
//! main
int main(int argc, char *argv[])
{
  enum {
    CaptureTimes = 10,
  };

#ifdef WINDOWS_OS
  const char device[] = "COM3"; /* For Windows */
#else
  const char device[] = "/dev/ttyACM0"; /* For Linux */
#endif

  int data_max;
  long* data;
  int timestamp = -1;
  int previous_timestamp;
  int remain_times;
  //int scan_msec;
  urg_parameter_t parameter;
  int ret;
  int n;
  int i;
  urg_t urg;

  /* Connection */
  urg_initialize(&urg);
  ret = urg_connect(&urg, device, 115200);
  if (ret < 0) {
    urg_exit(&urg, "urg_connect()");
    exit(1);
  }

  /* Reserve for receive buffer */
  data_max = urg_dataMax(&urg);
  data = (long*)malloc(sizeof(long) * data_max);
  if (data == NULL) {
    fprintf(stderr, "data_max: %d\n", data_max);
    perror("data buffer");
    exit(1);
  }
  urg_parameters(&urg, &parameter);
  //scan_msec = urg_scanMsec(&urg);

  /* Request for MD data */
  /* To get data continuously for more than 100 times, set capture times equal
     to infinity times(UrgInfinityTimes) */
  /* urg_setCaptureTimes(&urg, UrgInfinityTimes); */
  assert(CaptureTimes < 100);
  urg_setCaptureTimes(&urg, CaptureTimes);

  /* Request for data */
  ret = urg_requestData(&urg, URG_MD, URG_FIRST, URG_LAST);
  if (ret < 0) {
    urg_exit(&urg, "urg_requestData()");
  }

  for (i = 0; i < CaptureTimes; ++i) {
    /* Reception */
    n = urg_receiveData(&urg, data, data_max);
    printf("n = %d\n", n);
    if (n < 0) {
      urg_exit(&urg, "urg_receiveData()");
    } else if (n == 0) {
      printf("n == 0\n");
      --i;
      continue;
    }

    /* Display the front data with timestamp */
    /* Delay in reception of data at PC causes URG to discard the data which
       cannot be transmitted. This may  results in remain_times to become
       discontinuous */
    previous_timestamp = timestamp;
    timestamp = urg_recentTimestamp(&urg);
    remain_times = urg_remainCaptureTimes(&urg);

    /* Neglect the distance data if it is less than urg_minDistance() */
    printf("%d/%d: %ld [mm], %d [msec], (%d)\n",
           remain_times, CaptureTimes, data[parameter.area_front_], timestamp,
           timestamp - previous_timestamp);

    printf("%d, %d\n", i, remain_times);

    if (remain_times <= 0) {
      break;
    }
  }

  urg_disconnect(&urg);
  free(data);

#ifdef MSC
  getchar();
#endif

  return 0;
}