Skip to content

Commit

Permalink
sort the tf tree output, and output all the parent-children pairs- ne…
Browse files Browse the repository at this point in the history
…ed to handle the case of disconnected trees next
  • Loading branch information
lucasw committed Sep 9, 2024
1 parent 4bcd097 commit 72f2370
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tf_roslibrust/src/bin/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ fn print_tree(

match parent_to_children.get(parent) {
Some(children) => {
let mut children = children.iter().collect::<Vec<_>>();
children.sort();
for child in children {
let _ = print_tree(parent_to_children, child, level + 1);
}
Expand Down Expand Up @@ -69,10 +71,18 @@ async fn main() -> Result<(), anyhow::Error> {
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;

{
// TODO(lucasw) make tf listener stop listening
let buffer = listener.buffer.read().unwrap();
let root = buffer.get_root()?;
println!("\n");
let parent_to_children = buffer.get_parent_to_children();
{
let mut keys_sorted = parent_to_children.keys().collect::<Vec<_>>();
keys_sorted.sort();
for parent in keys_sorted {
println!("{parent}: {:?}", parent_to_children.get(parent).unwrap());
}
}
let _ = print_tree(&parent_to_children, &root, 0);
}

Expand Down

0 comments on commit 72f2370

Please sign in to comment.