7 #include <mrpt/version.h> 11 #if MRPT_VERSION >= 0x199 12 #include <mrpt/serialization/CArchive.h> 18 std::string sOutMap =
"mrpt_rbpfslam_";
23 (
unsigned int)parts.
month, (
unsigned int)parts.
day,
24 (
unsigned int)parts.
hour, (
unsigned int)parts.
minute,
25 (
unsigned int)parts.
second);
26 sOutMap +=
".simplemap";
33 <<
" doesn't exist, cannot save simplemap there! Default " 34 "'~/.ros/' path will be used.\n";
36 std::cout <<
"Saving built map " << sOutMap <<
"\n";
38 }
catch (
const std::exception &e) {
39 std::cerr <<
"Exception: " << e.what() <<
"\n";
44 #if MRPT_VERSION >= 0x199 45 mrpt::config::CConfigFile
iniFile(ini_filename);
50 "MappingApplication");
55 const std::string &rawlog_filename,
59 #if MRPT_VERSION >= 0x199 60 mrpt::io::CFileGZInputStream rawlog_stream(rawlog_filename);
61 auto rawlogFile = mrpt::serialization::archiveFrom(rawlog_stream);
65 mrpt::obs::CActionCollection::Ptr
action;
66 mrpt::obs::CSensoryFrame::Ptr observations;
78 rawlogFile, action, observations, rawlogEntry)) {
81 data.emplace_back(*action, *observations);
86 const mrpt::obs::CSensoryFrame::ConstPtr sensory_frame,
87 const mrpt::obs::CObservationOdometry::ConstPtr odometry) {
88 action_ = mrpt::obs::CActionCollection::Create();
90 odom_move.timestamp = sensory_frame->getObservationByIndex(0)->timestamp;
105 log4cxx::LoggerPtr ros_logger =
110 #if MRPT_VERSION < 0x199 111 mapBuilder_.logRegisterCallback(static_cast<output_logger_callback_t>(
114 mapBuilder_.logRegisterCallback(static_cast<output_logger_callback_t>(
120 #if MRPT_VERSION >= 0x199 121 mrpt::random::getRandomGenerator().randomize();
151 #if MRPT_HAS_WXWIDGETS 156 win3D_->setCameraZoom(40);
157 win3D_->setCameraAzimuthDeg(-50);
158 win3D_->setCameraElevationDeg(70);
168 mrpt::opengl::COpenGLScene::Ptr
scene;
169 scene = mrpt::opengl::COpenGLScene::Create();
172 mrpt::opengl::CGridPlaneXY::Ptr groundPlane =
174 groundPlane->setColor(0.4, 0.4, 0.4);
175 scene->insert(groundPlane);
179 mrpt::opengl::CCamera::Ptr objCam = mrpt::opengl::CCamera::Create();
183 objCam->setPointingAt(robotPose);
184 objCam->setAzimuthDegrees(-30);
185 objCam->setElevationDegrees(30);
186 scene->insert(objCam);
189 mrpt::opengl::CSetOfObjects::Ptr objs =
190 mrpt::opengl::CSetOfObjects::Create();
196 mrpt::opengl::CSetOfLines::Ptr objLines =
198 objLines->setColor(0, 1, 1);
199 for (
size_t i = 0; i < M; i++) {
200 std::deque<mrpt::math::TPose3D>
path;
203 float x0 = 0, y0 = 0, z0 = 0;
204 for (
size_t k = 0; k < path.size(); k++) {
205 objLines->appendLine(x0, y0, z0 + 0.001, path[k].
x, path[k].
y,
212 scene->insert(objLines);
216 float minDistBtwPoses = -1;
217 std::deque<mrpt::math::TPose3D> dummyPath;
219 for (
int k = (
int)dummyPath.size() - 1; k >= 0; k--) {
223 #if MRPT_VERSION >= 0x199 231 if (meanPose.
distanceTo(lastMeanPose) > minDistBtwPoses) {
233 #if MRPT_VERSION >= 0x199 234 COV.blockCopy<3, 3>(0, 0);
236 COV.block(0, 0, 3, 3);
239 minDistBtwPoses = 6 * sqrt(COV3(0, 0) + COV3(1, 1));
241 mrpt::opengl::CEllipsoid::Ptr objEllip =
242 mrpt::opengl::CEllipsoid::Create();
243 objEllip->setLocation(meanPose.
x(), meanPose.
y(), meanPose.z() + 0.001);
244 objEllip->setCovMatrix(COV3, COV3(2, 2) == 0 ? 2 : 3);
246 objEllip->setColor(0, 0, 1);
247 objEllip->enableDrawSolid3D(
false);
248 scene->insert(objEllip);
250 lastMeanPose = meanPose;
254 mrpt::opengl::COpenGLScene::Ptr &scenePtr =
win3D_->get3DSceneAndLock();
256 win3D_->unlockAccess3DScene();
void getEstimatedPosePDF(mrpt::poses::CPose3DPDFParticles &out_estimation) const
void BASE_IMPEXP timestampToParts(TTimeStamp t, TTimeParts &p, bool localTime=false)
GLint GLint GLint GLint GLint GLint y
void saveCurrentMapToFile(const std::string &fileName, bool compressGZ=true) const
void getPath(size_t i, std::deque< math::TPose3D > &out_path) const
void getMean(CPose3D &mean_pose) const MRPT_OVERRIDE
mrpt::slam::CMetricMapBuilderRBPF::TConstructionOptions rbpfMappingOptions_
options for SLAM from ini file
void observation(const mrpt::obs::CSensoryFrame::ConstPtr sensory_frame, const mrpt::obs::CObservationOdometry::ConstPtr odometry)
Calculate the actions from odometry model for current observation.
int PROGRESS_WINDOW_WIDTH_
static CDisplayWindow3DPtr Create(const std::string &windowCaption, unsigned int initialWindowWidth=400, unsigned int initialWindowHeight=300)
BASE_IMPEXP CRandomGenerator randomGenerator
mrpt::poses::CPose3DPDFParticles curPDF
current robot pose
mrpt::system::TTimeStamp now()
void getAs3DObject(mrpt::opengl::CSetOfObjectsPtr &outObj) const MRPT_OVERRIDE
static CSetOfLinesPtr Create(const std::vector< mrpt::math::TSegment3D > &sgms, const bool antiAliasing=true)
static bool readActionObservationPair(mrpt::utils::CStream &inStream, CActionCollectionPtr &action, CSensoryFramePtr &observations, size_t &rawlogEntry)
int PROGRESS_WINDOW_HEIGHT_
size_t particlesCount() const MRPT_OVERRIDE
void randomize(const uint32_t seed)
mrpt::gui::CDisplayWindow3D::Ptr win3D_
MRPT window.
struct mrpt_rbpf_slam::PFslam::Options options_
int BASE_IMPEXP getch() MRPT_NO_THROWS
void readIniFile(const std::string &ini_filename)
Read ini file.
mrpt::slam::CMetricMapBuilderRBPF mapBuilder_
map builder
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ion) MRPT_OVERRIDE
const CMultiMetricMap * getCurrentMostLikelyMetricMap() const
void initSlam(Options options)
initialize the SLAM
GLint GLint GLint GLint GLint x
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
mrpt::obs::CActionCollection::Ptr action_
actions
VerbosityLevel rosLoggerLvlToMRPTLoggerLvl(log4cxx::LevelPtr lvl)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
static CGridPlaneXYPtr Create(float xMin, float xMax, float yMin, float yMax, float z=0, float frequency=1, float lineWidth=1.3f, bool antiAliasing=true)
void readRawlog(const std::string &rawlog_filename, std::vector< std::pair< mrpt::obs::CActionCollection, mrpt::obs::CSensoryFrame >> &data)
Read pairs of actions and observations from rawlog file.
std::string BASE_IMPEXP fileNameStripInvalidChars(const std::string &filename, const char replacement_to_invalid_chars= '_')
void getCovarianceAndMean(mrpt::math::CMatrixDouble66 &cov, CPose3D &mean_point) const MRPT_OVERRIDE
const mrpt::maps::CMultiMetricMap * metric_map_
receive map after iteration of SLAM to metric map
bool SHOW_PROGRESS_IN_WINDOW_
bool BASE_IMPEXP kbhit() MRPT_NO_THROWS
void mrptToROSLoggerCallback(const std::string &msg, const VerbosityLevel level, const std::string &loggerName, const mrpt::system::TTimeStamp timestamp)
mrpt::poses::CPose2D odomLastObservation_
last observation of odometry
std::string simplemap_path_prefix
bool CAMERA_3DSCENE_FOLLOWS_ROBOT_
double distanceTo(const CPoseOrPoint< OTHERCLASS > &b) const
void dumpToConsole() const
bool BASE_IMPEXP directoryExists(const std::string &fileName)
void computeFromOdometry(const mrpt::poses::CPose2D &odometryIncrement, const TMotionModelOptions &options)
void mrptToROSLoggerCallback_mrpt_15(const std::string &msg, const VerbosityLevel level, const std::string &loggerName, const mrpt::system::TTimeStamp timestamp, void *userParam)
#define ROSCONSOLE_DEFAULT_NAME
void getEstimatedPosePDFAtTime(size_t timeStep, mrpt::poses::CPose3DPDFParticles &out_estimation) const
mrpt::maps::CMultiMetricMapPDF mapPDF
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions motion_model_options_