Skip to content

Commit 4505bfe

Browse files
authored
Include FrameId in error reporting for transform resolution (#11985)
### Related * Closes RR-2997. * [x] Merge after #11977. ### What Now that we have `TransformHashId` lookup functionality in `TransformTreeContext` we can print better error message.
1 parent 270f922 commit 4505bfe

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

crates/viewer/re_view_spatial/src/contexts/transform_tree_context.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ impl TransformTreeContext {
205205
) -> Option<&TransformFrameId> {
206206
self.frame_id_mapping.get(&frame_id_hash)
207207
}
208+
209+
/// Formats a frame ID hash as a human-readable string.
210+
///
211+
/// Returns the frame name if known, otherwise returns a debug representation of the hash.
212+
#[inline]
213+
pub fn format_frame(&self, frame_id_hash: TransformFrameIdHash) -> String {
214+
self.lookup_frame_id(frame_id_hash)
215+
.map_or_else(|| format!("{frame_id_hash:?}"), ToString::to_string)
216+
}
208217
}
209218

210219
fn lookup_image_plane_distance(

crates/viewer/re_view_spatial/src/visualizers/transform_axes_3d.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl VisualizerSystem for TransformAxes3DVisualizer {
158158
self.0
159159
.ui_labels
160160
.extend(transforms_to_draw.iter().map(|transform| UiLabel {
161-
text: frame_id.0.clone().into(),
161+
text: frame_id.to_string(),
162162
style: UiLabelStyle::Default,
163163
target: UiLabelTarget::Position3D(
164164
transform.transform_point3(glam::Vec3::ZERO),

crates/viewer/re_view_spatial/src/visualizers/utilities/transform_retrieval.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,34 @@ pub fn transform_info_for_entity_or_report_error<'a>(
1919
None
2020
}
2121

22-
Some(Err(re_tf::TransformFromToError::NoPathBetweenFrames { .. })) => {
23-
// TODO(RR-2997): Pretty print out the frames involved.
22+
Some(Err(re_tf::TransformFromToError::NoPathBetweenFrames { src, target, .. })) => {
23+
let src = transform_context.format_frame(*src);
24+
let target = transform_context.format_frame(*target);
2425
output.report_error_for(
2526
entity_path.clone(),
26-
"No transform path to the view's origin frame.",
27+
format!("No transform path from {src} to the view's origin frame ({target})."),
2728
);
2829
None
2930
}
3031

31-
Some(Err(re_tf::TransformFromToError::UnknownTargetFrame { .. })) => {
32+
Some(Err(re_tf::TransformFromToError::UnknownTargetFrame(target))) => {
3233
// The target frame is the view's origin.
3334
// This means this could be hit if the view's origin frame doesn't show up in any data.
34-
// TODO(RR-2997): Pretty print out the frames involved.
35-
output.report_error_for(entity_path.clone(), "The view's origin frame is unknown.");
35+
let target = transform_context.format_frame(*target);
36+
output.report_error_for(
37+
entity_path.clone(),
38+
format!("The view's origin frame {target} is unknown."),
39+
);
3640
None
3741
}
3842

39-
Some(Err(re_tf::TransformFromToError::UnknownSourceFrame { .. })) => {
43+
Some(Err(re_tf::TransformFromToError::UnknownSourceFrame(src))) => {
4044
// Unclear how we'd hit this. This means that when processing transforms we encountered a coordinate frame that the transform cache didn't know about.
4145
// That would imply that the cache is lagging behind.
42-
// TODO(RR-2997): Pretty print out the frames involved.
46+
let src = transform_context.format_frame(*src);
4347
output.report_error_for(
4448
entity_path.clone(),
45-
"The entity's coordinate frame is unknown.",
49+
format!("The entity's coordinate frame {src} is unknown."),
4650
);
4751
None
4852
}

0 commit comments

Comments
 (0)