Skip to content

Commit 3b4a48b

Browse files
refactor
Signed-off-by: Yuki Takagi <yuki.takagi@tier4.jp>
1 parent c87ebf8 commit 3b4a48b

File tree

2 files changed

+17
-22
lines changed
  • planning/behavior_path_dynamic_avoidance_module

2 files changed

+17
-22
lines changed

planning/behavior_path_dynamic_avoidance_module/include/behavior_path_dynamic_avoidance_module/scene.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ class DynamicAvoidanceModule : public SceneModuleInterface
193193
autoware_auto_perception_msgs::msg::Shape shape;
194194
double vel{0.0};
195195
double lat_vel{0.0};
196-
197196
bool is_object_on_ego_path{false};
198197
std::optional<rclcpp::Time> latest_time_inside_ego_path{std::nullopt};
199198
std::vector<autoware_auto_perception_msgs::msg::PredictedPath> predicted_paths{};
@@ -207,7 +206,7 @@ class DynamicAvoidanceModule : public SceneModuleInterface
207206
std::vector<PathPointWithLaneId> ref_path_points_for_obj_poly;
208207
LatFeasiblePaths ego_lat_feasible_paths;
209208

210-
// add additional information (not update to latest data)
209+
// add additional information (not update to the latest data)
211210
void update(
212211
const MinMaxValue & arg_lon_offset_to_avoid, const MinMaxValue & arg_lat_offset_to_avoid,
213212
const bool arg_is_collision_left, const bool arg_should_be_avoided,
@@ -435,7 +434,7 @@ class DynamicAvoidanceModule : public SceneModuleInterface
435434
const DynamicAvoidanceObject & object) const;
436435
std::optional<tier4_autoware_utils::Polygon2d> calcPredictedPathBasedDynamicObstaclePolygon(
437436
const DynamicAvoidanceObject & object, const EgoPathReservePoly & ego_path_poly) const;
438-
EgoPathReservePoly calcEgoPathPreservePoly(const PathWithLaneId & ego_path) const;
437+
EgoPathReservePoly calcEgoPathReservePoly(const PathWithLaneId & ego_path) const;
439438

440439
void printIgnoreReason(const std::string & obj_uuid, const std::string & reason)
441440
{

planning/behavior_path_dynamic_avoidance_module/src/scene.cpp

+15-19
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,14 @@
1919
#include "object_recognition_utils/predicted_path_utils.hpp"
2020
#include "signal_processing/lowpass_filter_1d.hpp"
2121
#include "tier4_autoware_utils/geometry/boost_polygon_utils.hpp"
22-
#include "tier4_autoware_utils/ros/msg_covariance.hpp"
2322

24-
#include <lanelet2_extension/utility/message_conversion.hpp>
2523
#include <lanelet2_extension/utility/utilities.hpp>
2624

2725
#include <boost/geometry/algorithms/buffer.hpp>
2826
#include <boost/geometry/algorithms/convex_hull.hpp>
2927
#include <boost/geometry/algorithms/correct.hpp>
3028
#include <boost/geometry/algorithms/difference.hpp>
3129
#include <boost/geometry/algorithms/union.hpp>
32-
#include <boost/geometry/strategies/agnostic/buffer_distance_symmetric.hpp>
33-
#include <boost/geometry/strategies/cartesian/buffer_end_flat.hpp>
34-
#include <boost/geometry/strategies/cartesian/buffer_join_round.hpp>
35-
#include <boost/geometry/strategies/cartesian/buffer_point_circle.hpp>
36-
#include <boost/geometry/strategies/cartesian/buffer_side_straight.hpp>
3730

3831
#include <lanelet2_core/geometry/Point.h>
3932
#include <lanelet2_core/geometry/Polygon.h>
@@ -401,7 +394,7 @@ BehaviorModuleOutput DynamicAvoidanceModule::plan()
401394
throw std::runtime_error("input path is empty");
402395
}
403396

404-
const auto ego_path_reserve_poly = calcEgoPathPreservePoly(input_path);
397+
const auto ego_path_reserve_poly = calcEgoPathReservePoly(input_path);
405398

406399
// create obstacles to avoid (= extract from the drivable area)
407400
std::vector<DrivableAreaInfo::Obstacle> obstacles_for_drivable_area;
@@ -413,8 +406,8 @@ BehaviorModuleOutput DynamicAvoidanceModule::plan()
413406

414407
if (parameters_->polygon_generation_method == PolygonGenerationMethod::EGO_PATH_BASE) {
415408
return calcEgoPathBasedDynamicObstaclePolygon(object);
416-
} else if (
417-
parameters_->polygon_generation_method == PolygonGenerationMethod::OBJECT_PATH_BASE) {
409+
}
410+
if (parameters_->polygon_generation_method == PolygonGenerationMethod::OBJECT_PATH_BASE) {
418411
return calcObjectPathBasedDynamicObstaclePolygon(object);
419412
}
420413
throw std::logic_error("The polygon_generation_method's string is invalid.");
@@ -1676,7 +1669,7 @@ DynamicAvoidanceModule::calcEgoPathBasedDynamicObstaclePolygon(
16761669
return obj_poly;
16771670
}
16781671

1679-
// TODO (takagi): replace by another function?
1672+
// TODO (takagi): replace by the nother function?
16801673
std::optional<tier4_autoware_utils::Polygon2d>
16811674
DynamicAvoidanceModule::calcObjectPathBasedDynamicObstaclePolygon(
16821675
const DynamicAvoidanceObject & object) const
@@ -1740,20 +1733,20 @@ std::optional<tier4_autoware_utils::Polygon2d>
17401733
DynamicAvoidanceModule::calcPredictedPathBasedDynamicObstaclePolygon(
17411734
const DynamicAvoidanceObject & object, const EgoPathReservePoly & ego_path_poly) const
17421735
{
1743-
std::vector<geometry_msgs::msg::Pose> candidate_poses;
1736+
std::vector<geometry_msgs::msg::Pose> obj_poses;
17441737
for (const auto & predicted_path : object.predicted_paths) {
17451738
if (predicted_path.confidence < parameters_->threshold_confidence) continue;
17461739

17471740
double time_count = 0.0;
17481741
for (const auto & pose : predicted_path.path) {
1749-
candidate_poses.push_back(pose);
1742+
obj_poses.push_back(pose);
17501743
time_count += predicted_path.time_step.sec + predicted_path.time_step.nanosec * 1e-9;
17511744
if (time_count > parameters_->end_time_to_consider + 1e-3) break;
17521745
}
17531746
}
17541747

17551748
tier4_autoware_utils::Polygon2d obj_points_as_poly;
1756-
for (const auto pose : candidate_poses) {
1749+
for (const auto pose : obj_poses) {
17571750
boost::geometry::append(
17581751
obj_points_as_poly, tier4_autoware_utils::toFootprint(
17591752
pose, object.shape.dimensions.x * 0.5, object.shape.dimensions.x * 0.5,
@@ -1798,7 +1791,7 @@ DynamicAvoidanceModule::calcPredictedPathBasedDynamicObstaclePolygon(
17981791
// Calculate the driving area required to ensure the safety of the own vehicle.
17991792
// It is assumed that this area will not be clipped.
18001793
// input: ego's reference path, ego's pose, ego's speed, and some global params
1801-
DynamicAvoidanceModule::EgoPathReservePoly DynamicAvoidanceModule::calcEgoPathPreservePoly(
1794+
DynamicAvoidanceModule::EgoPathReservePoly DynamicAvoidanceModule::calcEgoPathReservePoly(
18021795
const PathWithLaneId & ego_path) const
18031796
{
18041797
// This function require almost 0.5 ms. Should be refactored in the future
@@ -1818,22 +1811,25 @@ DynamicAvoidanceModule::EgoPathReservePoly DynamicAvoidanceModule::calcEgoPathPr
18181811
[&ego_path_lines](
18191812
strategy::distance_asymmetric<double> path_expand_strategy,
18201813
strategy::distance_asymmetric<double> steer_expand_strategy,
1821-
std::vector<geometry_msgs::msg::Point> steer_outer_path) -> tier4_autoware_utils::Polygon2d {
1814+
std::vector<geometry_msgs::msg::Point> outer_body_path) -> tier4_autoware_utils::Polygon2d {
1815+
// reserve area based on the reference path
18221816
tier4_autoware_utils::MultiPolygon2d path_poly;
18231817
boost::geometry::buffer(
18241818
ego_path_lines, path_poly, path_expand_strategy, strategy::side_straight(),
18251819
strategy::join_round(), strategy::end_flat(), strategy::point_circle());
18261820

1821+
// reserve area steer to the avoidance path
18271822
tier4_autoware_utils::LineString2d steer_lines;
1828-
for (const auto & point : steer_outer_path) {
1823+
for (const auto & point : outer_body_path) {
18291824
const auto bg_point = tier4_autoware_utils::fromMsg(point).to_2d();
18301825
if (boost::geometry::within(bg_point, path_poly)) {
18311826
if (steer_lines.size() != 0) {
1832-
boost::geometry::append(steer_lines, bg_point);
1827+
;
1828+
// boost::geometry::append(steer_lines, bg_point);
18331829
}
18341830
break;
18351831
}
1836-
boost::geometry::append(steer_lines, bg_point);
1832+
// boost::geometry::append(steer_lines, bg_point);
18371833
}
18381834
tier4_autoware_utils::MultiPolygon2d steer_poly;
18391835
boost::geometry::buffer(

0 commit comments

Comments
 (0)