• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1929 (tree)
日時2010-09-30 07:08:50
作者satofumi

ログメッセージ

sensor_parameter.cpp を実装

変更サマリ

差分

--- branches/tsukuba_2010/libs/lidar/samples/get_multiecho_intensity.cpp (nonexistent)
+++ branches/tsukuba_2010/libs/lidar/samples/get_multiecho_intensity.cpp (revision 1929)
@@ -0,0 +1,7 @@
1+int main(int argc, char *argv[])
2+{
3+ (void)argc;
4+ (void)argv;
5+ // !!!
6+ return 0;
7+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- branches/tsukuba_2010/libs/lidar/samples/sync_time_stamp.cpp (nonexistent)
+++ branches/tsukuba_2010/libs/lidar/samples/sync_time_stamp.cpp (revision 1929)
@@ -0,0 +1,7 @@
1+int main(int argc, char *argv[])
2+{
3+ (void)argc;
4+ (void)argv;
5+ // !!!
6+ return 0;
7+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- branches/tsukuba_2010/libs/lidar/samples/get_distance_intensity.cpp (nonexistent)
+++ branches/tsukuba_2010/libs/lidar/samples/get_distance_intensity.cpp (revision 1929)
@@ -0,0 +1,7 @@
1+int main(int argc, char *argv[])
2+{
3+ (void)argc;
4+ (void)argv;
5+ // !!!
6+ return 0;
7+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- branches/tsukuba_2010/libs/lidar/samples/get_multiecho.cpp (nonexistent)
+++ branches/tsukuba_2010/libs/lidar/samples/get_multiecho.cpp (revision 1929)
@@ -0,0 +1,7 @@
1+int main(int argc, char *argv[])
2+{
3+ (void)argc;
4+ (void)argv;
5+ // !!!
6+ return 0;
7+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- branches/tsukuba_2010/libs/lidar/samples/get_distance.cpp (nonexistent)
+++ branches/tsukuba_2010/libs/lidar/samples/get_distance.cpp (revision 1929)
@@ -0,0 +1,7 @@
1+int main(int argc, char *argv[])
2+{
3+ (void)argc;
4+ (void)argv;
5+ // !!!
6+ return 0;
7+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- branches/tsukuba_2010/libs/lidar/samples/sensor_parameter.cpp (nonexistent)
+++ branches/tsukuba_2010/libs/lidar/samples/sensor_parameter.cpp (revision 1929)
@@ -0,0 +1,91 @@
1+/*!
2+ \example sensor_parameter.c センサ情報の出力
3+
4+ \author Satofumi KAMIMURA
5+
6+ $Id$
7+*/
8+
9+#include "Urg_driver.h"
10+#include <iostream>
11+#include <string>
12+#include <cstring>
13+
14+using namespace qrk;
15+using namespace std;
16+
17+
18+namespace
19+{
20+ typedef struct
21+ {
22+ Urg_driver::connection_type_t connection_type;
23+ string device_or_ip;
24+ long baudrate_or_port;
25+ } connection_information_t;
26+
27+
28+ void set_serial_connection(connection_information_t& information)
29+ {
30+ information.connection_type = Urg_driver::Serial;
31+#if defined(URG_WINDOWS_OS)
32+ information.device_or_ip = "COM3";
33+#elif defined(URG_LINUX_OS)
34+ information.device_or_ip = "/dev/ttyACM0";
35+#else
36+#endif
37+ information.baudrate_or_port = 115200;
38+ }
39+
40+
41+ void set_ethernet_connection(connection_information_t& information)
42+ {
43+ information.connection_type = Urg_driver::Ethernet;
44+ information.device_or_ip = "192.168.0.10";
45+ information.baudrate_or_port = 10940;
46+ }
47+
48+
49+ void parse_connection_setting(connection_information_t& information,
50+ int argc, char *argv[])
51+ {
52+ for (int i = 1; i < argc; ++i) {
53+ if (!strcmp(argv[i], "-e")) {
54+ set_ethernet_connection(information);
55+ return;
56+ }
57+ }
58+ set_serial_connection(information);
59+ }
60+}
61+
62+
63+int main(int argc, char *argv[])
64+{
65+ connection_information_t information;
66+ parse_connection_setting(information, argc, argv);
67+
68+ Urg_driver urg;
69+ if (urg.open(information.device_or_ip.c_str(), information.baudrate_or_port,
70+ information.connection_type)) {
71+ cout << "Urg_driver::open():" << urg.what() << endl;
72+ return 1;
73+ }
74+
75+ printf("Sensor firmware version: %s\n", urg.version());
76+ printf("Sensor serial ID: %s\n", urg.serial_id());
77+ printf("Sensor status: %s\n", urg.status());
78+
79+ printf("step: [%d, %d]\n", urg.min_step(), urg.max_step());
80+ printf("distance: [%ld, %ld)\n", urg.min_distance(), urg.max_distance());
81+
82+ printf("scan interval: %ld [usec]\n", urg.scan_usec());
83+ printf("sensor data size: %d\n", urg.max_data_size());
84+
85+ urg.close();
86+
87+#if defined(URG_MSC)
88+ getchar();
89+#endif
90+ return 0;
91+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- branches/tsukuba_2010/libs/lidar/samples/Makefile (nonexistent)
+++ branches/tsukuba_2010/libs/lidar/samples/Makefile (revision 1929)
@@ -0,0 +1,35 @@
1+# lidar/samples
2+
3+CC = $(CXX)
4+CXXFLAGS = -g -O0 -Wall -Werror $(INCLUDES)
5+INCLUDES = -I..
6+LDFLAGS =
7+LDLIBS = `urg_c-config --libs`
8+
9+
10+TARGET = \
11+ sensor_parameter \
12+ get_distance \
13+ get_distance_intensity \
14+ get_multiecho \
15+ get_multiecho_intensity \
16+ calculate_xy \
17+ sync_time_stamp \
18+
19+all : $(TARGET)
20+
21+clean :
22+ $(RM) $(TARGET) *.o
23+
24+depend :
25+ makedepend -Y -- $(INCLUDES_FOR_BUILD) -- $(wildcard *.h *.c *.cpp)
26+
27+.PHONY : all clean depend
28+######################################################################
29+REQUIRE_LIBS = ../liblidar.a
30+$(REQUIRE_LIBS) :
31+ cd $(@D)/ && $(MAKE) $(@F)
32+
33+$(TARGET) : $(REQUIRE_LIBS)
34+
35+# DO NOT DELETE
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- branches/tsukuba_2010/libs/lidar/samples/calculate_xy.cpp (nonexistent)
+++ branches/tsukuba_2010/libs/lidar/samples/calculate_xy.cpp (revision 1929)
@@ -0,0 +1,7 @@
1+int main(int argc, char *argv[])
2+{
3+ (void)argc;
4+ (void)argv;
5+ // !!!
6+ return 0;
7+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- branches/tsukuba_2010/libs/lidar/Urg_driver.cpp (revision 1928)
+++ branches/tsukuba_2010/libs/lidar/Urg_driver.cpp (revision 1929)
@@ -8,28 +8,87 @@
88 */
99
1010 #include "Urg_driver.h"
11+extern "C" {
12+#include "urg_sensor.h"
13+#include "urg_utils.h"
14+}
15+#include <string>
1116
1217 using namespace qrk;
18+using namespace std;
1319
1420
1521 struct Urg_driver::pImpl
1622 {
17- // !!!
23+ urg_t urg_;
24+ string error_message_;
25+
26+
27+ pImpl(void) : error_message_("no error.")
28+ {
29+ }
1830 };
1931
2032
21-bool Urg_driver::open(const char* device_name, long baudrate)
33+Urg_driver::Urg_driver(void) : pimpl(new pImpl)
2234 {
23- (void)device_name;
24- (void)baudrate;
35+}
2536
37+
38+Urg_driver::~Urg_driver(void)
39+{
40+}
41+
42+
43+const char* Urg_driver::what(void) const
44+{
45+ return pimpl->error_message_.c_str();
46+}
47+
48+
49+bool Urg_driver::open(const char* device_name, long baudrate,
50+ connection_type_t type)
51+{
52+ urg_connection_type_t connection_type =
53+ (type == Ethernet) ? URG_ETHERNET : URG_SERIAL;
54+ int ret = urg_open(&pimpl->urg_, connection_type, device_name, baudrate);
55+ if (ret < 0) {
56+ pimpl->error_message_ = urg_error(&pimpl->urg_);
57+ return false;
58+ }
59+ return true;
60+}
61+
62+
63+void Urg_driver::close(void)
64+{
65+ urg_close(&pimpl->urg_);
66+}
67+
68+
69+bool Urg_driver::start_measurement(measurement_type_t type,
70+ int scan_times, int skip_scan)
71+{
72+ (void)type;
73+ (void)scan_times;
74+ (void)skip_scan;
2675 // !!!
2776
77+ return -1;
78+}
79+
80+
81+bool Urg_driver::get_distance(std::vector<long>& data, long* time_stamp)
82+{
83+ (void)data;
84+ (void)time_stamp;
85+ // !!!
86+
2887 return false;
2988 }
3089
3190
32-void Urg_driver::close(void)
91+void Urg_driver::urg_stop_measurement(void)
3392 {
3493 // !!!
3594 }
@@ -42,3 +101,77 @@
42101
43102 return false;
44103 }
104+
105+
106+int Urg_driver::min_step(void) const
107+{
108+ int min_step;
109+ int max_step;
110+
111+ urg_step_min_max(&pimpl->urg_, &min_step, &max_step);
112+
113+ return min_step;
114+}
115+
116+
117+int Urg_driver::max_step(void) const
118+{
119+ int min_step;
120+ int max_step;
121+
122+ urg_step_min_max(&pimpl->urg_, &min_step, &max_step);
123+
124+ return max_step;
125+}
126+
127+
128+long Urg_driver::min_distance(void) const
129+{
130+ long min_distance;
131+ long max_distance;
132+
133+ urg_distance_min_max(&pimpl->urg_, &min_distance, &max_distance);
134+
135+ return min_distance;
136+}
137+
138+
139+long Urg_driver::max_distance(void) const
140+{
141+ long min_distance;
142+ long max_distance;
143+
144+ urg_distance_min_max(&pimpl->urg_, &min_distance, &max_distance);
145+
146+ return max_distance;
147+}
148+
149+
150+long Urg_driver::scan_usec(void) const
151+{
152+ return urg_scan_usec(&pimpl->urg_);
153+}
154+
155+
156+int Urg_driver::max_data_size(void) const
157+{
158+ return urg_max_data_size(&pimpl->urg_);
159+}
160+
161+
162+const char* Urg_driver::version(void) const
163+{
164+ return urg_sensor_version(&pimpl->urg_);
165+}
166+
167+
168+const char* Urg_driver::serial_id(void) const
169+{
170+ return urg_sensor_serial_id(&pimpl->urg_);
171+}
172+
173+
174+const char* Urg_driver::status(void) const
175+{
176+ return urg_sensor_status(&pimpl->urg_);
177+}
--- branches/tsukuba_2010/libs/lidar/Makefile (revision 1928)
+++ branches/tsukuba_2010/libs/lidar/Makefile (revision 1929)
@@ -1,5 +1,6 @@
11 # lidar/
22
3+CC = $(CXX)
34 CXXFLAGS = -g -O0 -Wall -Werror -W $(INCLUDES) `urg_c-config --cflags`
45 CFLAGS = $(CXXFLAGS)
56 INCLUDES =
@@ -11,7 +12,7 @@
1112
1213 clean :
1314 $(RM) $(TARGET) *.o
14-# cd samples/ && $(MAKE) clean
15+ cd samples/ && $(MAKE) clean
1516
1617 depend :
1718 makedepend -Y -- $(INCLUDES_FOR_BUILD) -- $(wildcard *.h *.c *.cpp)
--- branches/tsukuba_2010/libs/lidar/Urg_driver.h (revision 1928)
+++ branches/tsukuba_2010/libs/lidar/Urg_driver.h (revision 1929)
@@ -11,6 +11,7 @@
1111 */
1212
1313 #include <memory>
14+#include <vector>
1415
1516
1617 namespace qrk
@@ -18,15 +19,51 @@
1819 class Urg_driver
1920 {
2021 public:
21- bool open(const char* device_name, long baudrate);
22+ typedef enum {
23+ Distance, /*!< 距離 */
24+ Distance_intensity, /*!< 距離 + 強度 */
25+ Multiecho, /*!< マルチエコーの距離 */
26+ Multiecho_intensity, /*!< マルチエコーの(距離 + 強度) */
27+ } measurement_type_t;
28+
29+
30+ typedef enum {
31+ Serial,
32+ Ethernet,
33+ } connection_type_t;
34+
35+
36+ enum {
37+ Default_baudrate = 115200,
38+ Infinity_times = -1,
39+ };
40+
41+
42+ Urg_driver(void);
43+ ~Urg_driver(void);
44+
45+ const char* what(void) const;
46+
47+
48+ bool open(const char* device_name, long baudrate = Default_baudrate,
49+ connection_type_t type = Serial);
2250 void close(void);
2351
52+
2453 // !!! データ取得の開始
54+ bool start_measurement(measurement_type_t type = Distance,
55+ int scan_times = Infinity_times,
56+ int skip_scan = 0);
2557
58+
2659 // !!! 受信データの受け取り
60+ bool get_distance(std::vector<long>& data, long* time_stamp = NULL);
2761
62+
2863 // !!! データ取得の中断
64+ void urg_stop_measurement(void);
2965
66+
3067 // !!! タイムスタンプの同期
3168 bool set_sensor_timestamp(long timestamp);
3269
@@ -35,6 +72,17 @@
3572 // !!! 設定可能範囲の取得
3673 // !!! 1周あたりのスキャン時間の取得
3774
75+ int min_step(void) const;
76+ int max_step(void) const;
77+ long min_distance(void) const;
78+ long max_distance(void) const;
79+ long scan_usec(void) const;
80+ int max_data_size(void) const;
81+
82+ const char* version(void) const;
83+ const char* serial_id(void) const;
84+ const char* status(void) const;
85+
3886 private:
3987 Urg_driver(const Urg_driver& rhs);
4088 Urg_driver& operator = (const Urg_driver& rhs);
--- branches/tsukuba_2010/Makefile (revision 1928)
+++ branches/tsukuba_2010/Makefile (revision 1929)
@@ -12,9 +12,10 @@
1212 cd programs/ && $(MAKE) clean
1313
1414 samples :
15+ cd libs/controller/samples/ && $(MAKE)
1516 cd libs/run_target/samples/ && $(MAKE)
16- cd libs/controller/samples/ && $(MAKE)
1717 cd libs/run/samples/ && $(MAKE)
18+ cd libs/lidar/samples/ && $(MAKE)
1819 cd programs/run_path_follower/samples/ && $(MAKE)
1920
2021
旧リポジトリブラウザで表示