namespace mrpt::test
Overview
Helpers shared by the SLAM unit tests: a synthetic closed room used as ground truth, plus 2D laser scans and odometry actions simulated from it, so that no dataset files are needed.
namespace test { // global functions const char* guiUnavailableReason(); bool guiIsAvailable(); const mrpt::maps::COccupancyGridMap2D& groundTruthRoom(); mrpt::system::TTimeStamp nextTimestamp(); mrpt::obs::CObservation2DRangeScan::Ptr simulateScan( const mrpt::poses::CPose2D& robotPose, const mrpt::system::TTimeStamp t ); mrpt::obs::CSensoryFrame::Ptr simulateSF( const mrpt::poses::CPose2D& robotPose, const mrpt::system::TTimeStamp t ); mrpt::obs::CActionCollection::Ptr makeOdometryAction( const mrpt::poses::CPose2D& increment, const mrpt::system::TTimeStamp t ); } // namespace test
Global Functions
const char* guiUnavailableReason()
Empty if a window can actually be created in this environment; otherwise a human-readable reason why not.
On X11 systems a display is required; CI runs these tests under a virtual one (xvfb-run), and they self-skip when none is available. Windows and macOS always have a window server, but MRPT there may have been built with -DDISABLE_WXWIDGETS=ON, in which case there is no window class to test.
This only checks that a display is configured, not that it is reachable: a stale DISPLAY (e.g. a declined X11 forwarding) makes each window test wait out CBaseGUIWindow ‘s creation timeout and then fail, which is the intended signal for a broken environment. Set MRPT_SKIP_GUI_TESTS=1 to skip them instead, or MRPT_WXSUBSYS_TIMEOUT_MS to shorten the wait.
bool guiIsAvailable()
True if a window can actually be created in this environment.
const mrpt::maps::COccupancyGridMap2D& groundTruthRoom()
A closed 10x10 m rectangular room, used as ground truth to simulate scans.
mrpt::system::TTimeStamp nextTimestamp()
Successive calls return timestamps 100 ms apart.
Do not use Clock::now() for each simulated step: its resolution is coarse enough on some platforms that consecutive calls return the same value, and consumers that need a strictly increasing clock (e.g. CRobot2DPoseEstimator) then drop the updates.