mars_lib  0.1.0.3dc76ee85e09
Modular and Robust Sensor-Fusion
read_gps_w_vel_data.h
Go to the documentation of this file.
1 // Copyright (C) 2021 Christian Brommer, Control of Networked Systems, University of Klagenfurt, Austria.
2 //
3 // All rights reserved.
4 //
5 // This software is licensed under the terms of the BSD-2-Clause-License with
6 // no commercial use allowed, the full terms of which are made available
7 // in the LICENSE file. No license in patents is granted.
8 //
9 // You can contact the author at <christian.brommer@ieee.org>
10 
11 #ifndef READ_GPS_W_VEL_DATA_H
12 #define READ_GPS_W_VEL_DATA_H
13 
16 #include <mars/time.h>
19 #include <Eigen/Dense>
20 #include <vector>
21 
22 namespace mars
23 {
25 {
26 public:
27  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
28 
29  ReadGpsWithVelData(std::vector<BufferEntryType>* data_out, std::shared_ptr<SensorAbsClass> sensor,
30  const std::string& file_path, const double& time_offset = 0)
31  {
32  std::vector<std::string> expect_entry = { "t", "lat", "long", "alt", "v_x", "v_y", "v_z" };
33 
34  CsvDataType csv_data;
35  ReadCsv(&csv_data, file_path);
36 
37  unsigned long number_of_datapoints = csv_data["t"].size();
38  data_out->resize(number_of_datapoints);
39 
40  for (size_t k = 0; k < number_of_datapoints; k++)
41  {
42  Time time = csv_data["t"][k] + time_offset;
43 
44  BufferDataType data;
45  data.set_measurement(std::make_shared<GpsVelMeasurementType>(csv_data["lat"][k], csv_data["long"][k],
46  csv_data["alt"][k], csv_data["v_x"][k],
47  csv_data["v_y"][k], csv_data["v_z"][k]));
48 
49  BufferEntryType current_entry(time, data, sensor);
50  data_out->at(k) = current_entry;
51  }
52  }
53 };
54 } // namespace mars
55 
56 #endif // READ_GPS_W_VEL_DATA_H
The BufferDataType binds the core and sensor state in form of a shared void pointer.
Definition: buffer_data_type.h:36
void set_measurement(std::shared_ptr< void > meas)
Definition: buffer_data_type.h:75
Definition: buffer_entry_type.h:41
Definition: read_csv.h:30
Definition: read_gps_w_vel_data.h:25
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ReadGpsWithVelData(std::vector< BufferEntryType > *data_out, std::shared_ptr< SensorAbsClass > sensor, const std::string &file_path, const double &time_offset=0)
Definition: read_gps_w_vel_data.h:29
Definition: time.h:20
Definition: buffer.h:27
std::map< std::string, std::vector< double > > CsvDataType
Definition: read_csv.h:26