42 #include <mrpt/examples_config.h> 46 "../share/mrpt/datasets/localization_demo.rawlog";
56 "Rawlog file does not exist: %s",
RAWLOG_FILE.c_str())
60 size_t rawlogEntry = 0;
66 rawlog_images_path +=
"/Images";
67 CImage::setImagesPathBase(rawlog_images_path);
81 cout <<
"Reading act/oct pair from rawlog..." << endl;
84 arch, action, observations, rawlogEntry))
102 sImgs ? sImgs->getSensorPose(cameraPose)
103 : Img->getSensorPose(cameraPose);
104 K = sImgs ? sImgs->leftCamera.intrinsicParams
105 : Img->cameraParams.intrinsicParams;
111 if (!laserScan)
continue;
115 laserScan->getSensorPose(laserPose);
117 if (abs(laserPose.
yaw()) >
DEG2RAD(90))
continue;
123 observations->insertObservationsInto(
127 vector<float> X, Y, Z;
132 sImgs ? sImgs->imageLeft.getWidth() : Img->image.getWidth();
134 sImgs ? sImgs->imageLeft.getHeight() : Img->image.getHeight();
137 vector<float> imgX, imgY;
139 imgX.resize(X.size());
140 imgY.resize(Y.size());
143 image = sImgs ? sImgs->imageLeft : Img->image;
148 for (itX = X.begin(), itY = Y.begin(), itZ = Z.begin(),
149 itImgX = imgX.begin(), itImgY = imgY.begin();
150 itX != X.end(); itX++, itY++, itZ++, itImgX++, itImgY++)
154 CPoint3D pCamera(pLaser - cameraPose);
158 *itImgX = -K(0, 0) * ((pCamera.x()) / (pCamera.z())) + K(0, 2);
159 *itImgY = -K(1, 1) * ((pCamera.y()) / (pCamera.z())) + K(1, 2);
161 if (*itImgX > 0 && *itImgX<imgW&& * itImgY> 0 && *itImgY < imgH)
162 image.filledRectangle(
163 *itImgX - 1, *itImgY - 1, *itImgX + 1, *itImgY + 1,
169 observations.reset();
173 std::this_thread::sleep_for(50ms);
182 int main(
int argc,
char** argv)
196 cerr <<
"EXCEPTION: " << e.what() << endl;
201 cerr <<
"Untyped exception!!";
Declares a class derived from "CObservation" that encapsules an image from a camera, whose relative pose to robot is also stored.
int getch() noexcept
An OS-independent version of getch, which waits until a key is pushed.
double DEG2RAD(const double x)
Degrees to radians.
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
double yaw() const
Get the YAW angle (in radians)
GLenum GLsizei GLenum GLenum const GLvoid * image
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. ...
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream, std::istream, std::ostream, std::stringstream
This base provides a set of functions for maths stuff.
void getAllPoints(VECTOR &xs, VECTOR &ys, VECTOR &zs, size_t decimation=1) const
Returns a copy of the 2D/3D points as a std::vector of float coordinates.
This class creates a window as a graphical user interface (GUI) for displaying images to the user...
Observation class for either a pair of left+right or left+disparity images from a stereo camera...
This namespace contains representation of robot actions and observations.
GLsizei const GLchar ** string
A class used to store a 3D point.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void pause(const std::string &msg=std::string("Press any key to continue...")) noexcept
Shows the message "Press any key to continue" (or other custom message) to the current standard outpu...
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 3D pose (a 3D translation + a rotation in 3D).
bool kbhit() noexcept
An OS-independent version of kbhit, which returns true if a key has been pushed.
void showImage(const mrpt::img::CImage &img)
Show a given color or grayscale image on the window.
TInsertionOptions insertionOptions
The options used when inserting observations in the map.
Classes for creating GUI windows for 2D and 3D visualization.
static bool readActionObservationPair(mrpt::serialization::CArchive &inStream, CActionCollection::Ptr &action, CSensoryFrame::Ptr &observations, size_t &rawlogEntry)
Reads a consecutive pair action / observation from the rawlog opened at some input stream...
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
std::string extractFileDirectory(const std::string &filePath)
Extract the whole path (the directory) of a filename from a complete path plus name plus extension...
A class for storing images as grayscale or RGB bitmaps.
float minDistBetweenLaserPoints
The minimum distance between points (in 3D): If two points are too close, one of them is not inserted...