Exemple #1
0
 void update()
 {
     qrk::LockGuard guard(urg_mutex);
     urg.capture(data, &timestamp);
     
     vector<float> angles;
     for (int i=0; i<data.size(); i++) {
         angles.push_back( urg.index2rad(i));
     }
     
     urg_data.setData(data);
     urg_data.setDataAngles(angles);
     
 }
Exemple #2
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;
}