29 std::istream& in_stream,
30 std::vector<mrpt::obs::CObservation::Ptr>& out_observations,
36 out_observations.clear();
42 if (!in_stream)
return false;
43 std::getline(in_stream, line);
56 mrpt::make_aligned_shared<CObservation2DRangeScan>();
63 double start_angle, angular_resolution, accuracy;
66 if (!(S >> obsLaser->sensorLabel >> laser_type >> start_angle >>
67 obsLaser->aperture >> angular_resolution >> obsLaser->maxRange >>
68 accuracy >> remission_mode))
70 "Error parsing line from CARMEN log (params):\n'%s'\n",
76 obsLaser->resizeScan(nRanges);
78 for (
size_t i = 0; i < nRanges; i++)
83 "Error parsing line from CARMEN log (ranges):\n'%s'\n",
85 obsLaser->setScanRange(i,
range);
87 obsLaser->setScanRangeValidity(
88 i, (obsLaser->scan[i] >= obsLaser->maxRange ||
89 obsLaser->scan[i] <= 0));
92 size_t remmision_count;
93 if (!(S >> remmision_count))
95 "Error parsing line from CARMEN log (remmision_count):\n'%s'\n",
98 vector<double> remission;
99 remission.resize(remmision_count);
101 for (
size_t i = 0; i < remmision_count; i++)
103 if (!(S >> remission[i]))
105 "Error parsing line from CARMEN log (remmision " 113 if (!(S >> globalLaserPose.
x >> globalLaserPose.
y >>
114 globalLaserPose.
phi >> globalRobotPose.
x >> globalRobotPose.
y >>
115 globalRobotPose.
phi))
117 "Error parsing line from CARMEN log (poses):\n'%s'\n",
121 obsLaser->sensorPose =
124 double tv, rv, fw_dist, side_dist, turn_axis;
125 S >> tv >> rv >> fw_dist >> side_dist >> turn_axis;
129 S >> timestamp >> robotName;
135 obsLaser->timestamp = obs_time;
140 mrpt::make_aligned_shared<CObservationOdometry>();
142 obsOdo_ptr->timestamp = obs_time;
143 obsOdo_ptr->odometry =
CPose2D(globalRobotPose);
144 obsOdo_ptr->sensorLabel =
"ODOMETRY";
146 out_observations.push_back(obsOdo_ptr);
150 out_observations.push_back(obsLaser_ptr);
159 std::istringstream S;
163 mrpt::make_aligned_shared<CObservation2DRangeScan>();
170 if (!(S >> obsLaser->sensorLabel >> nRanges))
172 "Error parsing line from CARMEN log (params):\n'%s'\n",
177 double maxRange = 81.0;
178 double resolutionDeg = 0.5;
184 .getWithDefaultVal(
"robot_front_laser_max",
"81.0")
186 resolutionDeg = atof(
189 "laser_front_laser_resolution",
"0.5")
192 else if (line[0] ==
'R')
196 .getWithDefaultVal(
"robot_rear_laser_max",
"81.0")
198 resolutionDeg = atof(
201 "laser_rear_laser_resolution",
"0.5")
204 obsLaser->maxRange = maxRange;
205 obsLaser->aperture =
DEG2RAD(resolutionDeg) * nRanges;
208 obsLaser->resizeScan(nRanges);
210 for (
size_t i = 0; i < nRanges; i++)
215 "Error parsing line from CARMEN log (ranges):\n'%s'\n",
217 obsLaser->setScanRange(i,
range);
219 obsLaser->setScanRangeValidity(
220 i, (obsLaser->scan[i] >= obsLaser->maxRange ||
221 obsLaser->scan[i] <= 0));
226 if (!(S >> globalLaserPose.
x >> globalLaserPose.
y >>
227 globalLaserPose.
phi >> globalRobotPose.
x >> globalRobotPose.
y >>
228 globalRobotPose.
phi))
230 "Error parsing line from CARMEN log (poses):\n'%s'\n",
234 obsLaser->sensorPose =
239 S >> timestamp >> robotName;
245 obsLaser->timestamp = obs_time;
250 mrpt::make_aligned_shared<CObservationOdometry>();
252 obsOdo_ptr->timestamp = obs_time;
253 obsOdo_ptr->odometry =
CPose2D(globalRobotPose);
254 obsOdo_ptr->sensorLabel =
"ODOMETRY";
256 out_observations.push_back(obsOdo_ptr);
260 out_observations.push_back(obsLaser_ptr);
267 std::istringstream S;
273 if (!(S >> key >>
val))
275 "Error parsing line from CARMEN log (PARAM):\n'%s'\n",
278 if (!key.empty() && !
val.empty())
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
For usage when passing a dynamic number of (numeric) arguments to a function, by name.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
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)
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
std::shared_ptr< CObservation2DRangeScan > Ptr
std::shared_ptr< CObservationOdometry > Ptr
std::string lowerCase(const std::string &str)
Returns an lower-case version of a string.
This namespace contains representation of robot actions and observations.
double DEG2RAD(const double x)
Degrees to radians.
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).
std::string trim(const std::string &str)
Removes leading and trailing spaces.
mrpt::system::TTimeStamp secondsToTimestamp(const double nSeconds)
Transform a time interval (in seconds) into TTimeStamp (e.g.
double phi
Orientation (rads)