Common
common packages for kyubic
 
Loading...
Searching...
No Matches
path_csv_loader.hpp
Go to the documentation of this file.
1
10#ifndef _PATH_CSV_PARSER_HPP
11#define _PATH_CSV_PARSER_HPP
12
13#include <array>
14#include <cstddef>
15#include <iomanip>
16#include <iostream>
17#include <memory>
18#include <string>
19#include <vector>
20
21namespace planner
22{
23
25{
26public:
28 bool catmull_rom = false;
29 size_t catmull_end_row = 0;
32 bool catmull_orient_LERP = false;
33 int timeout_sec = 0;
34
35 void print() const
36 {
37 std::cout << " checkpoint_end_row: " << checkpoint_end_row << std::endl;
38 std::cout << " catmull_rom: " << catmull_rom << std::endl;
39 std::cout << " catmull_end_row: " << catmull_end_row << std::endl;
40 std::cout << " catmull_density: " << catmull_density << std::endl;
41 std::cout << " catmull_min_distance: " << catmull_density << std::endl;
42 std::cout << " catmull_orient_LERP: " << catmull_orient_LERP << std::endl;
43 std::cout << " timeout_sec: " << timeout_sec << std::endl;
44 std::cout << std::endl;
45 }
46};
47
53{
54public:
55 double x;
56 double y;
57 double z;
58 int z_mode;
59 double roll;
60 double yaw;
61 double wait_ms;
62 bool fine;
63
65 const double x, const double y, const double z, const int z_mode, const double roll,
66 const double yaw, const double wait_ms, const bool fine = false)
67 : x(x), y(y), z(z), z_mode(z_mode), roll(roll), yaw(yaw), wait_ms(wait_ms), fine(fine)
68 {
69 }
70
71 void print() const
72 {
73 std::cout << " x:" << std::right << std::setw(7) << std::fixed << std::setprecision(2) << x;
74 std::cout << " y:" << std::right << std::setw(7) << std::fixed << std::setprecision(2) << y;
75 std::cout << " z:" << std::right << std::setw(7) << std::fixed << std::setprecision(2) << z;
76 std::cout << " z_mode:" << std::right << std::setw(2) << z_mode;
77 std::cout << " roll:" << std::right << std::setw(8) << std::fixed << std::setprecision(2)
78 << roll;
79 std::cout << " yaw:" << std::right << std::setw(8) << std::fixed << std::setprecision(2)
80 << yaw;
81 std::cout << " wait_ms:" << std::right << std::setw(8) << std::fixed << std::setprecision(0)
82 << wait_ms;
83 std::cout << " fine:" << std::right << std::setw(6) << (fine ? "true" : "false");
84 std::cout << std::endl;
85 }
86};
87
88const size_t NUM_CSV_COLUMNS = 19;
89const std::array<std::string, NUM_CSV_COLUMNS> csv_header = {
90 "parameter_label",
91 "value",
92 "x",
93 "y",
94 "z",
95 "z_mode",
96 "roll",
97 "yaw",
98 "wait_ms",
99 "fine",
100 "blank",
101 "catmull_x",
102 "catmull_y",
103 "catmull_z",
104 "catmull_z_mode",
105 "catmull_roll",
106 "catmull_yaw",
107 "catmull_wait_ms",
108 "catmull_fine",
109};
110
116{
117private:
118 std::array<std::string, NUM_CSV_COLUMNS> header = csv_header;
119 ParamData params_;
120 std::vector<PoseData> checkpoints_;
121 std::vector<PoseData> catmulls_;
122
123 // CsvParserからのみ内部データへのアクセスを許可
124 friend class PathCsvLoader;
125
126public:
127 const ParamData & get_params() const { return params_; }
128 const std::vector<PoseData> & get_checkpoints() const { return checkpoints_; }
129 const std::vector<PoseData> & get_catmulls() const { return catmulls_; }
130};
131
137{
138private:
139 std::shared_ptr<PathData> data_;
140
141 // helper
142 double stod_strict(const std::string & s, const std::string & context);
143 int stoi_strict(const std::string & s, const std::string & context);
144 bool stob_strict(const std::string & s, const std::string & context);
145
146 bool is_allNonEmpty(std::vector<std::string> vec);
147
148public:
149 explicit PathCsvLoader();
150
155 void parse(const std::string & csv_path);
156
161 const std::shared_ptr<PathData> get_data() const { return data_; }
162};
163
164} // namespace planner
165
166#endif
Definition: path_csv_loader.hpp:25
bool catmull_orient_LERP
Definition: path_csv_loader.hpp:32
size_t checkpoint_end_row
Definition: path_csv_loader.hpp:27
void print() const
Definition: path_csv_loader.hpp:35
int timeout_sec
Definition: path_csv_loader.hpp:33
bool catmull_rom
Definition: path_csv_loader.hpp:28
size_t catmull_end_row
Definition: path_csv_loader.hpp:29
int catmull_density
Definition: path_csv_loader.hpp:30
double catmull_min_distance
Definition: path_csv_loader.hpp:31
load and parse csv file with path
Definition: path_csv_loader.hpp:137
PathCsvLoader()
Definition: path_csv_loader.cpp:22
const std::shared_ptr< PathData > get_data() const
パースしたデータを取得する
Definition: path_csv_loader.hpp:161
void parse(const std::string &csv_path)
CSVファイルをパースする
Definition: path_csv_loader.cpp:65
Definition: path_csv_loader.hpp:116
const std::vector< PoseData > & get_catmulls() const
Definition: path_csv_loader.hpp:129
const std::vector< PoseData > & get_checkpoints() const
Definition: path_csv_loader.hpp:128
const ParamData & get_params() const
Definition: path_csv_loader.hpp:127
Definition: path_csv_loader.hpp:53
double z
Definition: path_csv_loader.hpp:57
bool fine
Definition: path_csv_loader.hpp:62
PoseData(const double x, const double y, const double z, const int z_mode, const double roll, const double yaw, const double wait_ms, const bool fine=false)
Definition: path_csv_loader.hpp:64
double y
Definition: path_csv_loader.hpp:56
double x
Definition: path_csv_loader.hpp:55
double yaw
Definition: path_csv_loader.hpp:60
int z_mode
Definition: path_csv_loader.hpp:58
double roll
Definition: path_csv_loader.hpp:59
void print() const
Definition: path_csv_loader.hpp:71
double wait_ms
Definition: path_csv_loader.hpp:61
Definition: path_csv_loader.hpp:22
const size_t NUM_CSV_COLUMNS
Definition: path_csv_loader.hpp:88
const std::array< std::string, NUM_CSV_COLUMNS > csv_header
Definition: path_csv_loader.hpp:89