RobotsIO
Loading...
Searching...
No Matches
DatasetTransform.cpp
1/*
2 * Copyright (C) 2020 Istituto Italiano di Tecnologia (IIT)
3 *
4 * This software may be modified and distributed under the terms of the
5 * BSD 3-Clause license. See the accompanying LICENSE file for details.
6 */
7
8#include <RobotsIO/Utils/DatasetTransform.h>
9
10using namespace Eigen;
11using namespace RobotsIO::Utils;
12
13
14DatasetTransform::DatasetTransform
15(
16 const std::string& file_path,
17 const std::size_t& skip_rows,
18 const std::size_t& skip_cols,
19 const std::size_t& expected_cols,
20 const int rx_time_index,
21 const int tx_time_index
22) :
23 DatasetDataStream(file_path, skip_rows, skip_cols, expected_cols, rx_time_index, tx_time_index)
24{}
25
26
27DatasetTransform::~DatasetTransform()
28{}
29
30
31Eigen::Transform<double, 3, Eigen::Affine> DatasetTransform::transform()
32{
33 return transform_;
34}
35
36
37bool DatasetTransform::freeze(const bool blocking)
38{
39 if (!DatasetDataStream::freeze())
40 return false;
41
42 VectorXd transform_data = data();
43
44 bool invalid_pose = true;
45 for (std::size_t i = 0; i < transform_data.size(); i++)
46 invalid_pose &= (transform_data(i) == 0.0);
47 if (invalid_pose)
48 return false;
49
50 transform_ = Translation<double, 3>(transform_data.head<3>());
51 AngleAxisd rotation(transform_data(6), transform_data.segment<3>(3));
52 transform_.rotate(rotation);
53
54 return true;
55}