Skip to content

Commit 848a387

Browse files
committed
refactor(trajectory_validator): pass shape type to target filter
1 parent 9f208bb commit 848a387

3 files changed

Lines changed: 32 additions & 32 deletions

File tree

planning/autoware_trajectory_validator/src/filters/safety/collision_check_filter/assessment.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ DracArtifact assess(
395395

396396
for (const auto & predicted_object : predicted_objects.objects) {
397397
const auto & drac_params = drac_param_map.at(to_type_string(predicted_object.classification));
398-
if (!drac_params.target_shapes.contains(predicted_object.shape)) {
398+
if (!drac_params.target_shape_types.contains(predicted_object.shape.type)) {
399399
continue;
400400
}
401401

@@ -483,7 +483,7 @@ RssArtifact assess(
483483

484484
for (const auto & object : context.predicted_objects->objects) {
485485
const auto & rss_params = rss_param_map.at(to_type_string(object.classification));
486-
if (!rss_params.target_shapes.contains(object.shape)) {
486+
if (!rss_params.target_shape_types.contains(object.shape.type)) {
487487
continue;
488488
}
489489

planning/autoware_trajectory_validator/src/filters/safety/collision_check_filter/parameter.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ inline bool is_disabled_target_shape_config(const std::vector<std::string> & sha
7575
return shape_names.size() == 1U && shape_names.front().empty();
7676
}
7777

78-
struct TargetShapeParams
78+
struct TargetShapeTypeParams
7979
{
8080
bool bbox{true};
8181
bool polygon{false};
8282

83-
TargetShapeParams() = default;
84-
explicit TargetShapeParams(const std::vector<std::string> & shape_names)
83+
TargetShapeTypeParams() = default;
84+
explicit TargetShapeTypeParams(const std::vector<std::string> & shape_names)
8585
: bbox{false}, polygon{false}
8686
{
8787
if (is_disabled_target_shape_config(shape_names)) {
@@ -105,14 +105,14 @@ struct TargetShapeParams
105105
}
106106
}
107107

108-
bool contains(const autoware_perception_msgs::msg::Shape & shape) const
108+
bool contains(const uint8_t shape_type) const
109109
{
110110
using autoware_perception_msgs::msg::Shape;
111111

112-
if (shape.type == Shape::BOUNDING_BOX) {
112+
if (shape_type == Shape::BOUNDING_BOX) {
113113
return bbox;
114114
}
115-
if (shape.type == Shape::POLYGON) {
115+
if (shape_type == Shape::POLYGON) {
116116
return polygon;
117117
}
118118
return false;
@@ -278,7 +278,7 @@ struct DracParams
278278
extract_labeled_param<bool>(input_acceleration.enable_abandon, key);
279279
};
280280

281-
target_shapes = TargetShapeParams(
281+
target_shape_types = TargetShapeTypeParams(
282282
extract_labeled_param<std::vector<std::string>>(drac.enable_assessment, key));
283283
pet_margin.ego_earlier = extract_labeled_param<double>(drac.pet_margin.ego_earlier, key);
284284
pet_margin.object_earlier = extract_labeled_param<double>(drac.pet_margin.object_earlier, key);
@@ -317,7 +317,7 @@ struct DracParams
317317
map_based.object_prioritized_object_earlier);
318318
}
319319

320-
TargetShapeParams target_shapes{};
320+
TargetShapeTypeParams target_shape_types{};
321321
PetMargin pet_margin{};
322322
EgoFootprintMargin ego_footprint_margin{};
323323
EgoReactionBrakingDelay ego_reaction_braking_delay{};
@@ -336,7 +336,7 @@ struct RssParams
336336
RssParams(const validator::Params & node_params, const std::string_view key)
337337
{
338338
const auto & rss = node_params.collision_check.rss;
339-
target_shapes = TargetShapeParams(
339+
target_shape_types = TargetShapeTypeParams(
340340
extract_labeled_param<std::vector<std::string>>(rss.enable_assessment, key));
341341
stop_distance_margin = extract_labeled_param<double>(rss.stop_distance_margin, key);
342342
ego_total_braking_delay = extract_labeled_param<double>(rss.ego_total_braking_delay, key);
@@ -349,7 +349,7 @@ struct RssParams
349349
extract_labeled_param<double>(rss.error_threshold.ego_acceleration, key);
350350
}
351351

352-
TargetShapeParams target_shapes{};
352+
TargetShapeTypeParams target_shape_types{};
353353
double stop_distance_margin{2.0};
354354
double ego_total_braking_delay{0.4};
355355
EgoFootprintMargin ego_footprint_margin{};

planning/autoware_trajectory_validator/test/plugins/collision_check_filter/test_geometry.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ TEST(GeometryTest, IntersectsSatMatchesBoostForPointContactAndNearPointCases)
214214
expect_both_outcomes_covered("point boundary shifts", saw_intersection, saw_separation);
215215
}
216216

217-
TEST(TargetShapeParamsTest, SupportsConfiguredShapeTypes)
217+
TEST(TargetShapeTypeParamsTest, SupportsConfiguredShapeTypes)
218218
{
219219
using autoware_perception_msgs::msg::Shape;
220220

@@ -227,44 +227,44 @@ TEST(TargetShapeParamsTest, SupportsConfiguredShapeTypes)
227227
Shape cylinder;
228228
cylinder.type = Shape::CYLINDER;
229229

230-
const TargetShapeParams target_shapes({"bbox", "polygon"});
231-
EXPECT_TRUE(target_shapes.bbox);
232-
EXPECT_TRUE(target_shapes.polygon);
233-
EXPECT_TRUE(target_shapes.contains(bbox));
234-
EXPECT_TRUE(target_shapes.contains(polygon));
235-
EXPECT_FALSE(target_shapes.contains(cylinder));
230+
const TargetShapeTypeParams target_shape_types({"bbox", "polygon"});
231+
EXPECT_TRUE(target_shape_types.bbox);
232+
EXPECT_TRUE(target_shape_types.polygon);
233+
EXPECT_TRUE(target_shape_types.contains(bbox.type));
234+
EXPECT_TRUE(target_shape_types.contains(polygon.type));
235+
EXPECT_FALSE(target_shape_types.contains(cylinder.type));
236236
}
237237

238-
TEST(TargetShapeParamsTest, EmptyConfigurationDisablesAllShapeTypes)
238+
TEST(TargetShapeTypeParamsTest, EmptyConfigurationDisablesAllShapeTypes)
239239
{
240240
using autoware_perception_msgs::msg::Shape;
241241

242242
Shape bbox;
243243
bbox.type = Shape::BOUNDING_BOX;
244244

245-
const TargetShapeParams target_shapes(std::vector<std::string>{});
246-
EXPECT_FALSE(target_shapes.bbox);
247-
EXPECT_FALSE(target_shapes.polygon);
248-
EXPECT_FALSE(target_shapes.contains(bbox));
245+
const TargetShapeTypeParams target_shape_types(std::vector<std::string>{});
246+
EXPECT_FALSE(target_shape_types.bbox);
247+
EXPECT_FALSE(target_shape_types.polygon);
248+
EXPECT_FALSE(target_shape_types.contains(bbox.type));
249249
}
250250

251-
TEST(TargetShapeParamsTest, EmptyStringConfigurationDisablesAllShapeTypes)
251+
TEST(TargetShapeTypeParamsTest, EmptyStringConfigurationDisablesAllShapeTypes)
252252
{
253253
using autoware_perception_msgs::msg::Shape;
254254

255255
Shape bbox;
256256
bbox.type = Shape::BOUNDING_BOX;
257257

258-
const TargetShapeParams target_shapes({""});
259-
EXPECT_FALSE(target_shapes.bbox);
260-
EXPECT_FALSE(target_shapes.polygon);
261-
EXPECT_FALSE(target_shapes.contains(bbox));
258+
const TargetShapeTypeParams target_shape_types({""});
259+
EXPECT_FALSE(target_shape_types.bbox);
260+
EXPECT_FALSE(target_shape_types.polygon);
261+
EXPECT_FALSE(target_shape_types.contains(bbox.type));
262262
}
263263

264-
TEST(TargetShapeParamsTest, RejectsUnsupportedShapeTypes)
264+
TEST(TargetShapeTypeParamsTest, RejectsUnsupportedShapeTypes)
265265
{
266-
EXPECT_THROW(TargetShapeParams({"cylinder"}), std::invalid_argument);
267-
EXPECT_THROW(TargetShapeParams({"", "bbox"}), std::invalid_argument);
266+
EXPECT_THROW(TargetShapeTypeParams({"cylinder"}), std::invalid_argument);
267+
EXPECT_THROW(TargetShapeTypeParams({"", "bbox"}), std::invalid_argument);
268268
}
269269

270270
} // namespace

0 commit comments

Comments
 (0)