47#include "../include/PoseTraces.h"
57 std::getline(stream, line);
59 std::regex re_header(
"\\s*X\\s*,\\s*Y\\s*,\\s*Z\\s*,\\s*Yaw\\s*,\\s*Pitch\\s*,\\s*Roll\\s*");
60 if (!std::regex_match(line, re_header)) {
61 throw std::runtime_error(
"Format error in the pose trace header");
65 std::regex re_row(
"([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)");
66 std::regex re_empty(
"\\s*");
67 bool trailing_empty_lines =
false;
69 while (std::getline(stream, line)) {
71 if (!trailing_empty_lines && std::regex_match(line, match, re_row)) {
74 std::stof(match[1].str()),
75 std::stof(match[2].str()),
76 std::stof(match[3].str())),
78 std::stof(match[4].str()),
79 std::stof(match[5].str()),
80 std::stof(match[6].str()))
83 else if (std::regex_match(line, re_empty)) {
84 trailing_empty_lines =
true;
87 throw std::runtime_error(
"Format error in a pose trace row");
96 std::ifstream stream(filename);
98 throw std::runtime_error(
"Failed to load pose trace");
static PoseTrace loadFrom(std::istream &stream)
static PoseTrace loadFromFile(std::string const &filename)