RobotsIO
Loading...
Searching...
No Matches
DatasetSpatialVelocity.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/DatasetSpatialVelocity.h>
9
10using namespace Eigen;
11using namespace RobotsIO::Utils;
12
13
14DatasetSpatialVelocity::DatasetSpatialVelocity(const std::string& file_path, const std::size_t& skip_rows, const std::size_t& skip_cols, const std::size_t& expected_cols, const int rx_time_index, const int tx_time_index) :
15 DatasetDataStream(file_path, skip_rows, skip_cols, expected_cols, rx_time_index, tx_time_index)
16{}
17
18
19DatasetSpatialVelocity::~DatasetSpatialVelocity()
20{}
21
22
23double DatasetSpatialVelocity::elapsed_time()
24{
25 return elapsed_time_;
26}
27
28
29VectorXd DatasetSpatialVelocity::twist()
30{
31 return twist_;
32}
33
34
35bool DatasetSpatialVelocity::freeze(const bool blocking)
36{
37 if (!DatasetDataStream::freeze())
38 return false;
39
40 /* Twist data. */
41 twist_ = data();
42
43 /* Elapsed time. */
44 double rx_time = DatasetDataStream::rx_time();
45 elapsed_time_ = 0.0;
46 if (last_time_initialized_)
47 elapsed_time_ = rx_time - last_time_;
48 last_time_ = rx_time;
49 last_time_initialized_ = true;
50
51 return true;
52}