5 #ifndef SPIDAR_WIN32_DATA_LOGGER_HPP 6 #define SPIDAR_WIN32_DATA_LOGGER_HPP 26 template <
class T1,
class T2,
class T3>
50 if (!fout.is_open())
return false;
52 fout <<
"position x \t" <<
"position y \t" <<
"position z \t";
54 fout <<
"velocity x \t" <<
"velocity y \t" <<
"velocity z \t";
56 fout <<
"target Force x \t" <<
"target Force y \t" <<
"target Force z \t";
57 fout <<
"resultant Force x \t" <<
"resultant Force y \t" <<
"resultant Force z \t";
59 fout <<
"rotation x \t" <<
"rotation y \t" <<
"rotation z \t" <<
"rotation w \t";
60 fout <<
"angular velocity x \t" <<
"angular velocity y \t" <<
"angular velocity z \t";
62 fout <<
"target Torque x \t" <<
"target Torque y \t" <<
"target Torque z \t";
63 fout <<
"resultant Torque x \t" <<
"resultant Torque y \t" <<
"resultant Torque z \t";
65 for (
size_t i=0; i<8; ++i)
67 fout <<
"tension " << i <<
"\t";
75 if (!fout.is_open())
return false;
77 fout << position.x() <<
"\t" << position.y() <<
"\t" << position.z() <<
"\t";
78 fout << velocity.x() <<
"\t" << velocity.y() <<
"\t" << velocity.z() <<
"\t";
80 fout << targetForce.x() <<
"\t" << targetForce.y() <<
"\t" << targetForce.z() <<
"\t";
81 fout << resultantForce.x() <<
"\t" << resultantForce.y() <<
"\t" << resultantForce.z() <<
"\t";
83 fout << rotation.x <<
"\t" << rotation.y <<
"\t" << rotation.z <<
"\t" << rotation.w <<
"\t";
84 fout << angularVelocity.x() <<
"\t" << angularVelocity.y() <<
"\t" << angularVelocity.z() <<
"\t";
86 fout << targetTorque.x() <<
"\t" << targetTorque.y() <<
"\t" << targetTorque.z() <<
"\t";
87 fout << resultantTorque.x() <<
"\t" << resultantTorque.y() <<
"\t" << resultantTorque.z() <<
"\t";
89 for (
size_t i=0; i<8; ++i)
91 fout << tension[i] <<
"\t";
110 bool started(
void)
const {
return started_; }
113 void add(
const DataType& data);
114 void output(
const std::string& filename);
117 std::vector<LARGE_INTEGER> timeStamp_;
118 std::vector<DataType> logData_;
120 LARGE_INTEGER frequency_;
121 LARGE_INTEGER start_;
135 logData_.reserve(size);
136 timeStamp_.reserve(size);
138 ::QueryPerformanceFrequency(&frequency_);
152 ::QueryPerformanceCounter(&start_);
164 if (!started_ || busy_)
return;
167 ::QueryPerformanceCounter(&time);
169 timeStamp_.push_back(time);
170 logData_.push_back(data);
182 if (logData_.size()!=timeStamp_.size())
return;
186 fout.open(filename, std::ios::out);
189 fout <<
"time [ms]\t";
191 DataType::outputLabel(fout);
196 for (
size_t i=0; i<logData_.size(); ++i)
198 double time =
static_cast<double>(timeStamp_[i].QuadPart - start_.QuadPart) / frequency_.QuadPart * 1000.0;
200 fout << std::setprecision(10) << time <<
"\t";
202 logData_[i].outputData(fout);
215 #endif // SPIDAR_WIN32_DATA_LOGGER_HPP bool outputData(std::ofstream &fout)
ログデータを出力します.
VectorType velocity
速度 [m/s]
VectorType resultantForce
並進力の出力値 [N]
VectorType angularVelocity
角速度 [rad/s]
VectorType targetForce
並進力の目標値 [N]
void output(const std::string &filename)
ログデータをファイル出力します.
void add(const DataType &data)
ログデータを1件追加します.
static bool outputLabel(std::ofstream &fout)
ログデータのラベルを出力します.
ValueType tension[8]
ワイヤの張力 [N]
DataLogger(size_t size=10000)
コンストラクタ.
VectorType targetTorque
回転力の目標値 [Nm]
VectorType resultantTorque
回転力の出力値 [Nm]
QuaternionType rotation
回転
void start(void)
ログデータの受け入れを開始します.
VectorType position
位置 [m]