Skip to content

Commit

Permalink
Fix transform entity path for PointCloud2, add additional checks
Browse files Browse the repository at this point in the history
  • Loading branch information
roym899 committed May 24, 2024
1 parent e862720 commit e8cecbe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions rerun_bridge/src/rerun_bridge/rerun_ros_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,17 +308,36 @@ void log_point_cloud2(
// TODO(leo) allow arbitrary color mapping

size_t x_offset, y_offset, z_offset;
bool has_x{false}, has_y{false}, has_z{false};

for (const auto& field : msg->fields) {
if (field.name == "x") {
x_offset = field.offset;
if(field.datatype != sensor_msgs::msg::PointField::FLOAT32) {
rec.log(entity_path, rerun::TextLog("Only FLOAT32 x field supported"));
return;
}
has_x = true;
} else if (field.name == "y") {
y_offset = field.offset;
if(field.datatype != sensor_msgs::msg::PointField::FLOAT32) {
rec.log(entity_path, rerun::TextLog("Only FLOAT32 y field supported"));
return;
}
} else if (field.name == "z") {
z_offset = field.offset;
if(field.datatype != sensor_msgs::msg::PointField::FLOAT32) {
rec.log(entity_path, rerun::TextLog("Only FLOAT32 z field supported"));
return;
}
}
}

if (!has_x || !has_y || !has_z) {
rec.log(entity_path, rerun::TextLog("Currently only PointCloud2 messages with x, y, z fields are supported"));
return;
}

std::vector<rerun::Position3D> points(msg->width * msg->height);
std::vector<rerun::Color> colors;

Expand Down
2 changes: 1 addition & 1 deletion rerun_bridge/src/rerun_bridge/visualizer_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ std::shared_ptr<rclcpp::Subscription<sensor_msgs::msg::PointCloud2>>
100ms
)
);
log_transform(_rec, parent_entity_path(entity_path), transform);
log_transform(_rec, entity_path, transform);
} catch (tf2::TransformException& ex) {
RCLCPP_WARN(this->get_logger(), "%s", ex.what());
}
Expand Down

0 comments on commit e8cecbe

Please sign in to comment.