Go to the documentation of this file.
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!!";
bool kbhit() noexcept
An OS-independent version of kbhit, which returns true if a key has been pushed.
std::string extractFileDirectory(const std::string &filePath)
Extract the whole path (the directory) of a filename from a complete path plus name plus extension.
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.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
float minDistBetweenLaserPoints
The minimum distance between points (in 3D): If two points are too close, one of them is not inserted...
Declares a class for storing a collection of robot actions.
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
This namespace contains representation of robot actions and observations.
void showImage(const mrpt::img::CImage &img)
Show a given color or grayscale image on the window.
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
std::shared_ptr< CObservationStereoImages > Ptr
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
std::shared_ptr< CObservationImage > Ptr
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans.
This class creates a window as a graphical user interface (GUI) for displaying images to the user.
Classes for creating GUI windows for 2D and 3D visualization.
A class for storing images as grayscale or RGB bitmaps.
std::shared_ptr< CObservation2DRangeScan > Ptr
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream,...
GLenum GLsizei GLenum GLenum const GLvoid * image
TInsertionOptions insertionOptions
The options used when inserting observations in the map.
double yaw() const
Get the YAW angle (in radians)
int getch() noexcept
An OS-independent version of getch, which waits until a key is pushed.
This base provides a set of functions for maths stuff.
GLsizei const GLchar ** string
A class used to store a 3D point.
Declares a class derived from "CObservation" that encapsules an image from a camera,...
Observation class for either a pair of left+right or left+disparity images from a stereo camera.
mrpt::io::CFileGZInputStream CFileGZInputStream
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 namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
double DEG2RAD(const double x)
Degrees to radians.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |