Created
March 5, 2012 04:18
-
-
Save trecouvr/1976603 to your computer and use it in GitHub Desktop.
test hokuyo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*! | |
| \file | |
| \brief データ取得サンプル | |
| \author Satofumi KAMIMURA | |
| $Id: gdScanSample.cpp 1883 2010-08-20 04:12:36Z satofumi $ | |
| */ | |
| #include "UrgCtrl.h" | |
| #include <cstdlib> | |
| #include <cstdio> | |
| using namespace qrk; | |
| using namespace std; | |
| //! main | |
| int main(int argc, char *argv[]) { | |
| //const char device[] = "COM3"; /* Windows での例 */ | |
| const char device[] = "/dev/ttyACM0"; | |
| UrgCtrl urg; | |
| if (! urg.connect(device)) { | |
| printf("UrgCtrl::connect: %s\n", urg.what()); | |
| exit(1); | |
| } | |
| // データ取得 | |
| vector<long> data; | |
| long timestamp = 0; | |
| int n = urg.capture(data, ×tamp); | |
| printf("n = %d\n", n); | |
| if (n < 0) { | |
| printf("UrgCtrl::capture: %s\n", urg.what()); | |
| exit(1); | |
| } | |
| printf("timestamp: %ld\n", timestamp); | |
| for (int i = 0; i < n; ++i) { | |
| printf("%ld, ", data[i]); | |
| } | |
| printf("\n"); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exe: src/main.cpp | |
| g++ -o exe src/main.cpp -Wall -Werror `urg-config --cflags` `sdl-config --cflags` `urg-config --libs` `sdl-config --libs` -lc -lpthread |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment