Skip to content

Commit 213c263

Browse files
authored
Merge pull request #1193 from tier4/feat/steering_factor_for_avoidance
feat(avoidance): (TEMPORARY) steering factor for avoidance maneuver
2 parents a65c73b + 79b1618 commit 213c263

File tree

3 files changed

+76
-18
lines changed

3 files changed

+76
-18
lines changed

Diff for: planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/scene.hpp

+4-10
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,6 @@ class AvoidanceModule : public SceneModuleInterface
122122
calcSignedArcLength(path.points, ego_position, left_shift.finish_pose.position);
123123
rtc_interface_ptr_map_.at("left")->updateCooperateStatus(
124124
left_shift.uuid, true, start_distance, finish_distance, clock_->now());
125-
if (finish_distance > -1.0e-03) {
126-
steering_factor_interface_ptr_->updateSteeringFactor(
127-
{left_shift.start_pose, left_shift.finish_pose}, {start_distance, finish_distance},
128-
PlanningBehavior::AVOIDANCE, SteeringFactor::LEFT, SteeringFactor::TURNING, "");
129-
}
130125
}
131126

132127
for (const auto & right_shift : right_shift_array_) {
@@ -136,11 +131,6 @@ class AvoidanceModule : public SceneModuleInterface
136131
calcSignedArcLength(path.points, ego_position, right_shift.finish_pose.position);
137132
rtc_interface_ptr_map_.at("right")->updateCooperateStatus(
138133
right_shift.uuid, true, start_distance, finish_distance, clock_->now());
139-
if (finish_distance > -1.0e-03) {
140-
steering_factor_interface_ptr_->updateSteeringFactor(
141-
{right_shift.start_pose, right_shift.finish_pose}, {start_distance, finish_distance},
142-
PlanningBehavior::AVOIDANCE, SteeringFactor::RIGHT, SteeringFactor::TURNING, "");
143-
}
144134
}
145135
}
146136

@@ -417,6 +407,10 @@ class AvoidanceModule : public SceneModuleInterface
417407

418408
bool safe_{true};
419409

410+
bool is_recording_{false};
411+
412+
bool is_record_necessary_{false};
413+
420414
std::shared_ptr<AvoidanceHelper> helper_;
421415

422416
std::shared_ptr<AvoidanceParameters> parameters_;

Diff for: planning/behavior_path_avoidance_module/src/scene.cpp

+70-8
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,34 @@ lanelet::BasicLineString3d toLineString3d(const std::vector<Point> & bound)
9797
bound.begin(), bound.end(), [&](const auto & p) { ret.emplace_back(p.x, p.y, p.z); });
9898
return ret;
9999
}
100+
101+
bool straddleRoadBound(
102+
const ShiftedPath & path, const lanelet::ConstLanelets & lanes,
103+
const vehicle_info_util::VehicleInfo & vehicle_info)
104+
{
105+
using boost::geometry::intersects;
106+
using tier4_autoware_utils::pose2transform;
107+
using tier4_autoware_utils::transformVector;
108+
109+
const auto footprint = vehicle_info.createFootprint();
110+
111+
for (const auto & lane : lanes) {
112+
for (const auto & p : path.path.points) {
113+
const auto transform = pose2transform(p.point.pose);
114+
const auto shifted_vehicle_footprint = transformVector(footprint, transform);
115+
116+
if (intersects(lane.leftBound2d().basicLineString(), shifted_vehicle_footprint)) {
117+
return true;
118+
}
119+
120+
if (intersects(lane.rightBound2d().basicLineString(), shifted_vehicle_footprint)) {
121+
return true;
122+
}
123+
}
124+
}
125+
126+
return false;
127+
}
100128
} // namespace
101129

102130
AvoidanceModule::AvoidanceModule(
@@ -894,6 +922,48 @@ BehaviorModuleOutput AvoidanceModule::plan()
894922
planner_data_->parameters.ego_nearest_yaw_threshold);
895923
}
896924

925+
// check if the ego straddles lane border
926+
if (!is_recording_) {
927+
is_record_necessary_ = straddleRoadBound(
928+
spline_shift_path, data.current_lanelets, planner_data_->parameters.vehicle_info);
929+
}
930+
931+
if (!path_shifter_.getShiftLines().empty()) {
932+
const auto front_shift_line = path_shifter_.getShiftLines().front();
933+
const double start_distance = calcSignedArcLength(
934+
data.reference_path.points, getEgoPosition(), front_shift_line.start.position);
935+
const double finish_distance = calcSignedArcLength(
936+
data.reference_path.points, getEgoPosition(), front_shift_line.end.position);
937+
938+
const auto record_start_time = !is_recording_ && is_record_necessary_ && helper_->isShifted();
939+
const auto record_end_time = is_recording_ && !helper_->isShifted();
940+
const auto relative_shift_length = front_shift_line.end_shift_length - helper_->getEgoShift();
941+
const auto steering_direction =
942+
relative_shift_length > 0.0 ? SteeringFactor::LEFT : SteeringFactor::RIGHT;
943+
const auto steering_status = [&]() {
944+
if (record_start_time) {
945+
is_recording_ = true;
946+
RCLCPP_ERROR(getLogger(), "start right avoidance maneuver. get time stamp.");
947+
return uint16_t(100);
948+
}
949+
950+
if (record_end_time) {
951+
is_recording_ = false;
952+
is_record_necessary_ = false;
953+
RCLCPP_ERROR(getLogger(), "end avoidance maneuver. get time stamp.");
954+
return uint16_t(200);
955+
}
956+
957+
return helper_->isShifted() ? SteeringFactor::TURNING : SteeringFactor::APPROACHING;
958+
}();
959+
960+
if (finish_distance > -1.0e-03) {
961+
steering_factor_interface_ptr_->updateSteeringFactor(
962+
{front_shift_line.start, front_shift_line.end}, {start_distance, finish_distance},
963+
PlanningBehavior::AVOIDANCE, steering_direction, steering_status, "");
964+
}
965+
}
966+
897967
// sparse resampling for computational cost
898968
{
899969
spline_shift_path.path = utils::resamplePathWithSpline(
@@ -974,14 +1044,6 @@ CandidateOutput AvoidanceModule::planCandidate() const
9741044
output.start_distance_to_path_change = sl_front.start_longitudinal;
9751045
output.finish_distance_to_path_change = sl_back.end_longitudinal;
9761046

977-
const uint16_t steering_factor_direction = std::invoke([&output]() {
978-
return output.lateral_shift > 0.0 ? SteeringFactor::LEFT : SteeringFactor::RIGHT;
979-
});
980-
steering_factor_interface_ptr_->updateSteeringFactor(
981-
{sl_front.start, sl_back.end},
982-
{output.start_distance_to_path_change, output.finish_distance_to_path_change},
983-
PlanningBehavior::AVOIDANCE, steering_factor_direction, SteeringFactor::APPROACHING, "");
984-
9851047
output.path_candidate = shifted_path.path;
9861048
return output;
9871049
}

Diff for: planning/behavior_path_planner/include/behavior_path_planner/planner_manager.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ class PlannerManager
286286

287287
module_ptr->publishRTCStatus();
288288

289+
module_ptr->publishSteeringFactor();
290+
289291
module_ptr->publishObjectsOfInterestMarker();
290292

291293
processing_time_.at(module_ptr->name()) += stop_watch_.toc(module_ptr->name(), true);

0 commit comments

Comments
 (0)