• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1990 (tree)
日時2012-05-18 09:36:04
作者satofumi

ログメッセージ

added recording pc_timestamp function

変更サマリ

差分

--- trunk/programs/UrgRecorder/UrgRecorderWidget.cpp (revision 1989)
+++ trunk/programs/UrgRecorder/UrgRecorderWidget.cpp (revision 1990)
@@ -23,6 +23,7 @@
2323 #include <QMessageBox>
2424 #include <QShortcut>
2525 #include <QSettings>
26+#include <fstream>
2627
2728 using namespace qrk;
2829 using namespace std;
@@ -31,7 +32,9 @@
3132 #define snprintf _snprintf
3233 #endif
3334
35+//#define SAVE_WITH_TIMESTAMP
3436
37+
3538 namespace
3639 {
3740 const char* Organization = "Hokuyo LTD.";
@@ -66,11 +69,15 @@
6669 bool intensity_mode_;
6770 bool is_using_serial_;
6871
72+ ofstream* timestamp_out_;
73+ QDateTime first_time_;
6974
75+
7076 pImpl(UrgRecorderWidget* widget)
7177 : widget_(widget), serial_connection_(NULL),
7278 capture_max_(1), total_times_(0), is_raw_record_(false),
73- intensity_mode_(false), is_using_serial_(true)
79+ intensity_mode_(false), is_using_serial_(true),
80+ timestamp_out_(NULL)
7481 {
7582 urg_finder_.addBaseName("/dev/ttyACM");
7683 urg_finder_.addBaseName("/dev/tty.usbmodem");
@@ -210,6 +217,16 @@
210217 } else {
211218 urg_.setCaptureMode(AutoCapture);
212219 }
220+
221+#if defined(SAVE_WITH_TIMESTAMP)
222+ string pc_timestamp_file =
223+ save_directory_.toStdString() + "/pc_timestamp.txt";
224+ timestamp_out_ = new ofstream(pc_timestamp_file.c_str());
225+
226+ first_time_ = QDateTime::currentDateTime();
227+ urg_.setTimestamp(0);
228+#endif
229+
213230 capture_timer_.setInterval(urg_.scanMsec() / 2);
214231 capture_timer_.start();
215232 }
@@ -219,12 +236,13 @@
219236 {
220237 vector<long> data;
221238 vector<long> intensity_data;
239+ long timestamp;
222240
223241 int n;
224242 if (intensity_mode_) {
225- n = urg_.captureWithIntensity(data, intensity_data);
243+ n = urg_.captureWithIntensity(data, intensity_data, &timestamp);
226244 } else {
227- n = urg_.capture(data);
245+ n = urg_.capture(data, &timestamp);
228246 }
229247
230248 if (n <= 0) {
@@ -232,8 +250,14 @@
232250 }
233251 ++total_times_;
234252
253+ // タイムスタンプの記録
254+#if defined(SAVE_WITH_TIMESTAMP)
255+ QDateTime current_pc_timestamp = first_time_.addMSecs(timestamp);
256+ *timestamp_out_ << current_pc_timestamp.
257+ toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString() << endl;
258+#endif
259+
235260 if (! is_raw_record_) {
236-
237261 // ファイルへのデータ書き出し
238262 char buffer[] = "/data_xxxxxxxxxx.csv";
239263 snprintf(buffer, sizeof(buffer), "/data_%09d.csv", total_times_);
@@ -262,6 +286,11 @@
262286
263287 urg_.stop();
264288
289+#if defined(SAVE_WITH_TIMESTAMP)
290+ delete timestamp_out_;
291+ timestamp_out_ = NULL;
292+#endif
293+
265294 if (is_raw_record_) {
266295 Connection* connection = urg_.connection();
267296 if (connection != serial_connection_) {
旧リポジトリブラウザで表示