ScanProjectSchemaSLAM.cpp
Go to the documentation of this file.
1 #include <sstream>
2 #include <iomanip>
3 
5 #include "lvr2/io/IOUtils.hpp"
8 
9 #include <boost/filesystem.hpp>
10 
11 namespace lvr2
12 {
13 
15 {
16  Description d;
17  d.groupName = ""; // All data is saved in the root dir
18  d.dataSetName = boost::none; // No dataset name for project root
19  d.metaData = boost::none; // No metadata for project
20  return d;
21 }
22 Description ScanProjectSchemaSLAM::position(const size_t &scanPosNo) const
23 {
24  Description d;
25 
26  // Scan does not support scan positions. So we only consider
27  // scan position 0 valid
28  if(scanPosNo == 0)
29  {
30  d.groupName = "";
31  }
32  else
33  {
34  d.groupName = boost::none;
35  }
36 
37  d.dataSetName = boost::none;
38  d.metaData = boost::none;
39  d.metaName = boost::none;
40  return d;
41 }
42 
43 Description ScanProjectSchemaSLAM::scan(const size_t &scanPosNo, const size_t &scanNo) const
44 {
45  Description d;
46 
47  // Scan does not support scan positions. So we only consider
48  // scan position 0 valid
49  if(scanPosNo == 0)
50  {
51  d.groupName = "";
52  }
53  else
54  {
55  d.groupName = boost::none;
56  }
57 
58  // Save scan file name
59  std::stringstream scan_stream;
60  scan_stream << "scan" << std::setfill('0') << std::setw(3) << scanNo;
61  d.dataSetName = scan_stream.str() + ".3d";
62 
63  // Setup meta info -> Read frames file and pose file to setup valid
64  // meta description node
65  boost::filesystem::path pose_path(scan_stream.str() + ".pose");
66  boost::filesystem::path frames_path(scan_stream.str() + ".frames");
67  boost::filesystem::path scan_path(*d.dataSetName);
68 
69  Eigen::Matrix<double, 4, 4> poseEstimate;
70  if(boost::filesystem::exists(pose_path))
71  {
72  poseEstimate = getTransformationFromPose<double>(pose_path);
73  }
74 
75  Eigen::Matrix<double, 4, 4> registration;
76  if(boost::filesystem::exists(frames_path))
77  {
78  registration = getTransformationFromFrames<double>(frames_path);
79  }
80 
81  // Try to load scan data
82  size_t num_pts = 0;
83  if(boost::filesystem::exists(scan_path))
84  {
85  num_pts = countPointsInFile(scan_path);
86  }
87 
88  // Encode meta data
89  YAML::Node node;
90  node["sensor_type"] = lvr2::Scan::sensorType; // Laser scanner
91 
92  node["start_time"] = 0.0; // Unknown
93  node["end_time"] = 0.0; // Unknown
94 
95  node["pose_estimate"] = poseEstimate; // Estimation from .pose
96  node["registration"] = registration; // Registration from .frames
97 
98  YAML::Node config;
99  config["theta"] = YAML::Load("[]");
100  config["theta"].push_back(0);
101  config["theta"].push_back(0);
102 
103  config["phi"] = YAML::Load("[]");
104  config["phi"].push_back(0);
105  config["phi"].push_back(0);
106 
107  config["v_res"] = 0.0;
108  config["h_res"] = 0.0;
109 
110  config["num_points"] = num_pts;
111  node["config"] = config;
112 
113  d.metaData = node;
114 
115  // Mark slam6d format
116  d.metaName = scan_stream.str() + ".slam6d";
117  return d;
118 }
119 
120 Description ScanProjectSchemaSLAM::scan(const std::string& scanPositionPath, const size_t &scanNo) const
121 {
122  return scan(0, scanNo);
123 }
124 
125 Description ScanProjectSchemaSLAM::scanCamera(const size_t &scanPositionNo, const size_t &camNo) const
126 {
127  // Scan camera is not supported
128  Description d;
129  d.groupName = boost::none;
130  d.dataSetName = boost::none;
131  d.metaData = boost::none;
132  d.metaName = boost::none;
133  return d;
134 }
135 
136 Description ScanProjectSchemaSLAM::scanCamera(const std::string &scanPositionPath, const size_t &camNo) const
137 {
138  // Scan camera is not supported
139  Description d;
140  d.groupName = boost::none;
141  d.dataSetName = boost::none;
142  d.metaData = boost::none;
143  d.metaName = boost::none;
144  return d;
145 }
146 
148  const size_t &scanPosNo, const size_t &scanNo,
149  const size_t &scanCameraNo, const size_t &scanImageNo) const
150 {
151  // Scan images are not supported
152  Description d;
153  d.groupName = boost::none;
154  d.dataSetName = boost::none;
155  d.metaData = boost::none;
156  d.metaName = boost::none;
157  return d;
158 }
159 
161  const std::string &scanImagePath, const size_t &scanImageNo) const
162 {
163  // Scan images are not supported
164  Description d;
165  d.groupName = boost::none;
166  d.dataSetName = boost::none;
167  d.metaData = boost::none;
168  d.metaName = boost::none;
169  return d;
170 }
171 
172 } // namespace lvr2
StringOptional metaName
virtual Description scanCamera(const size_t &scanPositionNo, const size_t &camNo) const
StringOptional groupName
static constexpr char sensorType[]
Definition: ScanTypes.hpp:42
virtual Description scanProject() const
virtual Description position(const size_t &scanPosNo) const
virtual Description scan(const size_t &scanPosNo, const size_t &scanNo) const
virtual Description scanImage(const size_t &scanPosNo, const size_t &scanNo, const size_t &scanCameraNo, const size_t &scanImageNo) const
size_t countPointsInFile(const boost::filesystem::path &inFile)
Counts the number of points (i.e. number of lines) in the given file.
Definition: IOUtils.cpp:132
StringOptional dataSetName


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:09