| 194 | } |
| 195 | |
| 196 | void load_CSV_pose_with_time( |
| 197 | const std::string &file_path, std::vector<int> &index_vec, |
| 198 | std::vector<std::pair<Eigen::Vector3d, Eigen::Matrix3d>> &poses_vec, |
| 199 | std::vector<std::string> ×_vec) { |
| 200 | std::ifstream fp(file_path); |
| 201 | std::string line; |
| 202 | std::getline(fp, line); // get ride of the first line |
| 203 | Eigen::Matrix<double, 1, 7> temp_matrix; |
| 204 | |
| 205 | while (std::getline(fp, line)) { |
| 206 | std::stringstream sin(line); |
| 207 | std::string info; |
| 208 | int number = 0; |
| 209 | while (std::getline(sin, info, ',')) { |
| 210 | if (number == 0) { |
| 211 | int index; |
| 212 | std::stringstream data; |
| 213 | data << info; |
| 214 | data >> index; |
| 215 | index_vec.push_back(index); |
| 216 | number++; |
| 217 | } else if (number == 1) { |
| 218 | std::string time; |
| 219 | std::stringstream data; |
| 220 | data << info; |
| 221 | data >> time; |
| 222 | times_vec.push_back(time); |
| 223 | number++; |
| 224 | } else { |
| 225 | double p; |
| 226 | std::stringstream data; |
| 227 | data << info; |
| 228 | data >> p; |
| 229 | temp_matrix[number - 2] = p; |
| 230 | if (number == 8) { |
| 231 | Eigen::Vector3d translation(temp_matrix[0], temp_matrix[1], |
| 232 | temp_matrix[2]); |
| 233 | Eigen::Quaterniond q(temp_matrix[6], temp_matrix[3], temp_matrix[4], |
| 234 | temp_matrix[5]); |
| 235 | std::pair<Eigen::Vector3d, Eigen::Matrix3d> single_pose; |
| 236 | single_pose.first = translation; |
| 237 | single_pose.second = q.toRotationMatrix(); |
| 238 | poses_vec.push_back(single_pose); |
| 239 | } |
| 240 | number++; |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | double time_inc(std::chrono::_V2::system_clock::time_point &t_end, |
| 247 | std::chrono::_V2::system_clock::time_point &t_begin) { |