27 std::istream& in_stream,
28 std::vector<mrpt::obs::CObservation::Ptr>& out_observations,
34 out_observations.clear();
40 if (!in_stream)
return false;
41 std::getline(in_stream, line);
54 std::make_shared<CObservation2DRangeScan>();
61 double start_angle, angular_resolution, accuracy;
64 if (!(S >> obsLaser->sensorLabel >> laser_type >> start_angle >>
65 obsLaser->aperture >> angular_resolution >> obsLaser->maxRange >>
66 accuracy >> remission_mode))
68 "Error parsing line from CARMEN log (params):\n'%s'\n",
74 obsLaser->resizeScan(nRanges);
76 for (
size_t i = 0; i < nRanges; i++)
81 "Error parsing line from CARMEN log (ranges):\n'%s'\n",
83 obsLaser->setScanRange(i,
range);
85 obsLaser->setScanRangeValidity(
86 i, (obsLaser->scan[i] >= obsLaser->maxRange ||
87 obsLaser->scan[i] <= 0));
90 size_t remmision_count;
91 if (!(S >> remmision_count))
93 "Error parsing line from CARMEN log (remmision_count):\n'%s'\n",
96 vector<double> remission;
97 remission.resize(remmision_count);
99 for (
size_t i = 0; i < remmision_count; i++)
101 if (!(S >> remission[i]))
103 "Error parsing line from CARMEN log (remmision " 111 if (!(S >> globalLaserPose.
x >> globalLaserPose.
y >>
112 globalLaserPose.
phi >> globalRobotPose.
x >> globalRobotPose.
y >>
113 globalRobotPose.
phi))
115 "Error parsing line from CARMEN log (poses):\n'%s'\n",
119 obsLaser->sensorPose =
122 double tv, rv, fw_dist, side_dist, turn_axis;
123 S >> tv >> rv >> fw_dist >> side_dist >> turn_axis;
127 S >> timestamp >> robotName;
131 std::chrono::microseconds(static_cast<uint64_t>(1e-6 * timestamp));
133 obsLaser->timestamp = obs_time;
138 std::make_shared<CObservationOdometry>();
140 obsOdo_ptr->timestamp = obs_time;
141 obsOdo_ptr->odometry =
CPose2D(globalRobotPose);
142 obsOdo_ptr->sensorLabel =
"ODOMETRY";
144 out_observations.push_back(obsOdo_ptr);
148 out_observations.push_back(obsLaser_ptr);
157 std::istringstream S;
161 std::make_shared<CObservation2DRangeScan>();
168 if (!(S >> obsLaser->sensorLabel >> nRanges))
170 "Error parsing line from CARMEN log (params):\n'%s'\n",
175 double maxRange = 81.0;
176 double resolutionDeg = 0.5;
183 .getWithDefaultVal(
"robot_front_laser_max",
"81.0"s)
186 atof(global_log_params
188 "laser_front_laser_resolution",
"0.5"s)
191 else if (line[0] ==
'R')
194 atof(global_log_params
195 .getWithDefaultVal(
"robot_rear_laser_max",
"81.0"s)
198 atof(global_log_params
200 "laser_rear_laser_resolution",
"0.5"s)
203 obsLaser->maxRange = maxRange;
204 obsLaser->aperture =
DEG2RAD(resolutionDeg) * nRanges;
207 obsLaser->resizeScan(nRanges);
209 for (
size_t i = 0; i < nRanges; i++)
214 "Error parsing line from CARMEN log (ranges):\n'%s'\n",
216 obsLaser->setScanRange(i,
range);
218 obsLaser->setScanRangeValidity(
219 i, (obsLaser->scan[i] >= obsLaser->maxRange ||
220 obsLaser->scan[i] <= 0));
225 if (!(S >> globalLaserPose.
x >> globalLaserPose.
y >>
226 globalLaserPose.
phi >> globalRobotPose.
x >> globalRobotPose.
y >>
227 globalRobotPose.
phi))
229 "Error parsing line from CARMEN log (poses):\n'%s'\n",
233 obsLaser->sensorPose =
238 S >> timestamp >> robotName;
242 std::chrono::microseconds(static_cast<uint64_t>(1e-6 * timestamp));
244 obsLaser->timestamp = obs_time;
249 std::make_shared<CObservationOdometry>();
251 obsOdo_ptr->timestamp = obs_time;
252 obsOdo_ptr->odometry =
CPose2D(globalRobotPose);
253 obsOdo_ptr->sensorLabel =
"ODOMETRY";
255 out_observations.push_back(obsOdo_ptr);
259 out_observations.push_back(obsLaser_ptr);
266 std::istringstream S;
272 if (!(S >> key >>
val))
274 "Error parsing line from CARMEN log (PARAM):\n'%s'\n",
277 if (!key.empty() && !
val.empty())
double DEG2RAD(const double x)
Degrees to radians.
bool carmen_log_parse_line(std::istream &in_stream, std::vector< mrpt::obs::CObservation::Ptr > &out_imported_observations, const mrpt::system::TTimeStamp &time_start_log)
Parse one line from an text input stream and interpret it as a CARMEN log entry, returning its MRPT o...
bool strStartsI(const std::string &str, const std::string &subStr)
Return true if "str" starts with "subStr" (case insensitive)
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
std::string lowerCase(const std::string &str)
Returns an lower-case version of a string.
This namespace contains representation of robot actions and observations.
static std::string & trim(std::string &s)
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
For usage when passing a dynamic number of (numeric) arguments to a function, by name.
double phi
Orientation (rads)