Skip to content

Commit

Permalink
use flatten() to get non-none tf_static message thanks to clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasw committed Sep 15, 2024
1 parent 11c76e3 commit d193c3d
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions mcap_tools/src/mcap_play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,27 +107,25 @@ async fn mcap_playback_init(
// topic? The easiest thing would be to save tf_static to a separate mcap in the
// first place, more advanced would be for mcap_record to put all the statics
// in a separate chunk but then 'mcap convert' wouldn't do that.
for message_raw in mcap::MessageStream::new(mapped)? {
if let Ok(message) = message_raw {
if message.channel.topic != "/tf_static" {
continue;
}
let msg_with_header = misc::get_message_data_with_header(message.data);
match serde_rosmsg::from_slice::<tf2_msgs::TFMessage>(&msg_with_header) {
Ok(tf_msg) => {
log::info!(
"{mcap_name} adding {} transforms to tf_static, total {}\r",
tf_msg.transforms.len(),
tf_msg.transforms.len() + tf_static_aggregated.transforms.len(),
);
for transform in tf_msg.transforms {
tf_static_aggregated.transforms.push(transform);
}
}
Err(err) => {
log::error!("{mcap_name} {err:?}");
for message in (mcap::MessageStream::new(mapped)?).flatten() {
if message.channel.topic != "/tf_static" {
continue;
}
let msg_with_header = misc::get_message_data_with_header(message.data);
match serde_rosmsg::from_slice::<tf2_msgs::TFMessage>(&msg_with_header) {
Ok(tf_msg) => {
log::info!(
"{mcap_name} adding {} transforms to tf_static, total {}\r",
tf_msg.transforms.len(),
tf_msg.transforms.len() + tf_static_aggregated.transforms.len(),
);
for transform in tf_msg.transforms {
tf_static_aggregated.transforms.push(transform);
}
}
Err(err) => {
log::error!("{mcap_name} {err:?}");
}
}
}
}
Expand Down

0 comments on commit d193c3d

Please sign in to comment.