drawable_submap.cpp¶
src/drawable_submap.cpp implements the DrawableSubmap class declared in drawable_submap.h.
Constants¶
kMinQueryDelayInMs = 250— minimum delay between texture queries to avoid flooding the service.kAlphaUpdateThreshold = 0.2f— alpha is only updated when it changes by more than this amount (unless it is exactly 0 or 1).kSubmapIdColor(red),kSubmapIdPosition(0, 0, 0.3),kSubmapIdCharHeight = 0.2f— styling of the submap ID label.kNumberOfSlicesPerSubmap = 2— each submap is rendered with a high- and a low-resolution slice.
Constructor¶
Creates a child scene node under the map node, creates the two OgreSlice objects, creates the visibility_ BoolProperty (parented to the submap category), sets up the red submap-ID text label (“(trajectory_id,submap_index)”) above the submap origin, applies the initial pose-marker visibility, and connects the RequestSucceeded() signal to the UpdateSceneNode() slot.
Destructor¶
If a texture query is in progress, waits on rpc_request_future_ (Qt then guarantees RequestSucceeded is not delivered after destruction). Destroys the submap and ID-text scene nodes.
Update¶
Stores the new metadata version and pose, applies the pose to the submap scene node, requests a render, and renames the visibility property to "<submap_index>.<version>" with a descriptive tooltip (trajectory, submap, version).
MaybeFetchTexture¶
Under the mutex, it checks three conditions: a newer texture version exists (submap_textures_ is null or its version differs), the last query was not within kMinQueryDelayInMs, and no query is in progress. If all hold, it marks a query in progress and launches an asynchronous task that calls cartographer_ros::FetchSubmapTextures() with a 10-second timeout. On success it stores the textures and emits RequestSucceeded(). Returns true if a query was started.
SetAlpha¶
Computes the z distance between the submap pose and the current tracking z, scales it against the fade-out band (which spans twice the configured start distance), and derives a target alpha. If the change is significant (or the alpha reaches 0 or 1), it updates current_alpha_ and applies it to every slice, then requests a render.
SetSliceVisibility / ToggleVisibility¶
SetSliceVisibility forwards to the given slice and re-evaluates node visibility. ToggleVisibility updates every slice node to the visibility property value.
UpdateSceneNode¶
Called via the Qt signal after a successful query: applies each fetched texture to the corresponding OgreSlice and requests a render.
TogglePoseMarkerVisibility¶
Shows/hides the submap ID text node and the pose-axes scene node.