RobotsIO
Loading...
Searching...
No Matches
DatasetTransformDelayed.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/DatasetTransformDelayed.h>
9
10using namespace Eigen;
11using namespace RobotsIO::Utils;
12
13
14DatasetTransformDelayed::DatasetTransformDelayed
15(
16 const double& fps,
17 const double& simulated_fps,
18 const bool simulate_inference_time,
19 const std::string& file_path,
20 const std::size_t& skip_rows,
21 const std::size_t& skip_cols,
22 const std::size_t& expected_cols,
23 const int rx_time_index,
24 const int tx_time_index
25) :
26 DatasetDataStreamDelayed(fps, simulated_fps, simulate_inference_time, file_path, skip_rows, skip_cols, expected_cols, rx_time_index, tx_time_index),
27 fps_(fps),
28 simulated_fps_(simulated_fps)
29{}
30
31
32DatasetTransformDelayed::~DatasetTransformDelayed()
33{}
34
35
36Eigen::Transform<double, 3, Eigen::Affine> DatasetTransformDelayed::transform()
37{
38 return transform_;
39}
40
41
42bool DatasetTransformDelayed::freeze(const bool blocking)
43{
44 if (!DatasetDataStreamDelayed::freeze())
45 return false;
46
47 VectorXd transform_data = data();
48
49 bool invalid_pose = true;
50 for (std::size_t i = 0; i < transform_data.size(); i++)
51 invalid_pose &= (transform_data(i) == 0.0);
52 if (invalid_pose)
53 return false;
54
55 transform_ = Translation<double, 3>(transform_data.head<3>());
56 AngleAxisd rotation(transform_data(6), transform_data.segment<3>(3));
57 transform_.rotate(rotation);
58
59 return true;
60}
61
62
64{
65 return int(fps_ / simulated_fps_);
66}