Beispiel #1
0
//! main
int main(int argc, char *argv[])
{
#ifdef WINDOWS_OS
  const char device[] = "COM3";
#else
  const char device[] = "/dev/ttyACM0";
#endif

  UrgDevice urg;
  if (! urg.connect(device)) {
    printf("UrgDevice::connect: %s\n", urg.what());
    exit(1);
  }

  vector<string> lines;

  // Receive version information
  urg.versionLines(lines);
  if (lines.empty()) {
    cerr << "UrgDevice::versionLines: " << urg.what() << endl;
    exit(1);
  }

  // Display
  for (vector<string>::iterator it = lines.begin();
       it != lines.end(); ++it) {
    cout << *it << endl;
  }

#ifdef MSC
  getchar();
#endif

  return 0;
}
Beispiel #2
0
//! main
int main(int argc, char *argv[])
{
  // Change the port name appropriately
#ifdef WINDOWS_OS
  const char device[] = "COM3";
#else
  const char device[] = "/dev/ttyACM0";
#endif

  UrgDevice urg;
  if (! urg.connect(device)) {
    printf("UrgDevice::connect: %s\n", urg.what());
    exit(1);
  }

  // Display parameter information
  RangeSensorParameter parameters = urg.parameter();
  printf("model: %s\n", parameters.model.c_str());
  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);

#ifdef MSC
  getchar();
#endif

  return 0;
}
Beispiel #3
0
 void connect()
 {
     qrk::LockGuard guard(urg_mutex);
     
     if (! urg.connect(device.c_str())) {
         printf("UrgDevice::connect: %s\n", urg.what());
         exit(1);
     }
 }
Beispiel #4
0
//! main
int main(int argc, char *argv[])
{
  if (argc < 3) {
    cerr << "usage:" << endl
         << "\t" << argv[0] << " <number of scans> <output file>\n"
         << endl;
    exit(1);
  }
  int scan_times = atoi(argv[1]);
  max(scan_times, 0);
  ofstream fout(argv[2]);
  if (! fout.is_open()) {
    perror(argv[2]);
  }

  // Search URG port
  vector<string> ports;
  findUrgPorts(ports);

  if (ports.empty()) {
    cerr << "no ports." << endl;
    exit(1);
  }

  UrgDevice urg;
  if (! urg.connect(ports[0].c_str())) {
    cerr << "UrgDevice::connect: " << urg.what() << endl;
    exit(1);
  }

  // Get data by GD command
  vector<long> data;
  for (int i = 0; i < scan_times; ++i) {
    int n = urg.capture(data);
    if (n < 0) {
      continue;
    }
    outputCsv(fout, data);
    cout << (i + 1) << " scaned." << endl;
  }

#ifdef MSC
  getchar();
#endif

  return 0;
}