• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1840 (tree)
日時2010-06-06 19:43:46
作者satofumi

ログメッセージ

add UrgCtrl.h

変更サマリ

差分

--- trunk/doxes/urg_dox/forge_conf.txt (revision 1839)
+++ trunk/doxes/urg_dox/forge_conf.txt (revision 1840)
@@ -1,24 +1,24 @@
1-# 更新ページリストを挿入するページ
1+# 譖エ譁ー繝壹?繧ク繝ェ繧ケ繝医r謖ソ蜈・縺吶k繝壹?繧ク
22 IndexHtml urg_programs/index.html
33 IndexHistoryMax 8
44 HistoryLogFile urg_dox/history_log.txt
55
6-# RSS の出力設定
6+# RSS 縺ョ蜃コ蜉幄ィュ螳
77 RssBaseUrl http://www.hokuyo-aut.co.jp/02sensor/07scanner/download/urg_programs/
8-RssTitle URG プログラミングガイド
9-RssDescription URG 用プログラム作成のチュートリアル
8+RssTitle URG 繝励Ο繧ー繝ゥ繝溘Φ繧ー繧ャ繧、繝
9+RssDescription URG 逕ィ繝励Ο繧ー繝ゥ繝?菴懈?縺ョ繝√Η繝シ繝医Μ繧「繝ォ
1010
1111 OutputRss10 urg_programs/urg_programs.rdf
1212 OutputRss20 urg_programs/urg_programs.xml
1313
14-# RSS を埋め込むか
14+# RSS 繧貞沂繧∬セシ繧?縺
1515 InsertRss yes
1616
17-# 置換処理を行うページ
17+# 鄂ョ謠帛?逅?r陦後≧繝壹?繧ク
1818 TargetHtml urg_programs/index.html
1919
20-# 再起的に更新されたページの検索を行うディレクトリ位置
20+# 蜀崎オキ逧?↓譖エ譁ー縺輔l縺溘?繝シ繧ク縺ョ讀懃エ「繧定。後≧繝?ぅ繝ャ繧ッ繝医Μ菴咲スョ
2121 FindDoxDirectory urg_dox/ ../programs/UrgViewer ../programs/UrgInformation ../programs/MultiUrgViewer ../programs/UrgRecorder
2222
23-# 以下、置換キーワード
23+# 莉・荳九?∫スョ謠帙く繝シ繝ッ繝シ繝
2424 #ReplaceList
--- trunk/scripts/doxyHtmlUpdate.rb (revision 1839)
+++ trunk/scripts/doxyHtmlUpdate.rb (revision 1840)
@@ -1,4 +1,5 @@
11 #!/usr/bin/ruby
2+# -*- coding: utf-8 -*-
23 # Doxygen で出力したページを SourceForge 用に調整するツール
34 # 併せて、RSS, 更新履歴の生成も行う
45 # Satofumi KAMIMURA
@@ -211,7 +212,7 @@
211212 rss = RSS::Maker.make(type) do |maker|
212213 # !!! fname, basename の扱いを確認すべき
213214 maker.channel.about = rss_settings['base'] + File.basename(fname)
214- maker.channel.title = rss_settings['title']
215+ maker.channel.title = rss_settings['title'].toutf8
215216 maker.channel.description = rss_settings['description']
216217 maker.channel.link = rss_settings['base']
217218
--- trunk/libs/range_sensor/UrgDevice.cpp (revision 1839)
+++ trunk/libs/range_sensor/UrgDevice.cpp (revision 1840)
@@ -1006,9 +1006,3 @@
10061006
10071007 return true;
10081008 }
1009-
1010-
1011-bool UrgDevice::reset(void)
1012-{
1013- return reboot();
1014-}
--- trunk/libs/range_sensor/UrgCtrl.cpp (nonexistent)
+++ trunk/libs/range_sensor/UrgCtrl.cpp (revision 1840)
@@ -0,0 +1,231 @@
1+/*!
2+ \file
3+ \brief URG sensor control
4+
5+ \author Satofumi KAMIMURA
6+
7+ $Id$
8+*/
9+
10+#include "UrgCtrl.h"
11+#include "UrgDevice.h"
12+#include "RangeSensorParameter.h"
13+
14+using namespace qrk;
15+
16+
17+struct UrgCtrl::pImpl
18+{
19+ UrgDevice urg_;
20+};
21+
22+
23+UrgCtrl::UrgCtrl(void) : pimpl(new pImpl)
24+{
25+}
26+
27+
28+UrgCtrl::~UrgCtrl(void)
29+{
30+}
31+
32+
33+const char* UrgCtrl::what(void) const
34+{
35+ return pimpl->urg_.what();
36+}
37+
38+
39+bool UrgCtrl::connect(const char* device, long baudrate)
40+{
41+ return pimpl->urg_.connect(device, baudrate);
42+}
43+
44+
45+void UrgCtrl::setConnection(Connection* con)
46+{
47+ pimpl->urg_.setConnection(con);
48+}
49+
50+
51+Connection* UrgCtrl::connection(void)
52+{
53+ return pimpl->urg_.connection();
54+}
55+
56+
57+void UrgCtrl::disconnect(void)
58+{
59+ pimpl->urg_.disconnect();
60+}
61+
62+
63+bool UrgCtrl::isConnected(void) const
64+{
65+ return pimpl->urg_.isConnected();
66+}
67+
68+
69+long UrgCtrl::minDistance(void) const
70+{
71+ return pimpl->urg_.minDistance();
72+}
73+
74+
75+long UrgCtrl::maxDistance(void) const
76+{
77+ return pimpl->urg_.maxDistance();
78+}
79+
80+
81+int UrgCtrl::maxScanLines(void) const
82+{
83+ return pimpl->urg_.maxScanLines();
84+}
85+
86+
87+void UrgCtrl::setRetryTimes(size_t times)
88+{
89+ return pimpl->urg_.setRetryTimes(times);
90+}
91+
92+
93+void UrgCtrl::setCapturesSize(size_t size)
94+{
95+ pimpl->urg_.setCapturesSize(size);
96+}
97+
98+
99+int UrgCtrl::scanMsec(void) const
100+{
101+ return pimpl->urg_.scanMsec();
102+}
103+
104+
105+void UrgCtrl::setCaptureMode(RangeCaptureMode mode)
106+{
107+ pimpl->urg_.setCaptureMode(mode);
108+}
109+
110+
111+RangeCaptureMode UrgCtrl::captureMode(void)
112+{
113+ return pimpl->urg_.captureMode();
114+}
115+
116+
117+void UrgCtrl::setCaptureRange(int begin_index, int end_index)
118+{
119+ pimpl->urg_.setCaptureRange(begin_index, end_index);
120+}
121+
122+
123+void UrgCtrl::setCaptureFrameInterval(size_t interval)
124+{
125+ pimpl->urg_.setCaptureFrameInterval(interval);
126+}
127+
128+
129+void UrgCtrl::setCaptureTimes(size_t times)
130+{
131+ pimpl->urg_.setCaptureTimes(times);
132+}
133+
134+
135+size_t UrgCtrl::remainCaptureTimes(void)
136+{
137+ return pimpl->urg_.remainCaptureTimes();
138+}
139+
140+
141+void UrgCtrl::setCaptureSkipLines(size_t skip_lines)
142+{
143+ pimpl->urg_.setCaptureSkipLines(skip_lines);
144+}
145+
146+
147+int UrgCtrl::capture(std::vector<long>& data, long* timestamp)
148+{
149+ return pimpl->urg_.capture(data, timestamp);
150+}
151+
152+
153+int UrgCtrl::captureWithIntensity(std::vector<long>& data,
154+ std::vector<long>& intensity_data,
155+ long* timestamp)
156+{
157+ return pimpl->urg_.captureWithIntensity(data, intensity_data, timestamp);
158+}
159+
160+
161+void UrgCtrl::stop(void)
162+{
163+ pimpl->urg_.stop();
164+}
165+
166+
167+bool UrgCtrl::setTimestamp(int timestamp, int* response_msec,
168+ int* force_delay_msec)
169+{
170+ return pimpl->urg_.setTimestamp(timestamp, response_msec, force_delay_msec);
171+}
172+
173+
174+long UrgCtrl::recentTimestamp(void) const
175+{
176+ return pimpl->urg_.recentTimestamp();
177+}
178+
179+
180+bool UrgCtrl::setLaserOutput(bool on)
181+{
182+ return pimpl->urg_.setLaserOutput(on);
183+}
184+
185+
186+double UrgCtrl::index2rad(const int index) const
187+{
188+ return pimpl->urg_.index2rad(index);
189+}
190+
191+
192+int UrgCtrl::rad2index(const double radian) const
193+{
194+ return pimpl->urg_.rad2index(radian);
195+}
196+
197+
198+void UrgCtrl::setParameter(const RangeSensorParameter& parameter)
199+{
200+ pimpl->urg_.setParameter(parameter);
201+}
202+
203+
204+RangeSensorParameter UrgCtrl::parameter(void) const
205+{
206+ return pimpl->urg_.parameter();
207+}
208+
209+
210+bool UrgCtrl::loadParameter(void)
211+{
212+ return pimpl->urg_.loadParameter();
213+}
214+
215+
216+bool UrgCtrl::versionLines(std::vector<std::string>& lines)
217+{
218+ return pimpl->urg_.versionLines(lines);
219+}
220+
221+
222+bool UrgCtrl::reboot(void)
223+{
224+ return pimpl->urg_.reboot();
225+}
226+
227+
228+bool UrgCtrl::reset(void)
229+{
230+ return pimpl->urg_.reboot();
231+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- trunk/libs/range_sensor/UrgDevice.h (revision 1839)
+++ trunk/libs/range_sensor/UrgDevice.h (revision 1840)
@@ -240,14 +240,6 @@
240240 bool reboot(void);
241241
242242
243- /*!
244- \brief Reboot URG
245-
246- \deprecated use reboot() function.
247- */
248- bool reset(void);
249-
250-
251243 protected:
252244 virtual void captureReceived(void);
253245
--- trunk/libs/range_sensor/UrgCtrl.h (nonexistent)
+++ trunk/libs/range_sensor/UrgCtrl.h (revision 1840)
@@ -0,0 +1,100 @@
1+#ifndef URG_CTRL_H
2+#define URG_CTRL_H
3+
4+/*!
5+ \file
6+ \brief URG sensor control
7+
8+ \author Satofumi KAMIMURA
9+
10+ $Id$
11+*/
12+
13+#include "RangeSensor.h"
14+#include "Coordinate.h"
15+
16+
17+namespace qrk
18+{
19+ class Connection;
20+
21+
22+ /*!
23+ \brief URG sensor control
24+
25+ \obsolute use UrgCtrl
26+ */
27+ class UrgCtrl : public Coordinate, public RangeSensor
28+ {
29+ public:
30+
31+ enum {
32+ DefaultBaudrate = 115200, //!< [bps]
33+ DefaultRetryTimes = 8,
34+ Infinity = 0,
35+
36+ Off = 0, //!< Laser is off
37+ On = 1, //!< Laser is on
38+ };
39+
40+ UrgCtrl(void);
41+ virtual ~UrgCtrl(void);
42+
43+ const char* what(void) const;
44+
45+ bool connect(const char* device, long baudrate = DefaultBaudrate);
46+ void setConnection(Connection* con);
47+ Connection* connection(void);
48+ void disconnect(void);
49+ bool isConnected(void) const;
50+
51+ long minDistance(void) const;
52+ long maxDistance(void) const;
53+ int maxScanLines(void) const;
54+
55+
56+ void setRetryTimes(size_t times);
57+ void setCapturesSize(size_t size);
58+ int scanMsec(void) const;
59+ void setCaptureMode(RangeCaptureMode mode);
60+ RangeCaptureMode captureMode(void);
61+ void setCaptureRange(int begin_index, int end_index);
62+ void setCaptureFrameInterval(size_t interval);
63+ void setCaptureTimes(size_t times);
64+ size_t remainCaptureTimes(void);
65+ void setCaptureSkipLines(size_t skip_lines);
66+ int capture(std::vector<long>& data, long* timestamp = NULL);
67+ int captureWithIntensity(std::vector<long>& data,
68+ std::vector<long>& intensity_data,
69+ long* timestamp = NULL);
70+ void stop(void);
71+ bool setTimestamp(int timestamp = 0, int* response_msec = NULL,
72+ int* force_delay_msec = NULL);
73+ long recentTimestamp(void) const;
74+ bool setLaserOutput(bool on);
75+
76+ double index2rad(const int index) const;
77+ int rad2index(const double radian) const;
78+ void setParameter(const RangeSensorParameter& parameter);
79+ RangeSensorParameter parameter(void) const;
80+ bool loadParameter(void);
81+ bool versionLines(std::vector<std::string>& lines);
82+ bool reboot(void);
83+ bool reset(void);
84+
85+
86+ protected:
87+ virtual void captureReceived(void);
88+
89+
90+ private:
91+ UrgCtrl(const UrgCtrl& rhs);
92+ UrgCtrl& operator = (const UrgCtrl& rhs);
93+
94+ struct pImpl;
95+ std::auto_ptr<pImpl> pimpl;
96+ };
97+}
98+
99+
100+#endif /* !URG_CTRL_H */
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- trunk/libs/range_sensor/Makefile (revision 1839)
+++ trunk/libs/range_sensor/Makefile (revision 1840)
@@ -34,6 +34,7 @@
3434 $(RANGE_SENSOR_LIB) : \
3535 $(RANGE_SENSOR_LIB)(ScipHandler.o) \
3636 $(RANGE_SENSOR_LIB)(UrgDevice.o) \
37+ $(RANGE_SENSOR_LIB)(UrgCtrl.o) \
3738 $(RANGE_SENSOR_LIB)(UrgUsbCom.o) \
3839 $(RANGE_SENSOR_LIB)(convert2d.o) \
3940 $(RANGE_SENSOR_LIB)(../range_finder/findUrgPorts.o) \
@@ -42,6 +43,9 @@
4243
4344 RangeSensor.o: RangeCaptureMode.h ../math/MathUtils.h ../system/DetectOS.h
4445 ScipHandler.o: CaptureSettings.h
46+UrgCtrl.o: RangeSensor.h RangeCaptureMode.h ../math/MathUtils.h
47+UrgCtrl.o: ../system/DetectOS.h ../coordinate/Coordinate.h
48+UrgCtrl.o: ../geometry/Position.h ../geometry/Angle.h
4549 UrgDevice.o: RangeSensor.h RangeCaptureMode.h ../math/MathUtils.h
4650 UrgDevice.o: ../system/DetectOS.h ../coordinate/Coordinate.h
4751 UrgDevice.o: ../geometry/Position.h ../geometry/Angle.h
@@ -51,6 +55,9 @@
5155 ScipHandler.o: ../connection/Connection.h ../connection/ConnectionUtils.h
5256 ScipHandler.o: ../system/ticks.h ../system/delay.h ../system/DetectOS.h
5357 ScipHandler.o: ../system/log_printf.h
58+UrgCtrl.o: UrgCtrl.h RangeSensor.h RangeCaptureMode.h ../math/MathUtils.h
59+UrgCtrl.o: ../system/DetectOS.h ../coordinate/Coordinate.h
60+UrgCtrl.o: ../geometry/Position.h ../geometry/Angle.h UrgDevice.h
5461 UrgDevice.o: UrgDevice.h RangeSensor.h RangeCaptureMode.h ../math/MathUtils.h
5562 UrgDevice.o: ../system/DetectOS.h ../coordinate/Coordinate.h
5663 UrgDevice.o: ../geometry/Position.h ../geometry/Angle.h
--- trunk/libs/embedded_utils/ring_buffer.c (nonexistent)
+++ trunk/libs/embedded_utils/ring_buffer.c (revision 1840)
@@ -0,0 +1,135 @@
1+/*!
2+ \file
3+ \brief リングバッファ
4+
5+ \author Satofumi KAMIMURA
6+
7+ $Id$
8+*/
9+
10+#include "ring_buffer.h"
11+
12+
13+void ring_initialize(ring_buffer_t *ring, char *buffer, const int shift_length)
14+{
15+ ring->buffer = buffer;
16+ ring->buffer_size = 1 << shift_length;
17+ ring_clear(ring);
18+}
19+
20+
21+void ring_clear(ring_buffer_t *ring)
22+{
23+ ring->first = 0;
24+ ring->last = 0;
25+}
26+
27+
28+int ring_size(const ring_buffer_t *ring)
29+{
30+ int first = ring->first;
31+ int last = ring->last;
32+
33+ return (last >= first) ? last - first : ring->buffer_size - (first - last);
34+}
35+
36+
37+int ring_capacity(const ring_buffer_t *ring)
38+{
39+ return ring->buffer_size - 1;
40+}
41+
42+
43+static void byte_move(char *dest, const char *src, int n)
44+{
45+ const char *last_p = dest + n;
46+ while (dest < last_p) {
47+ *dest++ = *src++;
48+ }
49+}
50+
51+
52+int ring_write(ring_buffer_t *ring, const char *data, int size)
53+{
54+ int free_size = ring_capacity(ring) - ring_size(ring);
55+ int push_size = (size > free_size) ? free_size : size;
56+
57+ // データ配置
58+ if (ring->first <= ring->last) {
59+ // last から buffer_size 終端までに配置
60+ int left_size = 0;
61+ int to_end = ring->buffer_size - ring->last;
62+ int move_size = (to_end > push_size) ? push_size : to_end;
63+
64+ byte_move(&ring->buffer[ring->last], data, move_size);
65+ ring->last += move_size;
66+ ring->last &= (ring->buffer_size -1);
67+
68+ left_size = push_size - move_size;
69+ if (left_size > 0) {
70+ // 0 から first の前までを配置
71+ byte_move(ring->buffer, &data[move_size], left_size);
72+ ring->last = left_size;
73+ }
74+ } else {
75+ // last から first の前まで配置
76+ byte_move(&ring->buffer[ring->last], data, size);
77+ ring->last += push_size;
78+ }
79+ return push_size;
80+}
81+
82+
83+int ring_read(ring_buffer_t *ring, char *buffer, int size)
84+{
85+ // データ取得
86+ int now_size = ring_size(ring);
87+ int pop_size = (size > now_size) ? now_size : size;
88+
89+ if (ring->first <= ring->last) {
90+ byte_move(buffer, &ring->buffer[ring->first], pop_size);
91+ ring->first += pop_size;
92+
93+ } else {
94+ // first から buffer_size 終端までを配置
95+ int left_size = 0;
96+ int to_end = ring->buffer_size - ring->first;
97+ int move_size = (to_end > pop_size) ? pop_size : to_end;
98+ byte_move(buffer, &ring->buffer[ring->first], move_size);
99+
100+ ring->first += move_size;
101+ ring->first &= (ring->buffer_size -1);
102+
103+ left_size = pop_size - move_size;
104+ if (left_size > 0) {
105+ // 0 から last の前までを配置
106+ byte_move(&buffer[move_size], ring->buffer, left_size);
107+
108+ ring->first = left_size;
109+ }
110+ }
111+ return pop_size;
112+}
113+
114+
115+int ring_readPtr(ring_buffer_t *ring, char **ptr, int size)
116+{
117+ int diff;
118+ int readable_size;
119+ int read_size;
120+ int actual_size = ring_size(ring);
121+
122+ if (size < actual_size) {
123+ actual_size = size;
124+ }
125+
126+ *ptr = &ring->buffer[ring->first];
127+ diff = ring->last - ring->first;
128+ readable_size = (diff > 0) ? diff : ring->buffer_size - ring->first;
129+ read_size = (readable_size > actual_size) ? actual_size : readable_size;
130+
131+ ring->first += read_size;
132+ ring->first &= (ring->buffer_size -1);
133+
134+ return read_size;
135+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- trunk/libs/embedded_utils/ring_buffer.h (nonexistent)
+++ trunk/libs/embedded_utils/ring_buffer.h (revision 1840)
@@ -0,0 +1,86 @@
1+#ifndef RING_BUFFER_H
2+#define RING_BUFFER_H
3+
4+/*!
5+ \file
6+ \brief リングバッファ
7+
8+ \author Satofumi KAMIMURA
9+
10+ $Id$
11+*/
12+
13+
14+//! リングバッファの管理情報
15+typedef struct
16+{
17+ char *buffer; //!< バッファへのポインタ
18+ int buffer_size; //!< バッファサイズ
19+ int first; //!< バッファの先頭位置
20+ int last; //!< バッファの最終位置
21+} ring_buffer_t;
22+
23+
24+/*!
25+ \brief 初期化
26+
27+ \param[in] ring リングバッファの構造体
28+ \param[in] buffer 割り当てるバッファ
29+ \param[in] shift_length バッファサイズの 2 の乗数
30+*/
31+extern void ring_initialize(ring_buffer_t *ring,
32+ char *buffer, const int shift_length);
33+
34+
35+/*!
36+ \brief リングバッファのクリア
37+
38+ \param[in] ring リングバッファの構造体
39+*/
40+extern void ring_clear(ring_buffer_t *ring);
41+
42+
43+/*!
44+ \brief 格納データ数を返す
45+
46+ \param[in] ring リングバッファの構造体
47+*/
48+extern int ring_size(const ring_buffer_t *ring);
49+
50+
51+/*!
52+ \brief 最大の格納データ数を返す
53+
54+ \param[in] ring リングバッファの構造体
55+*/
56+extern int ring_capacity(const ring_buffer_t *ring);
57+
58+
59+/*!
60+ \brief データの格納
61+
62+ \param[in] ring リングバッファの構造体
63+ \param[in] data データ
64+ \param[in] size データサイズ
65+
66+ \return 格納したデータ数
67+*/
68+extern int ring_write(ring_buffer_t *ring, const char *data, int size);
69+
70+
71+/*!
72+ \brief データの取り出し
73+
74+ \param[in] ring リングバッファの構造体
75+ \param[out] buffer データ
76+ \param[in] size 最大のデータサイズ
77+
78+ \return 取り出したデータ数
79+*/
80+extern int ring_read(ring_buffer_t *ring, char *buffer, int size);
81+
82+
83+//! 内部ポインタから直に読み出しを行う
84+extern int ring_readPtr(ring_buffer_t *ring, char **ptr, int size);
85+
86+#endif /* ! RING_BUFFER_H */
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
旧リポジトリブラウザで表示