• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1779 (tree)
日時2010-04-15 12:17:57
作者satofumi

ログメッセージ

ScipLineDecoder is implemented.

変更サマリ

差分

--- trunk/libs/range_sensor/c/samples/intensity_sample.c (revision 1778)
+++ trunk/libs/range_sensor/c/samples/intensity_sample.c (revision 1779)
@@ -30,7 +30,7 @@
3030 static void printData(urg_t *urg, urg_parameter_t *parameter,
3131 long data[], int data_size, long intensity[])
3232 {
33-#if 0
33+#if 1
3434 int timestamp = urg_recentTimestamp(urg);
3535
3636 /* Display the front data with timestamp */
@@ -44,8 +44,7 @@
4444 int i;
4545
4646 for (i = 0; i < data_size; ++i) {
47- //printf("%d: %ld [mm] (%ld)\n", i, data[i], intensity[i]);
48- printf("%d, %ld, %ld\n", i, data[i], intensity[i]);
47+ printf("%d: %ld [mm] (%ld)\n", i, data[i], intensity[i]);
4948 }
5049 #endif
5150 }
--- trunk/libs/range_sensor/samples/urgsScan.cpp (revision 1778)
+++ trunk/libs/range_sensor/samples/urgsScan.cpp (revision 1779)
@@ -10,8 +10,8 @@
1010 #include "UrgDevice.h"
1111 #include "Thread.h"
1212 #include "delay.h"
13+#include <iostream>
1314 #include <cstdlib>
14-#include <cstdio>
1515
1616 using namespace qrk;
1717 using namespace std;
@@ -23,7 +23,7 @@
2323
2424 const char* device = static_cast<const char*>(args);
2525 if (! urg.connect(device)) {
26- printf("UrgDevice::connect: %s\n", urg.what());
26+ cout << "UrgDevice::connect: " << urg.what() << endl;
2727 exit(1);
2828 }
2929
@@ -32,7 +32,7 @@
3232 for (int i = 0; i < CaptureTimes; ++i) {
3333 data.clear();
3434 if (urg.capture(data)) {
35- printf("%s: n = %d\n", device, data.size());
35+ cout << device << ": n = " << data.size() << endl;
3636 }
3737 delay(1);
3838 }
--- trunk/programs/ScipDecoder/main.cpp (revision 1778)
+++ trunk/programs/ScipDecoder/main.cpp (nonexistent)
@@ -1,20 +0,0 @@
1-/*!
2- \file
3- \brief 入力した SCIP 文字列を数値に変更するツール
4-
5- \author Satofumi KAMIMURA
6-
7- $Id$
8-*/
9-
10-#include <QApplication>
11-
12-
13-int main(int argc, char *argv[])
14-{
15- QApplication app(argc, argv);
16-
17- // !!!
18-
19- return app.exec();
20-}
Deleted: svn:keywords
## -1 +0,0 ##
-Id
\ No newline at end of property
--- trunk/programs/ScipLineDecoder/InputWidget.cpp (nonexistent)
+++ trunk/programs/ScipLineDecoder/InputWidget.cpp (revision 1779)
@@ -0,0 +1,80 @@
1+/*!
2+ \file
3+ \brief SCIP 文字列を入力し、結果を表示するフォーム
4+
5+ \author Satofumi KAMIMURA
6+
7+ $Id$
8+*/
9+
10+#include "InputWidget.h"
11+#include <QShortcut>
12+#include <string>
13+
14+using namespace std;
15+
16+
17+namespace
18+{
19+ long decode(const char* data, size_t size)
20+ {
21+ const char* p = data;
22+ const char* last_p = p + size;
23+
24+ int value = 0;
25+ while (p < last_p) {
26+ value <<= 6;
27+ value &= ~0x3f;
28+ value |= *p++ - 0x30;
29+ }
30+ return value;
31+ }
32+}
33+
34+
35+struct InputWidget::pImpl
36+{
37+ InputWidget* widget_;
38+
39+
40+ pImpl(InputWidget* widget) : widget_(widget)
41+ {
42+ }
43+
44+
45+ void initializeForm(void)
46+ {
47+ // イベント割り付け
48+ connect(widget_->input_lineedit_, SIGNAL(textChanged(const QString&)),
49+ widget_, SLOT(inputChanged(const QString&)));
50+
51+ // ショートカット割り付け
52+ (void) new QShortcut(Qt::CTRL + Qt::Key_Q, widget_, SLOT(close()));
53+ }
54+};
55+
56+
57+InputWidget::InputWidget(QWidget* parent)
58+ : QWidget(parent), pimpl(new pImpl(this))
59+{
60+ setupUi(this);
61+ pimpl->initializeForm();
62+}
63+
64+
65+InputWidget::~InputWidget(void)
66+{
67+}
68+
69+
70+void InputWidget::inputChanged(const QString& text)
71+{
72+ if (text.isEmpty()) {
73+ result_lineedit_->clear();
74+ return;
75+ }
76+
77+ string string_text = text.toStdString();
78+ long value = decode(string_text.c_str(), string_text.size());
79+ result_lineedit_->setText(QString("%1").arg(value));
80+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- trunk/programs/ScipLineDecoder/main.cpp (nonexistent)
+++ trunk/programs/ScipLineDecoder/main.cpp (revision 1779)
@@ -0,0 +1,22 @@
1+/*!
2+ \file
3+ \brief 入力した SCIP 文字列を数値に変更するツール
4+
5+ \author Satofumi KAMIMURA
6+
7+ $Id$
8+*/
9+
10+#include "InputWidget.h"
11+#include <QApplication>
12+
13+
14+int main(int argc, char *argv[])
15+{
16+ QApplication app(argc, argv);
17+
18+ InputWidget widget;
19+ widget.show();
20+
21+ return app.exec();
22+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- trunk/programs/ScipLineDecoder/InputWidget.h (nonexistent)
+++ trunk/programs/ScipLineDecoder/InputWidget.h (revision 1779)
@@ -0,0 +1,36 @@
1+#ifndef INPUT_WIDGET_H
2+#define INPUT_WIDGET_H
3+
4+/*!
5+ \file
6+ \brief SCIP 文字列を入力し、結果を表示するフォーム
7+
8+ \author Satofumi KAMIMURA
9+
10+ $Id$
11+*/
12+
13+#include "ui_InputWidgetForm.h"
14+#include <memory>
15+
16+
17+class InputWidget : public QWidget, private Ui::InputWidgetForm
18+{
19+ Q_OBJECT;
20+
21+public:
22+ InputWidget(QWidget* parent = 0);
23+ ~InputWidget(void);
24+
25+private slots:
26+ void inputChanged(const QString& text);
27+
28+private:
29+ InputWidget(const InputWidget& rhs);
30+ InputWidget& operator = (const InputWidget& rhs);
31+
32+ struct pImpl;
33+ std::auto_ptr<pImpl> pimpl;
34+};
35+
36+#endif /* !INPUT_WIDGET_H */
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
旧リポジトリブラウザで表示