14 #ifndef _DS3D_DATALOADER_LIDARSOURCE_CONFIG_H
15 #define _DS3D_DATALOADER_LIDARSOURCE_CONFIG_H
23 #define _PATH_MAX 4096
25 namespace ds3d {
namespace impl {
namespace lidarsource {
44 std::vector<std::deque<std::map<uint64_t, std::string>>>
dataParas;
55 if(dataType ==
"FP32") {
58 LOG_WARNING(
"unsupported datatype: %s, fallback to FP32", dataType.c_str());
67 std::map<uint64_t, std::string> dataParas;
68 std::deque<std::map<uint64_t, std::string>> dataParasQueue;
69 YAML::Node node = YAML::LoadFile(config.
realPath);
70 const YAML::Node& listNode = node[
"source-list"];
71 uint64_t timestampPrev = 0;
72 for (std::size_t i = 0; i < listNode.size(); i++) {
73 const YAML::Node& kvs = listNode[i];
74 for (
const auto& kv : kvs) {
75 uint64_t timestamp = kv.first.as<uint64_t>();
76 std::string filename = kv.second.as<std::string>();
77 std::string absFilepath =
"";
78 if (filename[0] ==
'/') {
79 absFilepath = filename;
81 int pos = config.
realPath.find_last_of(
"/");
82 std::string tmpPath = config.
realPath.substr(0, pos+1);
83 tmpPath = tmpPath + filename;
84 if (!realpath(tmpPath.c_str(), absRealFilePath)) {
85 if (errno != ENOENT) {
90 absFilepath = absRealFilePath;
91 LOG_DEBUG(
"lidar data path %s",absFilepath.c_str());
93 dataParas[timestamp] = absFilepath;
97 dataParasQueue.push_back(dataParas);
100 config.
dataParas.push_back(dataParasQueue);
102 if (listNode.size() > 1) {
117 "parse lidarsource component content failed");
121 if (node[
"data_config_file"]) {
122 auto lidarDataNode = node[
"data_config_file"];
123 std::vector<std::string> lidarDataPaths;
124 if (lidarDataNode.IsSequence()) {
125 lidarDataPaths = lidarDataNode.as<std::vector<std::string>>();
128 lidarDataPaths.resize(1);
129 lidarDataPaths[0] = lidarDataNode.as<std::string>();
131 for (
const auto& item : lidarDataPaths) {
137 if (!realpath(path.c_str(), absRealFilePath)) {
138 if (errno != ENOENT) {
139 LOG_WARNING(
"Your config file path is not right!");
144 int pos = config.
realPath.find_last_of(
"/");
145 std::string tmpPath = config.
realPath.substr(0, pos+1);
153 if (node[
"mem_type"]) {
154 auto strType = node[
"mem_type"].as<std::string>();
155 if (strncasecmp(strType.c_str(),
"cpu", strType.size()) == 0) {
157 }
else if (strncasecmp(strType.c_str(),
"gpu", strType.size()) == 0) {
161 "unknown mem_type: %s in lidar_file_source config parsing", strType.c_str());
164 if (node[
"gpu_id"]) {
165 config.
gpuId = node[
"gpu_id"].as<int32_t>();
167 if (node[
"fixed_points_num"]) {
170 if (node[
"mem_pool_size"]) {
171 config.
memPoolSize = node[
"mem_pool_size"].as<uint32_t>();
173 if (node[
"data_type"]) {
174 std::string dataType = node[
"data_type"].as<std::string>();
177 if (node[
"points_num"]) {
178 config.
pointNums = node[
"points_num"].as<uint32_t>();
180 if (node[
"element_stride"]) {
181 config.
elementStride = node[
"element_stride"].as<uint32_t>();
183 if (node[
"element_size"]) {
184 config.
elementSize = node[
"element_size"].as<uint32_t>();
186 if (node[
"output_datamap_key"]) {
187 auto keyNode = node[
"output_datamap_key"];
188 if (keyNode.IsSequence()) {
189 config.
datamapKey = keyNode.as<std::vector<std::string>>();
192 config.
datamapKey[0] = keyNode.as<std::string>();
195 if (node[
"file_loop"]) {
196 config.
fileLoop = node[
"file_loop"].as<
bool>();
199 if (node[
"source_id"]) {
200 config.
sourceId = node[
"source_id"].as<uint32_t>();
209 "lidar data config element_size: %d must be [3, 4].", config.
elementSize);
217 #endif // _DS3D_DATALOADER_LIDARSOURCE_CONFIG_H