RobotsIO
Loading...
Searching...
No Matches
DatasetDataStreamDelayed.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/DatasetDataStreamDelayed.h>
9
10using namespace Eigen;
11using namespace RobotsIO::Utils;
12
13
14DatasetDataStreamDelayed::DatasetDataStreamDelayed
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 DatasetDataStream(file_path, skip_rows, skip_cols, expected_cols, rx_time_index, tx_time_index),
27 delay_(static_cast<int>(fps / simulated_fps)),
28 simulate_inference_time_(simulate_inference_time)
29{
30 if (simulate_inference_time_)
31 set_head(get_head() - delay_ + skip_rows);
32}
33
34
35DatasetDataStreamDelayed::~DatasetDataStreamDelayed()
36{}
37
38
39VectorXd DatasetDataStreamDelayed::data()
40{
41 int head = get_head();
42
43 if (simulate_inference_time_)
44 {
45 if (head < 0)
46 head = 0;
47 }
48
49 return DatasetDataStream::data(head);
50}
51
52
53bool DatasetDataStreamDelayed::freeze()
54{
55 DatasetDataStream::freeze();
56
57 if ((get_head() % delay_) != 0)
58 return false;
59
60 return true;
61}