Checklist
Description
Nodes across Autoware Core disagree on how to treat empty inputs, with some throwing exceptions, others blocking, and some silently failing. This inconsistency leads to fragile pipelines where empty point clouds or trajectories can crash downstream nodes. This aligns with Anti-pattern 3 in the system performance documentation.
Purpose
The purpose of this task is to:
- Establish consistent empty-data handling policies across all nodes
- Prevent crashes from empty sensor messages and trajectories
- Define clear contracts for empty-input behavior
- Improve system robustness during sensor failures or initialization
Possible approaches
Approach 1: Explicit Empty-Data Contract (Recommended)
/// Contract: Empty cloud means "no detection"; publish empty results.
/// Never throw on empty input; never block waiting for non-empty.
void onCloud(const sensor_msgs::msg::PointCloud2 &cloud) {
if (cloud.width == 0 || cloud.height == 0 || cloud.data.empty()) {
MyResult empty;
empty.header = cloud.header;
empty.detections.clear(); // Explicitly empty
pub_->publish(empty);
RCLCPP_DEBUG(get_logger(), "Received empty cloud, publishing empty result");
return;
}
// Normal processing...
}
Approach 2: Guard Clauses with Logging
// Early return pattern with appropriate logging
if (points.empty()) {
RCLCPP_WARN_THROTTLE(get_logger(), *get_clock(), 1000,
"Empty trajectory received, skipping processing");
return;
}
Approach 3: Default Value Propagation
// Return safe defaults instead of throwing
if (cluster.points.empty()) {
geometry_msgs::msg::Point centroid;
centroid.x = centroid.y = centroid.z = 0.0;
return centroid; // Valid but neutral value
}
Definition of done
Critical Fixes
System-wide Standardization
Testing and Validation
Checklist
Description
Nodes across Autoware Core disagree on how to treat empty inputs, with some throwing exceptions, others blocking, and some silently failing. This inconsistency leads to fragile pipelines where empty point clouds or trajectories can crash downstream nodes. This aligns with Anti-pattern 3 in the system performance documentation.
Purpose
The purpose of this task is to:
Possible approaches
Approach 1: Explicit Empty-Data Contract (Recommended)
Approach 2: Guard Clauses with Logging
Approach 3: Default Value Propagation
Definition of done
Critical Fixes
euclidean_cluster_node: Add empty cloud checksvoxel_grid_based_euclidean_cluster: Add empty validationmotion_utils/getCentroid: Handle zero-size clustersSystem-wide Standardization
Testing and Validation