Skip to content

Commit

Permalink
Add env var for debugging
Browse files Browse the repository at this point in the history
jlblancoc committed Feb 4, 2024
1 parent cacb810 commit 78231a7
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/doxygen-docs/changelog.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
- Changes in libraries:
- \ref mrpt_maps_grp:
- Implement missing probabilistic observation models in mrpt::maps::CVoxelMap and mrpt::maps::CVoxelMapRGB
- Add debug env variable `MRPT_DEBUG_OBSPTS_LAZY_LOAD` to debug lazy-load point cloud observations.
- \ref mrpt_ros2bridge_grp:
- Fix wrong macros leading to including obsolete header `<cv_bridge/cv_bridge.h>`.

2 changes: 2 additions & 0 deletions doc/source/env-vars.rst
Original file line number Diff line number Diff line change
@@ -24,6 +24,8 @@ numerical value (e.g. ``1``) will be interpreted as "true".

- ``MRPT_DEBUG_OBSIMG_LAZY_LOAD``: Shows `std::cout` traces whenever an mrpt::obs::CObservationImage with delay-load content is loaded or unloaded.

- ``MRPT_DEBUG_OBSPTS_LAZY_LOAD``: Shows `std::cout` traces whenever an mrpt::obs::CObservationPointCloud with delay-load content is loaded or unloaded.

- ``MRPT_EXPR_VERBOSE``: Set to ``1`` to enable extra verbose debug traces for
`mrpt::expr::CRuntimeCompiledExpression::eval() <class_mrpt_expr_CRuntimeCompiledExpression.html>`_.

14 changes: 14 additions & 0 deletions libs/maps/src/obs/CObservationPointCloud.cpp
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@

#include "maps-precomp.h" // Precomp header
//
#include <mrpt/core/get_env.h>
#include <mrpt/core/lock_helper.h>
#include <mrpt/io/CFileGZInputStream.h>
#include <mrpt/io/CFileGZOutputStream.h>
@@ -111,6 +112,12 @@ void CObservationPointCloud::load_impl() const
{
MRPT_START

const thread_local bool MRPT_DEBUG_OBSPTS_LAZY_LOAD =
mrpt::get_env<bool>("MRPT_DEBUG_OBSPTS_LAZY_LOAD", false);
if (MRPT_DEBUG_OBSPTS_LAZY_LOAD)
std::cout << "[CObservationPointCloud::load()] Called on this="
<< reinterpret_cast<const void*>(this) << std::endl;

// Already loaded?
if (!isExternallyStored() || (isExternallyStored() && pointcloud)) return;

@@ -201,6 +208,13 @@ void CObservationPointCloud::load_impl() const
void CObservationPointCloud::unload() const
{
MRPT_START

const thread_local bool MRPT_DEBUG_OBSPTS_LAZY_LOAD =
mrpt::get_env<bool>("MRPT_DEBUG_OBSPTS_LAZY_LOAD", false);
if (MRPT_DEBUG_OBSPTS_LAZY_LOAD)
std::cout << "[CObservationPointCloud::unload()] Called on this="
<< reinterpret_cast<const void*>(this) << std::endl;

if (!isExternallyStored() || !pointcloud) return;

// Free memory, saving to the file if it doesn't exist:

0 comments on commit 78231a7

Please sign in to comment.