23
23
24
24
using Label = autoware_auto_perception_msgs::msg::ObjectClassification;
25
25
26
- ShapeEstimator::ShapeEstimator (bool use_corrector, bool use_filter, bool use_boost_bbox_optimizer)
26
+ ShapeEstimator::ShapeEstimator (std::vector<ShapeParameters> & shapes, bool use_corrector, bool use_filter, bool use_boost_bbox_optimizer)
27
27
: use_corrector_(use_corrector),
28
28
use_filter_(use_filter),
29
- use_boost_bbox_optimizer_(use_boost_bbox_optimizer)
29
+ use_boost_bbox_optimizer_(use_boost_bbox_optimizer),
30
+ shapes_(shapes)
30
31
{
31
32
}
32
33
@@ -38,6 +39,11 @@ bool ShapeEstimator::estimateShapeAndPose(
38
39
{
39
40
autoware_auto_perception_msgs::msg::Shape shape;
40
41
geometry_msgs::msg::Pose pose;
42
+
43
+ // get str name of label
44
+ std::string label_str = labelToString (label);
45
+ ShapeParameters shape_limitation = getShapeLimitation (label_str);
46
+
41
47
// estimate shape
42
48
bool reverse_to_unknown = false ;
43
49
if (!estimateOriginalShapeAndPose (label, cluster, ref_yaw_info, shape, pose)) {
@@ -46,7 +52,7 @@ bool ShapeEstimator::estimateShapeAndPose(
46
52
47
53
// rule based filter
48
54
if (use_filter_) {
49
- if (!applyFilter (label, shape, pose)) {
55
+ if (!applyFilter (label, shape, pose, shape_limitation )) {
50
56
reverse_to_unknown = true ;
51
57
}
52
58
}
@@ -91,22 +97,15 @@ bool ShapeEstimator::estimateOriginalShapeAndPose(
91
97
92
98
bool ShapeEstimator::applyFilter (
93
99
const uint8_t label, const autoware_auto_perception_msgs::msg::Shape & shape,
94
- const geometry_msgs::msg::Pose & pose)
100
+ const geometry_msgs::msg::Pose & pose, const ShapeParameters & shape_limitation )
95
101
{
96
102
std::unique_ptr<ShapeEstimationFilterInterface> filter_ptr;
97
- if (label == Label::CAR) {
98
- filter_ptr.reset (new CarFilter);
99
- } else if (label == Label::BUS) {
100
- filter_ptr.reset (new BusFilter);
101
- } else if (label == Label::TRUCK) {
102
- filter_ptr.reset (new TruckFilter);
103
- } else if (label == Label::TRAILER) {
104
- filter_ptr.reset (new TrailerFilter);
103
+ if (label == Label::CAR || label == Label::BUS || label == Label::TRUCK || label == Label::TRAILER) {
104
+ filter_ptr.reset (new VehicleFilter);
105
105
} else {
106
106
filter_ptr.reset (new NoFilter);
107
107
}
108
-
109
- return filter_ptr->filter (shape, pose);
108
+ return filter_ptr->filter (shape, pose, shape_limitation);
110
109
}
111
110
112
111
bool ShapeEstimator::applyCorrector (
@@ -134,3 +133,53 @@ bool ShapeEstimator::applyCorrector(
134
133
135
134
return corrector_ptr->correct (shape, pose);
136
135
}
136
+
137
+ // get shape_limitation by name
138
+ ShapeParameters ShapeEstimator::getShapeLimitation (const std::string & name)
139
+ {
140
+ for (const auto & param : shapes_) {
141
+ if (param.name == name) {
142
+ // debug print
143
+ std::cout << " Shape Limitation in Query: " << param.name << std::endl;
144
+ // std::cout << "min_width: " << param.shape_limitations.min_width << std::endl;
145
+ // std::cout << "max_width: " << param.shape_limitations.max_width << std::endl;
146
+ // std::cout << "min_length: " << param.shape_limitations.min_length << std::endl;
147
+ // std::cout << "max_length: " << param.shape_limitations.max_length << std::endl;
148
+ // std::cout << "min_height: " << param.shape_limitations.min_height << std::endl;
149
+ // std::cout << "max_height: " << param.shape_limitations.max_height << std::endl;
150
+ return param;
151
+ }
152
+ }
153
+ ShapeParameters shape_limitation;
154
+ shape_limitation.name = " unknown" ;
155
+ shape_limitation.shape_limitations .min_width = 0.0 ;
156
+ shape_limitation.shape_limitations .max_width = 99.0 ;
157
+ shape_limitation.shape_limitations .min_length = 0.0 ;
158
+ shape_limitation.shape_limitations .max_length = 99.0 ;
159
+ shape_limitation.shape_limitations .min_height = 0.0 ;
160
+ shape_limitation.shape_limitations .max_height = 99.0 ;
161
+ return shape_limitation;
162
+ }
163
+
164
+
165
+ // convert label(uint8_t) to string
166
+ std::string ShapeEstimator::labelToString (const uint8_t label)
167
+ {
168
+ if (label == Label::CAR) {
169
+ return " car" ;
170
+ } else if (label == Label::TRUCK) {
171
+ return " truck" ;
172
+ } else if (label == Label::BUS) {
173
+ return " bus" ;
174
+ } else if (label == Label::TRAILER) {
175
+ return " trailer" ;
176
+ } else if (label == Label::BICYCLE) {
177
+ return " bicycle" ;
178
+ } else if (label == Label::MOTORCYCLE) {
179
+ return " bicycle" ;
180
+ } else if (label == Label::PEDESTRIAN) {
181
+ return " pedestrian" ;
182
+ } else {
183
+ return " unknown" ;
184
+ }
185
+ }
0 commit comments