Пример #1
0
int main(int argc, char *argv[])
{
    Connection_information information(argc, argv);

    // 接続
    Urg_driver urg;
    if (!urg.open(information.device_or_ip_name(),
                  information.baudrate_or_port_number(),
                  information.connection_type())) {
        cout << "Urg_driver::open(): "
             << information.device_or_ip_name() << ": " << urg.what() << endl;
        return 1;
    }

    // データは1ステップのみ取得する
    int min_step = urg.min_step();
    urg.set_scanning_parameter(min_step, min_step);

    // 比較用に PC とセンサのタイムスタンプを表示する
    print_timestamp(urg);
    cout << endl;

    // センサに PC のタイムスタンプを設定し、
    // 距離データを取得したときに得られるタイムスタンプが、
    // PC から得られるタイムスタンプと同じになるようにする
    urg.set_sensor_time_stamp(ticks());

    // 設定後に PC とセンサのタイムスタンプを表示する
    print_timestamp(urg);

    return 0;
}
Пример #2
0
int main(int argc, char *argv[])
{
    Connection_information information(argc, argv);

    // 接続
    Urg_driver urg;
    if (!urg.open(information.device_or_ip_name(),
                  information.baudrate_or_port_number(),
                  information.connection_type())) {
        cout << "Urg_driver::open(): "
             << information.device_or_ip_name() << ": " << urg.what() << endl;
        return 1;
    }

    // データ取得
#if 1
    // データの取得範囲を変更する場合
    urg.set_scanning_parameter(urg.deg2step(-90), urg.deg2step(+90), 0);
#endif
    enum { Capture_times = 10 };
    urg.start_measurement(Urg_driver::Distance, Urg_driver::Infinity_times, 0);
    for (int i = 0; i < Capture_times; ++i) {
        vector<long> data;
        long time_stamp = 0;

        if (!urg.get_distance(data, &time_stamp)) {
            cout << "Urg_driver::get_distance(): " << urg.what() << endl;
            return 1;
        }
        print_data(urg, data, time_stamp);
    }

#if defined(URG_MSC)
    getchar();
#endif
    return 0;
}