Skip to content

Commit 18755b5

Browse files
authored
Merge pull request #1199 from tier4/hotfix/shape_estimation
fix(shape estimation): 5330 + 6157 + 6598
2 parents 37dfa79 + 290b42b commit 18755b5

File tree

8 files changed

+94
-26
lines changed

8 files changed

+94
-26
lines changed

perception/shape_estimation/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,5 @@ rclcpp_components_register_node(shape_estimation_node
6464

6565
ament_auto_package(INSTALL_TO_SHARE
6666
launch
67+
config
6768
)

perception/shape_estimation/README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ This node calculates a refined object shape (bounding box, cylinder, convex hull
3636

3737
## Parameters
3838

39-
| Name | Type | Default Value | Description |
40-
| --------------------------- | ---- | ------------- | --------------------------------------------------- |
41-
| `use_corrector` | bool | true | The flag to apply rule-based filter |
42-
| `use_filter` | bool | true | The flag to apply rule-based corrector |
43-
| `use_vehicle_reference_yaw` | bool | true | The flag to use vehicle reference yaw for corrector |
39+
{{ json_to_markdown("perception/shape_estimation/schema/shape_estimation.schema.json") }}
4440

4541
## Assumptions / Known limits
4642

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**:
2+
ros__parameters:
3+
use_corrector: true
4+
use_filter: true
5+
use_vehicle_reference_yaw: false
6+
use_vehicle_reference_shape_size: false
7+
use_boost_bbox_optimizer: false
8+
fix_filtered_objects_label_to_unknown: true
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
<launch>
22
<arg name="input/objects" default="labeled_clusters"/>
33
<arg name="output/objects" default="shape_estimated_objects"/>
4-
<arg name="use_filter" default="true"/>
5-
<arg name="use_corrector" default="true"/>
64
<arg name="node_name" default="shape_estimation"/>
7-
<arg name="use_vehicle_reference_yaw" default="false"/>
8-
<arg name="use_vehicle_reference_shape_size" default="false"/>
9-
<arg name="use_boost_bbox_optimizer" default="false"/>
5+
<!-- Parameter -->
6+
<arg name="config_file" default="$(find-pkg-share shape_estimation)/config/shape_estimation.param.yaml"/>
7+
108
<node pkg="shape_estimation" exec="shape_estimation" name="$(var node_name)" output="screen">
119
<remap from="input" to="$(var input/objects)"/>
1210
<remap from="objects" to="$(var output/objects)"/>
13-
<param name="use_filter" value="$(var use_filter)"/>
14-
<param name="use_corrector" value="$(var use_corrector)"/>
15-
<param name="use_vehicle_reference_yaw" value="$(var use_vehicle_reference_yaw)"/>
16-
<param name="use_boost_bbox_optimizer" value="$(var use_boost_bbox_optimizer)"/>
11+
<param from="$(var config_file)"/>
1712
</node>
1813
</launch>

perception/shape_estimation/lib/shape_estimator.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,31 @@ bool ShapeEstimator::estimateShapeAndPose(
3939
autoware_auto_perception_msgs::msg::Shape shape;
4040
geometry_msgs::msg::Pose pose;
4141
// estimate shape
42+
bool reverse_to_unknown = false;
4243
if (!estimateOriginalShapeAndPose(label, cluster, ref_yaw_info, shape, pose)) {
43-
return false;
44+
reverse_to_unknown = true;
4445
}
4546

4647
// rule based filter
4748
if (use_filter_) {
4849
if (!applyFilter(label, shape, pose)) {
49-
return false;
50+
reverse_to_unknown = true;
5051
}
5152
}
5253

5354
// rule based corrector
5455
if (use_corrector_) {
5556
bool use_reference_yaw = ref_yaw_info ? true : false;
5657
if (!applyCorrector(label, use_reference_yaw, ref_shape_size_info, shape, pose)) {
57-
return false;
58+
reverse_to_unknown = true;
5859
}
5960
}
60-
61+
if (reverse_to_unknown) {
62+
estimateOriginalShapeAndPose(Label::UNKNOWN, cluster, ref_yaw_info, shape, pose);
63+
shape_output = shape;
64+
pose_output = pose;
65+
return false;
66+
}
6167
shape_output = shape;
6268
pose_output = pose;
6369
return true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Parameters for Shape Estimation Node",
4+
"type": "object",
5+
"definitions": {
6+
"shape_estimation": {
7+
"type": "object",
8+
"properties": {
9+
"use_corrector": {
10+
"type": "boolean",
11+
"description": "The flag to apply rule-based corrector.",
12+
"default": "true"
13+
},
14+
"use_filter": {
15+
"type": "boolean",
16+
"description": "The flag to apply rule-based filter",
17+
"default": "true"
18+
},
19+
"use_vehicle_reference_yaw": {
20+
"type": "boolean",
21+
"description": "The flag to use vehicle reference yaw for corrector",
22+
"default": "false"
23+
},
24+
"use_vehicle_reference_shape_size": {
25+
"type": "boolean",
26+
"description": "The flag to use vehicle reference shape size",
27+
"default": "false"
28+
},
29+
"use_boost_bbox_optimizer": {
30+
"type": "boolean",
31+
"description": "The flag to use boost bbox optimizer",
32+
"default": "false"
33+
}
34+
},
35+
"required": [
36+
"use_corrector",
37+
"use_filter",
38+
"use_vehicle_reference_yaw",
39+
"use_vehicle_reference_shape_size",
40+
"use_boost_bbox_optimizer"
41+
]
42+
}
43+
},
44+
"properties": {
45+
"/**": {
46+
"type": "object",
47+
"properties": {
48+
"ros__parameters": {
49+
"$ref": "#/definitions/shape_estimation"
50+
}
51+
},
52+
"required": ["ros__parameters"]
53+
}
54+
},
55+
"required": ["/**"]
56+
}

perception/shape_estimation/src/node.cpp

+13-8
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ ShapeEstimationNode::ShapeEstimationNode(const rclcpp::NodeOptions & node_option
4242
"input", rclcpp::QoS{1}, std::bind(&ShapeEstimationNode::callback, this, _1));
4343

4444
pub_ = create_publisher<DetectedObjectsWithFeature>("objects", rclcpp::QoS{1});
45-
bool use_corrector = declare_parameter("use_corrector", true);
46-
bool use_filter = declare_parameter("use_filter", true);
47-
use_vehicle_reference_yaw_ = declare_parameter("use_vehicle_reference_yaw", true);
48-
use_vehicle_reference_shape_size_ = declare_parameter("use_vehicle_reference_shape_size", true);
49-
bool use_boost_bbox_optimizer = declare_parameter("use_boost_bbox_optimizer", false);
45+
bool use_corrector = declare_parameter<bool>("use_corrector");
46+
bool use_filter = declare_parameter<bool>("use_filter");
47+
use_vehicle_reference_yaw_ = declare_parameter<bool>("use_vehicle_reference_yaw");
48+
use_vehicle_reference_shape_size_ = declare_parameter<bool>("use_vehicle_reference_shape_size");
49+
bool use_boost_bbox_optimizer = declare_parameter<bool>("use_boost_bbox_optimizer");
50+
fix_filtered_objects_label_to_unknown_ =
51+
declare_parameter<bool>("fix_filtered_objects_label_to_unknown");
5052
RCLCPP_INFO(this->get_logger(), "using boost shape estimation : %d", use_boost_bbox_optimizer);
5153
estimator_ =
5254
std::make_unique<ShapeEstimator>(use_corrector, use_filter, use_boost_bbox_optimizer);
@@ -96,12 +98,15 @@ void ShapeEstimationNode::callback(const DetectedObjectsWithFeature::ConstShared
9698
const bool estimated_success = estimator_->estimateShapeAndPose(
9799
label, *cluster, ref_yaw_info, ref_shape_size_info, shape, pose);
98100

99-
// If the shape estimation fails, ignore it.
100-
if (!estimated_success) {
101+
// If the shape estimation fails, change to Unknown object.
102+
if (!fix_filtered_objects_label_to_unknown_ && !estimated_success) {
101103
continue;
102104
}
103-
104105
output_msg.feature_objects.push_back(feature_object);
106+
if (!estimated_success) {
107+
output_msg.feature_objects.back().object.classification.front().label = Label::UNKNOWN;
108+
}
109+
105110
output_msg.feature_objects.back().object.shape = shape;
106111
output_msg.feature_objects.back().object.kinematics.pose_with_covariance.pose = pose;
107112
}

perception/shape_estimation/src/node.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class ShapeEstimationNode : public rclcpp::Node
3838
std::unique_ptr<ShapeEstimator> estimator_;
3939
bool use_vehicle_reference_yaw_;
4040
bool use_vehicle_reference_shape_size_;
41+
bool fix_filtered_objects_label_to_unknown_;
4142

4243
public:
4344
explicit ShapeEstimationNode(const rclcpp::NodeOptions & node_options);

0 commit comments

Comments
 (0)