42 template <
bool QUAT_REPR = true,
bool TUM_FORMAT = true>
45 std::vector<std::string> curr_tokens;
49 curr_tokens.size() == 7,
51 "Invalid number of tokens in given string\n" 53 "\tTokens size: %" USIZE_STR
"\n",
57 quat.
r(atof(curr_tokens[6].c_str()));
58 quat.
x(atof(curr_tokens[3].c_str()));
59 quat.
y(atof(curr_tokens[4].c_str()));
60 quat.
z(atof(curr_tokens[5].c_str()));
65 atof(curr_tokens[0].c_str()),
66 atof(curr_tokens[1].c_str()),
67 atof(curr_tokens[2].c_str()),
83 THROW_EXCEPTION(
"Invalid combination: QUAT_REPR=false, TUM_FORMAT=true");
133 template <
class POSE_T>
135 const std::string& fname, std::vector<POSE_T>* poses_vec,
136 std::vector<mrpt::system::TTimeStamp>* timestamps = NULL,
137 bool substract_init_offset =
false)
144 using namespace internal;
149 "\nFile %s was not found.\n" 150 "Either specify a valid filename or set set the " 151 "m_visualize_GT flag to false\n",
156 file_GT.fileOpenCorrectly(),
157 "\nreadGTFileRGBD_TUM: Couldn't openGT file\n");
158 ASSERTMSG_(poses_vec,
"std::vector<POSE_T>* is not valid.");
163 for (
size_t i = 0; file_GT.readLine(curr_line); i++)
165 if (curr_line.at(0) !=
'#')
172 POSE_T pose_offset_opposite;
173 if (substract_init_offset)
178 curr_line.begin() + curr_line.find_first_of(
" \t") + 1,
181 pose_offset_opposite = pose_offset.getOppositeScalar();
185 for (; file_GT.readLine(curr_line);)
192 curr_line.begin() + curr_line.find_first_of(
" \t"));
193 timestamps->push_back(atof(timestamp_str.c_str()));
199 curr_line.begin() + curr_line.find_first_of(
" \t") + 1,
204 if (substract_init_offset)
206 curr_pose.addComponents(pose_offset_opposite);
210 poses_vec->push_back(curr_pose);
#define THROW_EXCEPTION(msg)
T y() const
Return y coordinate of the quaternion.
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
void fromStringRaw(const std::string &s)
Same as fromString, but without requiring the square brackets in the string.
void tokenize(const std::string &inString, const std::string &inDelimiters, OUT_CONTAINER &outTokens, bool skipBlankTokens=true) noexcept
Tokenizes a string according to a set of delimiting characters.
T r() const
Return r coordinate of the quaternion.
void readFileWithPoses(const std::string &fname, std::vector< POSE_T > *poses_vec, std::vector< mrpt::system::TTimeStamp > *timestamps=NULL, bool substract_init_offset=false)
Parse the textfile and fill in the corresponding poses vector.
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
mrpt::io::CFileInputStream CFileInputStream
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
GLsizei const GLchar ** string
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void getPoseFromString< false, true >(const std::string &s, mrpt::poses::CPose3D &p)
Invalid form.
T x() const
Return x coordinate of the quaternion.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
void getPoseFromString(const std::string &s, mrpt::poses::CPose2D &p)
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
T z() const
Return z coordinate of the quaternion.
void rpy(T &roll, T &pitch, T &yaw) const
Return the yaw, pitch & roll angles associated to quaternion.