|
RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
|
Top-level RTAB-Map SLAM pipeline (mapping, localization and loop closure). More...
#include <Rtabmap.h>
Public Types | |
| enum | VhStrategy { kVhNone , kVhEpipolar , kVhUndef } |
| Loop-closure verification strategy. More... | |
Public Member Functions | |
| bool | process (const SensorData &data, Transform odomPose, const cv::Mat &odomCovariance=cv::Mat::eye(6, 6, CV_64FC1), const std::vector< float > &odomVelocity=std::vector< float >(), const std::map< std::string, float > &externalStats=std::map< std::string, float >()) |
| Main RTAB-Map iteration: ingests one sensor frame and updates the map. | |
| bool | process (const SensorData &data, Transform odomPose, float odomLinearVariance, float odomAngularVariance, const std::vector< float > &odomVelocity=std::vector< float >(), const std::map< std::string, float > &externalStats=std::map< std::string, float >()) |
| Convenience overload: builds a diagonal covariance from scalar variances. | |
| bool | process (const cv::Mat &image, int id=0, const std::map< std::string, float > &externalStats=std::map< std::string, float >()) |
| Appearance-only convenience overload (loop-closure detection without odometry). | |
| void | init (const ParametersMap ¶meters, const std::string &databasePath="", bool loadDatabaseParameters=false) |
| Initializes Rtabmap with parameters and a database. | |
| void | init (const std::string &configFile="", const std::string &databasePath="", bool loadDatabaseParameters=false) |
| Initializes Rtabmap from a configuration file and a database. | |
| void | close (bool databaseSaved=true, const std::string &ouputDatabasePath="") |
| Closes Rtabmap and releases the underlying Memory. | |
| const std::string & | getWorkingDir () const |
| bool | isRGBDMode () const |
| int | getLoopClosureId () const |
| float | getLoopClosureValue () const |
| int | getHighestHypothesisId () const |
| float | getHighestHypothesisValue () const |
| int | getLastLocationId () const |
| std::list< int > | getWM () const |
| std::set< int > | getSTM () const |
| int | getWMSize () const |
| int | getSTMSize () const |
| std::map< int, int > | getWeights () const |
| int | getTotalMemSize () const |
| double | getLastProcessTime () const |
| bool | isInSTM (int locationId) const |
| bool | isIDsGenerated () const |
| const Statistics & | getStatistics () const |
| const std::map< int, Transform > & | getLocalOptimizedPoses () const |
| const std::multimap< int, Link > & | getLocalConstraints () const |
| Transform | getPose (int locationId) const |
| Transform | getMapCorrection () const |
| const Memory * | getMemory () const |
| float | getGoalReachedRadius () const |
| float | getLocalRadius () const |
| const Transform & | getLastLocalizationPose () const |
| float | getTimeThreshold () const |
| void | setTimeThreshold (float maxTimeAllowed) |
| Sets the per-iteration time budget (ms). | |
| int | getMemoryThreshold () const |
| void | setMemoryThreshold (int maxMemoryAllowed) |
| Sets the maximum number of signatures kept in WM (0 = unbounded). | |
| void | setInitialPose (const Transform &initialPose) |
| Sets the localization prior pose used to seed the next process() call (localization mode only). | |
| int | triggerNewMap () |
| Starts a new map session (next process() will create a fresh map id). | |
| bool | labelLocation (int id, const std::string &label) |
Assigns or clears a label on signature id. | |
| bool | setUserData (int id, const cv::Mat &data) |
Attaches user data to signature id, compressing it on the fly if needed. | |
| void | generateDOTGraph (const std::string &path, int id=0, int margin=5) |
| Writes a Graphviz DOT file of the pose graph. | |
| void | exportPoses (const std::string &path, bool optimized, bool global, int format) |
| Exports the current pose graph to a text file. | |
| void | resetMemory () |
| Clears all in-memory state and resets the database. | |
| void | dumpPrediction () const |
| Dumps the Bayes-filter prediction matrix to a file in the working directory. | |
| void | dumpData () const |
| Dumps the Memory state (signatures, words, dictionary) to the working directory. | |
| void | parseParameters (const ParametersMap ¶meters) |
| Re-parses parameters and propagates them to owned sub-objects (Memory, BayesFilter, Optimizer, ...). | |
| const ParametersMap & | getParameters () const |
| void | setWorkingDirectory (std::string path) |
| Sets the working directory used for dumps, logs and temporary files. | |
| void | rejectLastLoopClosure () |
| Removes the loop-closure link added at the last process() iteration. | |
| void | deleteLastLocation () |
| Deletes the most recent (non-intermediate) location from the map. | |
| void | setOptimizedPoses (const std::map< int, Transform > &poses, const std::multimap< int, Link > &constraints) |
| Replaces the current optimized poses and constraints with externally provided ones. | |
| Signature | getSignatureCopy (int id, bool images, bool scan, bool userData, bool occupancyGrid, bool withWords, bool withGlobalDescriptors) const |
Returns a copy of signature id with optional payloads attached. | |
| RTABMAP_DEPRECATED void | get3DMap (std::map< int, Signature > &signatures, std::map< int, Transform > &poses, std::multimap< int, Link > &constraints, bool optimized, bool global) const |
Deprecated: use getGraph() instead with withImages=true, withScan=true, withUserData=true and withGrid=true. | |
| void | getGraph (std::map< int, Transform > &poses, std::multimap< int, Link > &constraints, bool optimized, bool global, std::map< int, Signature > *signatures=0, bool withImages=false, bool withScan=false, bool withUserData=false, bool withGrid=false, bool withWords=true, bool withGlobalDescriptors=true) const |
| Extracts a full snapshot of the current pose graph. | |
| std::map< int, Transform > | getNodesInRadius (const Transform &pose, float radius, int k=0, std::map< int, float > *distsSqr=0) |
Returns optimized poses within a metric radius of pose. | |
| std::map< int, Transform > | getNodesInRadius (int nodeId, float radius, int k=0, std::map< int, float > *distsSqr=0) |
Returns optimized poses within a metric radius of node nodeId. | |
| int | detectMoreLoopClosures (float clusterRadiusMax=0.5f, float clusterAngle=M_PI/6.0f, int iterations=1, bool intraSession=true, bool interSession=true, const ProgressState *state=0, float clusterRadiusMin=0.0f, int toFromMapId=-1) |
| Post-processing: searches for additional loop closures over the existing graph. | |
| bool | globalBundleAdjustment (int optimizerType=1, bool rematchFeatures=true, int iterations=0, float pixelVariance=0.0f) |
| Runs a global bundle adjustment over the optimized graph. | |
| int | cleanupLocalGrids (const std::map< int, Transform > &mapPoses, const cv::Mat &map, float xMin, float yMin, float cellSize, int cropRadius=1, bool filterScans=false) |
| Filters spurious obstacles from every node's local grid using a reference 2D map. | |
| int | refineLinks () |
| Re-runs registration on every link of the current graph and updates the ones that converge. | |
| bool | addLink (const Link &link) |
| Adds an external link to the map. | |
| cv::Mat | getInformation (const cv::Mat &covariance) const |
| Converts an odometry covariance into an information matrix, clipping by Memory::getOdomMaxInf() when Parameters::kRGBDLoopCovLimited() is enabled. | |
| void | addNodesToRepublish (const std::vector< int > &ids) |
| Marks node ids whose data should be re-emitted on the next process(). | |
| void | setDummyDictionary (bool enabled=true) |
| Loads the visual word dictionary as ids only, without descriptors. | |
| int | getPathStatus () const |
| void | clearPath (int status) |
| Clears the current path and sets its terminal status. | |
| bool | computePath (int targetNode, bool global) |
Plans a path from the current location to node targetNode. | |
| bool | computePath (const Transform &targetPose, float tolerance=-1.0f) |
| Plans a path in the current optimized map toward a metric goal pose. | |
| const std::vector< std::pair< int, Transform > > & | getPath () const |
| std::vector< std::pair< int, Transform > > | getPathNextPoses () const |
| std::vector< int > | getPathNextNodes () const |
| int | getPathCurrentGoalId () const |
| unsigned int | getPathCurrentIndex () const |
| unsigned int | getPathCurrentGoalIndex () const |
| const Transform & | getPathTransformToGoal () const |
| std::map< int, Transform > | getForwardWMPoses (int fromId, int maxNearestNeighbors, float radius, int maxDiffID) const |
Returns optimized poses of WM nodes located in front of fromId. | |
| std::map< int, std::map< int, Transform > > | getPaths (const std::map< int, Transform > &poses, const Transform &target, int maxGraphDepth=0) const |
| Segments a set of optimized poses into paths connected by neighbor links. | |
| void | adjustLikelihood (std::map< int, float > &likelihood) const |
| Applies the standard RTAB-Map likelihood adjustment. | |
Top-level RTAB-Map SLAM pipeline (mapping, localization and loop closure).
Rtabmap orchestrates the full SLAM iteration. Each new sensor observation passed to process() goes through the steps described below.
Done via Memory::update(): a new Signature is added to STM, the oldest STM entry is promoted to WM if STM is full, and rehearsal compares the new signature to the previous STM signature.
When the robot barely moved since the previous frame (odometry displacement below Parameters::kRGBDLinearUpdate() and Parameters::kRGBDAngularUpdate()), the iteration is flagged as a "small displacement":
In either case, at the end of the iteration, if no loop closure, proximity detection or landmark observation latched onto the new node, it is deleted from Memory so the map does not grow while the robot is idle.
Rehearsal still runs first, so visually similar consecutive idle frames may also be merged into the previous STM signature (its weight is incremented and the new signature is discarded) when the similarity exceeds Parameters::kMemRehearsalSimilarity().
Scored via Memory::computeLikelihood() and the recursive BayesFilter (prior + observation update).
The highest posterior is compared against the loop-closure threshold (Parameters::kRtabmapLoopThr()); if accepted, the loop-closure link is added and the pose graph is re-optimized by Optimizer.
In RGB-D mode, two extra checks must pass before the link is committed:
The optimization used by the consistency check depends on the operating mode:
In both modes, if the same link is rejected twice in a row, a graph repair may also be attempted (within Parameters::kRGBDOptimizeMaxErrorRepairRadius()) to drop the offending link instead of the new candidate.
If either RGB-D check fails, the candidate is discarded and no link is added.
Once a loop-closure hypothesis is selected, neighbors of the matched node are brought back from LTM into WM via Memory::reactivateSignatures(), so the next iteration can compare against them too. Up to Parameters::kRtabmapMaxRetrieved() nodes are pulled per iteration; nodes around the current path or local pose may also be retrieved (capped by Parameters::kRGBDMaxLocalRetrieved()).
Retrieval (and the related node immunization) is only active when memory management is enabled, i.e. when Parameters::kRtabmapTimeThr() or Parameters::kRtabmapMemoryThr() is non-zero.
Visual and scan-based local matches to nearby nodes, used in addition to the appearance-based loop closure.
Candidate proximity links go through the same two RGB-D gates as loop closures above: a valid geometric transform must be computed by the registration pipeline, and the transform must not be rejected by the graph-optimization consistency check.
At the end of the iteration, if the iteration exceeded the configured time budget (Parameters::kRtabmapTimeThr()) or WM exceeded its size budget (Parameters::kRtabmapMemoryThr()), Memory::forget() moves the oldest low-frequency signatures from WM to LTM (immunized nodes – retrieved neighbors, the last localization node, etc. – are kept in WM).
Transfer is skipped when both thresholds are 0 (memory management disabled).
Optimized poses, current map correction and statistics are made available to callers via the getters below.
Selected by Parameters::kMemIncrementalMemory() (see Memory::isIncremental()):
Rtabmap also exposes basic graph-based path planning in RGB-D mode (computePath(), getPath(), getPathStatus()), used by the GUI to navigate between mapped locations.
When memory management is enabled (see step 4 Retrieval and step 6 Transfer), the retrieval step also pulls nodes along the currently planned path back from LTM into WM (capped by Parameters::kRGBDMaxLocalRetrieved()) so the robot is able to re-localize against upcoming waypoints as it follows the path, even when those nodes had been transferred out of WM earlier.
| bool rtabmap::Rtabmap::process | ( | const SensorData & | data, |
| Transform | odomPose, | ||
| const cv::Mat & | odomCovariance = cv::Mat::eye(6, 6, CV_64FC1), |
||
| const std::vector< float > & | odomVelocity = std::vector< float >(), |
||
| const std::map< std::string, float > & | externalStats = std::map< std::string, float >() |
||
| ) |
Main RTAB-Map iteration: ingests one sensor frame and updates the map.
Adds data to Memory, runs the Bayes filter on the current likelihood, selects a loop-closure hypothesis if any, performs proximity detection, re-optimizes the graph as needed, and refreshes getStatistics() and getLastLocalizationPose().
| data | Sensor data for this frame (images, scan, user data, ...). |
| odomPose | Odometry pose; must be non-null in RGB-D SLAM mode. Pass a null Transform to fall back to appearance-only mode. |
| odomCovariance | 6x6 odometry covariance (default: identity). |
| odomVelocity | Optional 6-vector (vx, vy, vz, vroll, vpitch, vyaw). |
| externalStats | Extra named statistics to record in the database for this iteration. |
data was added to the map (i.e. the memory update succeeded). | bool rtabmap::Rtabmap::process | ( | const SensorData & | data, |
| Transform | odomPose, | ||
| float | odomLinearVariance, | ||
| float | odomAngularVariance, | ||
| const std::vector< float > & | odomVelocity = std::vector< float >(), |
||
| const std::map< std::string, float > & | externalStats = std::map< std::string, float >() |
||
| ) |
Convenience overload: builds a diagonal covariance from scalar variances.
The 6x6 odometry covariance is constructed as diag(odomLinearVariance, odomLinearVariance, odomLinearVariance,
odomAngularVariance, odomAngularVariance, odomAngularVariance).
| bool rtabmap::Rtabmap::process | ( | const cv::Mat & | image, |
| int | id = 0, |
||
| const std::map< std::string, float > & | externalStats = std::map< std::string, float >() |
||
| ) |
Appearance-only convenience overload (loop-closure detection without odometry).
Equivalent to processing image alone, with no odometry pose. Useful for offline loop-closure benchmarking on image sequences.
| image | RGB or grayscale frame. |
| id | Optional frame id (0 = auto-generated). |
| externalStats | Extra named statistics to record in the database for this iteration. |
| void rtabmap::Rtabmap::init | ( | const ParametersMap & | parameters, |
| const std::string & | databasePath = "", |
||
| bool | loadDatabaseParameters = false |
||
| ) |
Initializes Rtabmap with parameters and a database.
| parameters | Parameters overriding default parameters and database parameters (see loadDatabaseParameters). |
| databasePath | Database input/output path. If empty, an in-memory database is used. If set and the file does not exist, it is created empty; if it exists, nodes and the visual word vocabulary are loaded into working memory. |
| loadDatabaseParameters | If true and an existing database is opened, the parameters stored inside the database are loaded and applied to this Rtabmap instance (then overridden by parameters). |
| void rtabmap::Rtabmap::init | ( | const std::string & | configFile = "", |
| const std::string & | databasePath = "", |
||
| bool | loadDatabaseParameters = false |
||
| ) |
Initializes Rtabmap from a configuration file and a database.
| configFile | Configuration file (*.ini) overriding default parameters and database parameters (see loadDatabaseParameters). |
| databasePath | Database input/output path; same semantics as the other init(). |
| loadDatabaseParameters | If true and an existing database is opened, the parameters stored inside the database are loaded and applied first, then overridden by values from configFile. |
| void rtabmap::Rtabmap::close | ( | bool | databaseSaved = true, |
| const std::string & | ouputDatabasePath = "" |
||
| ) |
Closes Rtabmap and releases the underlying Memory.
| databaseSaved | If true, the in-memory state is flushed to the database; if false, in-memory changes are discarded. |
| ouputDatabasePath | If non-empty, the database is copied to this path on close. If a database on disk was initially created/loaded on a different path, it will be updated with the latest changes and renamed to the output path. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| int rtabmap::Rtabmap::getLastLocationId | ( | ) | const |
| std::list< int > rtabmap::Rtabmap::getWM | ( | ) | const |
| std::set< int > rtabmap::Rtabmap::getSTM | ( | ) | const |
| int rtabmap::Rtabmap::getWMSize | ( | ) | const |
| int rtabmap::Rtabmap::getSTMSize | ( | ) | const |
| std::map< int, int > rtabmap::Rtabmap::getWeights | ( | ) | const |
| int rtabmap::Rtabmap::getTotalMemSize | ( | ) | const |
|
inline |
| bool rtabmap::Rtabmap::isInSTM | ( | int | locationId | ) | const |
locationId is currently in short-term memory. | bool rtabmap::Rtabmap::isIDsGenerated | ( | ) | const |
| const Statistics & rtabmap::Rtabmap::getStatistics | ( | ) | const |
|
inline |
|
inline |
| Transform rtabmap::Rtabmap::getPose | ( | int | locationId | ) | const |
locationId in the current local map (identity if not present).
|
inline |
This is the correction applied to incoming odometry poses so they align with the latest graph optimization output. Updated whenever a loop closure or proximity detection re-optimizes the graph.
In ROS terms, this corresponds to the standard /map -> /odom TF transform published by SLAM systems: composing it with the live odometry pose (/odom -> /base_link) yields the robot pose in the map frame.
|
inline |
|
inline |
|
inline |
|
inline |
In localization mode, this is the corrected odometry pose of the last processed frame. In mapping mode, this is the last pose returned by getLocalOptimizedPoses().
|
inline |
| void rtabmap::Rtabmap::setTimeThreshold | ( | float | maxTimeAllowed | ) |
Sets the per-iteration time budget (ms).
Drives how aggressively WM is transferred to LTM to keep iterations under the threshold. 0 disables the time bound.
|
inline |
| void rtabmap::Rtabmap::setMemoryThreshold | ( | int | maxMemoryAllowed | ) |
Sets the maximum number of signatures kept in WM (0 = unbounded).
| void rtabmap::Rtabmap::setInitialPose | ( | const Transform & | initialPose | ) |
Sets the localization prior pose used to seed the next process() call (localization mode only).
Tells RTAB-Map where the robot is currently located in the map frame, so that the very next call to process() can align incoming odometry with the persisted map without waiting for a loop closure. Typical use cases: restoring localization after a session restart, applying an external pose estimate (e.g. from a GPS or a known starting point), or recovering from "kidnapped robot" situations.
This call only stages state; it does not itself produce a non-identity getMapCorrection(). The alignment between the odometry frame and the map frame is performed on the next process() call, which consumes initialPose together with the incoming odometry pose. Two branches are taken depending on Parameters::kRGBDOptimizeFromGraphEnd():
initialPose in the map frame (the optimized map is left untouched).initialPose (the map correction stays close to identity).The transform applied is restricted by SLAM dimensionality: 3-DoF (x, y, yaw) for 2D SLAM, 4-DoF (x, y, z, yaw) when gravity is available (IMU orientation or Memory::isOdomGravityUsed()) and Parameters::kOptimizerGravitySigma() is non-zero, full 6-DoF otherwise.
Side effects on the staged state:
initialPose; the localization covariance, the last localization node id and the odometry cache used for loop-closure rejection are all cleared.After the next process() consumes the prior, the nearest optimized node to initialPose is recorded as the last localization node.
| initialPose | Robot pose in the map frame. |
| int rtabmap::Rtabmap::triggerNewMap | ( | ) |
Starts a new map session (next process() will create a fresh map id).
In mapping mode, this increments the map id, clears the local optimized graph and resets the Bayes filter. In localization mode, it resets the map correction, the localization node and the odometry cache; if Parameters::kRGBDStartAtOrigin() is enabled, the last localization pose is reset to identity.
| bool rtabmap::Rtabmap::labelLocation | ( | int | id, |
| const std::string & | label | ||
| ) |
Assigns or clears a label on signature id.
| bool rtabmap::Rtabmap::setUserData | ( | int | id, |
| const cv::Mat & | data | ||
| ) |
Attaches user data to signature id, compressing it on the fly if needed.
The format is detected automatically: a single-row CV_8UC1 matrix is treated as already-compressed data and stored as-is; anything else is considered raw and compressed before being stored.
| id | Target signature id (must be in WM/STM or LTM). |
| data | Raw or pre-compressed user data. |
| void rtabmap::Rtabmap::generateDOTGraph | ( | const std::string & | path, |
| int | id = 0, |
||
| int | margin = 5 |
||
| ) |
Writes a Graphviz DOT file of the pose graph.
| path | Output file path. |
| id | If non-zero, root the graph at id; otherwise use the last signature. |
| margin | Maximum graph depth around id to include. |
| void rtabmap::Rtabmap::exportPoses | ( | const std::string & | path, |
| bool | optimized, | ||
| bool | global, | ||
| int | format | ||
| ) |
Exports the current pose graph to a text file.
Forwards to graph::exportPoses() after collecting either the optimized or the raw odometry poses (and the matching constraints when needed).
| path | Output file path. |
| optimized | If true, export optimized poses; otherwise raw odometry poses. |
| global | If true, include nodes from LTM as well; otherwise only WM/STM. |
| format | Output format code; see graph::exportPoses() for the full list of supported values (raw, RGBD-SLAM/TUM, KITTI, TORO, g2o, ...). |
| void rtabmap::Rtabmap::resetMemory | ( | ) |
Clears all in-memory state and resets the database.
In incremental mode, also clears the persisted map. In read-only memory mode, resets the in-memory state but leaves the database untouched.
|
inline |
| void rtabmap::Rtabmap::setWorkingDirectory | ( | std::string | path | ) |
Sets the working directory used for dumps, logs and temporary files.
Can also be configured through Parameters::kRtabmapWorkingDirectory() in the parameter map passed to init() or parseParameters().
| void rtabmap::Rtabmap::rejectLastLoopClosure | ( | ) |
Removes the loop-closure link added at the last process() iteration.
Looks at the last non-intermediate signature in STM and erases any Link::kGlobalClosure, Link::kLocalSpaceClosure, Link::kLocalTimeClosure or Link::kUserClosure attached to it. The current optimized map is updated accordingly.
| void rtabmap::Rtabmap::deleteLastLocation | ( | ) |
Deletes the most recent (non-intermediate) location from the map.
Used by tools to undo the very last process() iteration. In mapping mode, the optimized graph is recomputed without the deleted node.
| void rtabmap::Rtabmap::setOptimizedPoses | ( | const std::map< int, Transform > & | poses, |
| const std::multimap< int, Link > & | constraints | ||
| ) |
Replaces the current optimized poses and constraints with externally provided ones.
Useful when graph optimization is performed outside of Rtabmap.
poses and constraints overwrite the internal containers verbatim. The caller is responsible for ensuring that every id in poses (and every endpoint of every link in constraints) belongs to a signature currently in STM or WM (see Memory::isInSTM() / Memory::isInWM()). Passing poses for ids that are no longer loaded will leave dangling entries that may confuse subsequent process() calls. | Signature rtabmap::Rtabmap::getSignatureCopy | ( | int | id, |
| bool | images, | ||
| bool | scan, | ||
| bool | userData, | ||
| bool | occupancyGrid, | ||
| bool | withWords, | ||
| bool | withGlobalDescriptors | ||
| ) | const |
Returns a copy of signature id with optional payloads attached.
Loads from WM/STM if present, otherwise from LTM. Selectively populates the returned Signature with images, scan, user data, occupancy grid, visual words and global descriptors.
| void rtabmap::Rtabmap::getGraph | ( | std::map< int, Transform > & | poses, |
| std::multimap< int, Link > & | constraints, | ||
| bool | optimized, | ||
| bool | global, | ||
| std::map< int, Signature > * | signatures = 0, |
||
| bool | withImages = false, |
||
| bool | withScan = false, |
||
| bool | withUserData = false, |
||
| bool | withGrid = false, |
||
| bool | withWords = true, |
||
| bool | withGlobalDescriptors = true |
||
| ) | const |
Extracts a full snapshot of the current pose graph.
| poses | Output: pose for every selected node. |
| constraints | Output: links between selected nodes. |
| optimized | If true, return optimized poses; otherwise raw odometry poses. |
| global | If true, include nodes from LTM as well; otherwise only WM/STM. |
| signatures | Optional output: a copy of each node's Signature (with the payloads requested by the with* flags). |
| withImages | Attach compressed RGB/depth images to signatures. |
| withScan | Attach laser scan blob. |
| withUserData | Attach user data blob. |
| withGrid | Attach occupancy grid cells. |
| withWords | Attach visual words (id, keypoints, 3D points, descriptors). |
| withGlobalDescriptors | Attach global descriptors. |
| std::map< int, Transform > rtabmap::Rtabmap::getNodesInRadius | ( | const Transform & | pose, |
| float | radius, | ||
| int | k = 0, |
||
| std::map< int, float > * | distsSqr = 0 |
||
| ) |
Returns optimized poses within a metric radius of pose.
| pose | Query pose in the map frame. |
| radius | Search radius in meters (0 falls back to Parameters::kRGBDLocalRadius()). |
| k | If non-zero, also cap the result to the k nearest neighbors. |
| distsSqr | Optional output: per-id squared distance to pose. |
| std::map< int, Transform > rtabmap::Rtabmap::getNodesInRadius | ( | int | nodeId, |
| float | radius, | ||
| int | k = 0, |
||
| std::map< int, float > * | distsSqr = 0 |
||
| ) |
Returns optimized poses within a metric radius of node nodeId.
| nodeId | Query node id. Pass 0 to query around the latest node. A negative id requests neighbors of the corresponding landmark. |
| radius | Search radius in meters (0 falls back to Parameters::kRGBDLocalRadius()). |
| k | If non-zero, cap the result to the k nearest neighbors. |
| distsSqr | Optional output: per-id squared distance to nodeId. |
| int rtabmap::Rtabmap::detectMoreLoopClosures | ( | float | clusterRadiusMax = 0.5f, |
| float | clusterAngle = M_PI/6.0f, |
||
| int | iterations = 1, |
||
| bool | intraSession = true, |
||
| bool | interSession = true, |
||
| const ProgressState * | state = 0, |
||
| float | clusterRadiusMin = 0.0f, |
||
| int | toFromMapId = -1 |
||
| ) |
Post-processing: searches for additional loop closures over the existing graph.
Clusters nearby optimized poses and runs registration between candidates that are not yet linked. New links are added to Memory and the graph is re-optimized.
| clusterRadiusMax | Maximum metric distance (m) between two candidate nodes. |
| clusterAngle | Maximum angular distance (rad) between two candidate nodes. |
| iterations | Number of refinement passes. |
| intraSession | Include loop closures within the same map session. |
| interSession | Include loop closures between different map sessions. |
| state | Optional progress sink; cancellation requests are honored. |
| clusterRadiusMin | Minimum metric distance (m); pairs closer than this are considered already linked through neighbor links. |
| toFromMapId | If >=0, restrict candidate pairs to nodes belonging to this map id. |
| bool rtabmap::Rtabmap::globalBundleAdjustment | ( | int | optimizerType = 1, |
| bool | rematchFeatures = true, |
||
| int | iterations = 0, |
||
| float | pixelVariance = 0.0f |
||
| ) |
Runs a global bundle adjustment over the optimized graph.
| optimizerType | Backend optimizer (e.g. 1=g2o); availability depends on what RTAB-Map was built with. |
| rematchFeatures | If true, re-match visual features between connected nodes before BA (otherwise reuse existing word-id correspondences). |
| iterations | Solver iterations (0 falls back to Parameters::kOptimizerIterations()). |
| pixelVariance | Pixel reprojection variance used by the cost (0 falls back to Parameters::kOptimizerPixelVariance()). |
| int rtabmap::Rtabmap::cleanupLocalGrids | ( | const std::map< int, Transform > & | mapPoses, |
| const cv::Mat & | map, | ||
| float | xMin, | ||
| float | yMin, | ||
| float | cellSize, | ||
| int | cropRadius = 1, |
||
| bool | filterScans = false |
||
| ) |
Filters spurious obstacles from every node's local grid using a reference 2D map.
Thin wrapper around Memory::cleanupLocalGrids(); see that method for the exact filtering rule and the meaning of cropRadius and filterScans.
| int rtabmap::Rtabmap::refineLinks | ( | ) |
Re-runs registration on every link of the current graph and updates the ones that converge.
Useful after parameter changes to refresh stored transforms.
| bool rtabmap::Rtabmap::addLink | ( | const Link & | link | ) |
Adds an external link to the map.
The link's "from" and "to" endpoints must exist in memory (incremental mode) or in the optimized poses (localization mode). RGB-D mode only.
| void rtabmap::Rtabmap::addNodesToRepublish | ( | const std::vector< int > & | ids | ) |
Marks node ids whose data should be re-emitted on the next process().
The requested signatures are attached to the Statistics object produced by the next process() call (via the same mechanism as the regular "last signature data"), so consumers reading getStatistics() pick them up alongside the normal output. Up to Parameters::kRtabmapMaxRepublished() ids are emitted per iteration; any leftover ids stay queued for subsequent iterations until they are republished or fall out of the current graph.
Pass an empty vector to clear the request set. Requires Parameters::kRtabmapMaxRepublished() > 0 and Parameters::kRtabmapPublishLastSignature() = true.
| void rtabmap::Rtabmap::setDummyDictionary | ( | bool | enabled = true | ) |
Loads the visual word dictionary as ids only, without descriptors.
With a dummy dictionary, init() populates VWDictionary with placeholder VisualWord objects carrying an empty descriptor, and the dictionary update (FLANN index construction) is skipped. This makes opening a large database much faster and lighter in RAM when the word descriptors are not needed, e.g. to inspect or post-process an existing map rather than to localize in it.
The dummy dictionary is silently disabled if the database has no words, or if the dictionary has to be rebuilt from the nodes because it was not saved properly.
| enabled | True to load ids only, false to load the full dictionary (default). |
Memory::createSignature(). Loop closure detection also cannot match new observations against a descriptor-less dictionary.
|
inline |
| void rtabmap::Rtabmap::clearPath | ( | int | status | ) |
Clears the current path and sets its terminal status.
| status | -1 = failed, 0 = idle / executing, 1 = success. |
| bool rtabmap::Rtabmap::computePath | ( | int | targetNode, |
| bool | global | ||
| ) |
Plans a path from the current location to node targetNode.
RGB-D mode only (requires Parameters::kRGBDEnabled() = true).
| targetNode | Destination node id (positive) or landmark id (negative). |
| global | If true, also search nodes in LTM; otherwise only the current optimized map. |
| bool rtabmap::Rtabmap::computePath | ( | const Transform & | targetPose, |
| float | tolerance = -1.0f |
||
| ) |
Plans a path in the current optimized map toward a metric goal pose.
| targetPose | Goal pose in the map frame. |
| tolerance | Goal-acceptance tolerance (meters). A negative value falls back to Parameters::kRGBDLocalRadius(); 0 means infinite tolerance. |
|
inline |
| std::vector< std::pair< int, Transform > > rtabmap::Rtabmap::getPathNextPoses | ( | ) | const |
| std::vector< int > rtabmap::Rtabmap::getPathNextNodes | ( | ) | const |
| int rtabmap::Rtabmap::getPathCurrentGoalId | ( | ) | const |
|
inline |
|
inline |
|
inline |
| std::map< int, Transform > rtabmap::Rtabmap::getForwardWMPoses | ( | int | fromId, |
| int | maxNearestNeighbors, | ||
| float | radius, | ||
| int | maxDiffID | ||
| ) | const |
Returns optimized poses of WM nodes located in front of fromId.
Candidates are first gathered around fromId, then STM nodes are excluded, the survivors are cropped to a forward-facing box of width radius (1 m behind, radius ahead, +/-radius laterally), and a KdTree radius search keeps the maxNearestNeighbors closest poses in that box.
fromId: nodes reachable within maxDiffID graph hops AND within radius meters in the optimized poses.radius meters of fromId is considered. The forward-box crop and KdTree radius search that follow are identical in both modes.| fromId | Reference node (must be in Memory and getLocalOptimizedPoses()). |
| maxNearestNeighbors | Cap on the number of nodes returned. |
| radius | Maximum metric distance from fromId (meters). |
| maxDiffID | Maximum graph depth from fromId in mapping mode (0 = unlimited). Ignored in localization mode. |
| std::map< int, std::map< int, Transform > > rtabmap::Rtabmap::getPaths | ( | const std::map< int, Transform > & | poses, |
| const Transform & | target, | ||
| int | maxGraphDepth = 0 |
||
| ) | const |
Segments a set of optimized poses into paths connected by neighbor links.
Designed to be called on the result of a radius search around target (a set of poses already constrained to be metrically close to the goal). Within that radius, the method partitions the poses into one or more "paths" where each path is a connected component reachable from its starting node using only neighbor (sequential) links – loop-closure links, landmark links and intermediate nodes are not used to traverse between members. Paths are produced one at a time, each starting from the still-unclaimed pose nearest to target; a candidate is added to the current path only if it has at least one neighbor link to a node already in the path.
Used internally by proximity detection by space (see Parameters::kRGBDProximityBySpace()) in two independent stages, each iterating over the segmented paths:
| poses | Candidate nodes with their optimized poses (typically pre-filtered to a radius around target). |
| target | Reference pose used to order paths: each path's starting node is the still-unclaimed pose closest to target. |
| maxGraphDepth | Maximum graph depth traversed from the starting node when gathering candidates for a path (0 = unlimited). |
| void rtabmap::Rtabmap::adjustLikelihood | ( | std::map< int, float > & | likelihood | ) | const |
Applies the standard RTAB-Map likelihood adjustment.
Normalizes raw likelihoods using mean and standard deviation across non-null values. Real-place entries with value <= mean + stdDev are clamped to 1.0; only entries above that threshold are scaled. The virtual place (the first key in likelihood, representing the "new place" hypothesis) is then set so that its likelihood reflects how peaked the real distribution is.
The exact formulas are selected by Parameters::kRtabmapVirtualPlaceLikelihoodRatio() (default 0, Angeli PhD formulation):
(value - (stdDev - epsilon)) / meanmean / stdDev + 1 (when stdDev is non-trivial and a maximum exists; otherwise 2). The virtual place "wins" when the real-place distribution is flat (small stdDev relative to mean).(value - mean) / stdDev (i.e. the z-score).stdDev / (max - mean) + 1 (when max > mean; otherwise 2). The virtual place "wins" when no real candidate stands out far above the mean.In both formulations a low virtual-place likelihood favors a real-place loop closure on the next Bayes update; a high one favors the "new place" hypothesis.