18 #ifndef _DS3D_DATALOADER_LIDARSOURCE_CONFIG_H
19 #define _DS3D_DATALOADER_LIDARSOURCE_CONFIG_H
21 #include <ds3d/common/common.h>
22 #include <ds3d/common/func_utils.h>
24 #include "ds3d/common/hpp/yaml_config.hpp"
25 #include "ds3d/common/idatatype.h"
27 #define _PATH_MAX 4096
29 namespace ds3d {
namespace impl {
namespace lidarsource {
48 std::vector<std::deque<std::map<uint64_t, std::string>>>
dataParas;
59 if(dataType ==
"FP32") {
62 LOG_WARNING(
"unsupported datatype: %s, fallback to FP32", dataType.c_str());
71 std::map<uint64_t, std::string> dataParas;
72 std::deque<std::map<uint64_t, std::string>> dataParasQueue;
73 YAML::Node node = YAML::LoadFile(config.
realPath);
74 const YAML::Node& listNode = node[
"source-list"];
75 uint64_t timestampPrev = 0;
76 for (std::size_t i = 0; i < listNode.size(); i++) {
77 const YAML::Node& kvs = listNode[i];
78 for (
const auto& kv : kvs) {
79 uint64_t timestamp = kv.first.as<uint64_t>();
80 std::string filename = kv.second.as<std::string>();
81 std::string absFilepath =
"";
82 if (filename[0] ==
'/') {
83 absFilepath = filename;
85 int pos = config.
realPath.find_last_of(
"/");
86 std::string tmpPath = config.
realPath.substr(0, pos+1);
87 tmpPath = tmpPath + filename;
88 if (!realpath(tmpPath.c_str(), absRealFilePath)) {
89 if (errno != ENOENT) {
94 absFilepath = absRealFilePath;
95 LOG_DEBUG(
"lidar data path %s",absFilepath.c_str());
97 dataParas[timestamp] = absFilepath;
101 dataParasQueue.push_back(dataParas);
104 config.
dataParas.push_back(dataParasQueue);
106 if (listNode.size() > 1) {
121 "parse lidarsource component content failed");
125 if (node[
"data_config_file"]) {
126 auto lidarDataNode = node[
"data_config_file"];
127 std::vector<std::string> lidarDataPaths;
128 if (lidarDataNode.IsSequence()) {
129 lidarDataPaths = lidarDataNode.as<std::vector<std::string>>();
132 lidarDataPaths.resize(1);
133 lidarDataPaths[0] = lidarDataNode.as<std::string>();
135 for (
const auto& item : lidarDataPaths) {
141 if (!realpath(path.c_str(), absRealFilePath)) {
142 if (errno != ENOENT) {
143 LOG_WARNING(
"Your config file path is not right!");
148 int pos = config.
realPath.find_last_of(
"/");
149 std::string tmpPath = config.
realPath.substr(0, pos+1);
157 if (node[
"mem_type"]) {
158 auto strType = node[
"mem_type"].as<std::string>();
159 if (strncasecmp(strType.c_str(),
"cpu", strType.size()) == 0) {
161 }
else if (strncasecmp(strType.c_str(),
"gpu", strType.size()) == 0) {
165 "unknown mem_type: %s in lidar_file_source config parsing", strType.c_str());
168 if (node[
"gpu_id"]) {
169 config.
gpuId = node[
"gpu_id"].as<int32_t>();
171 if (node[
"fixed_points_num"]) {
174 if (node[
"mem_pool_size"]) {
175 config.
memPoolSize = node[
"mem_pool_size"].as<uint32_t>();
177 if (node[
"data_type"]) {
178 std::string dataType = node[
"data_type"].as<std::string>();
181 if (node[
"points_num"]) {
182 config.
pointNums = node[
"points_num"].as<uint32_t>();
184 if (node[
"element_stride"]) {
185 config.
elementStride = node[
"element_stride"].as<uint32_t>();
187 if (node[
"element_size"]) {
188 config.
elementSize = node[
"element_size"].as<uint32_t>();
190 if (node[
"output_datamap_key"]) {
191 auto keyNode = node[
"output_datamap_key"];
192 if (keyNode.IsSequence()) {
193 config.
datamapKey = keyNode.as<std::vector<std::string>>();
196 config.
datamapKey[0] = keyNode.as<std::string>();
199 if (node[
"file_loop"]) {
200 config.
fileLoop = node[
"file_loop"].as<
bool>();
203 if (node[
"source_id"]) {
204 config.
sourceId = node[
"source_id"].as<uint32_t>();
213 "lidar data config element_size: %d must be [3, 4].", config.
elementSize);
221 #endif // _DS3D_DATALOADER_LIDARSOURCE_CONFIG_H