Skip to content

Commit 79b1618

Browse files
committed
fix(avoidance): update logic
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent 19d74b3 commit 79b1618

File tree

2 files changed

+36
-58
lines changed
  • planning/behavior_path_avoidance_module

2 files changed

+36
-58
lines changed

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/scene.hpp

-50
Original file line numberDiff line numberDiff line change
@@ -122,31 +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-
126-
const auto record_start_time = !is_recording_ && is_record_necessary_ && helper_->isShifted();
127-
const auto record_end_time = is_recording_ && !helper_->isShifted();
128-
const auto steering_factor = [&]() {
129-
if (record_start_time) {
130-
is_recording_ = true;
131-
RCLCPP_DEBUG(getLogger(), "start left avoidance maneuver. get time stamp.");
132-
return uint16_t(100);
133-
}
134-
135-
if (record_end_time) {
136-
is_recording_ = false;
137-
is_record_necessary_ = false;
138-
RCLCPP_DEBUG(getLogger(), "end avoidance maneuver. get time stamp.");
139-
return uint16_t(200);
140-
}
141-
142-
return SteeringFactor::LEFT;
143-
}();
144-
145-
if (finish_distance > -1.0e-03) {
146-
steering_factor_interface_ptr_->updateSteeringFactor(
147-
{left_shift.start_pose, left_shift.finish_pose}, {start_distance, finish_distance},
148-
PlanningBehavior::AVOIDANCE, steering_factor, SteeringFactor::TURNING, "");
149-
}
150125
}
151126

152127
for (const auto & right_shift : right_shift_array_) {
@@ -156,31 +131,6 @@ class AvoidanceModule : public SceneModuleInterface
156131
calcSignedArcLength(path.points, ego_position, right_shift.finish_pose.position);
157132
rtc_interface_ptr_map_.at("right")->updateCooperateStatus(
158133
right_shift.uuid, true, start_distance, finish_distance, clock_->now());
159-
160-
const auto record_start_time = !is_recording_ && is_record_necessary_ && helper_->isShifted();
161-
const auto record_end_time = is_recording_ && !helper_->isShifted();
162-
const auto steering_factor = [&]() {
163-
if (record_start_time) {
164-
is_recording_ = true;
165-
RCLCPP_DEBUG(getLogger(), "start right avoidance maneuver. get time stamp.");
166-
return uint16_t(100);
167-
}
168-
169-
if (record_end_time) {
170-
is_recording_ = false;
171-
is_record_necessary_ = false;
172-
RCLCPP_DEBUG(getLogger(), "end avoidance maneuver. get time stamp.");
173-
return uint16_t(200);
174-
}
175-
176-
return SteeringFactor::RIGHT;
177-
}();
178-
179-
if (finish_distance > -1.0e-03) {
180-
steering_factor_interface_ptr_->updateSteeringFactor(
181-
{right_shift.start_pose, right_shift.finish_pose}, {start_distance, finish_distance},
182-
PlanningBehavior::AVOIDANCE, steering_factor, SteeringFactor::TURNING, "");
183-
}
184134
}
185135
}
186136

planning/behavior_path_avoidance_module/src/scene.cpp

+36-8
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,42 @@ BehaviorModuleOutput AvoidanceModule::plan()
928928
spline_shift_path, data.current_lanelets, planner_data_->parameters.vehicle_info);
929929
}
930930

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+
931967
// sparse resampling for computational cost
932968
{
933969
spline_shift_path.path = utils::resamplePathWithSpline(
@@ -1008,14 +1044,6 @@ CandidateOutput AvoidanceModule::planCandidate() const
10081044
output.start_distance_to_path_change = sl_front.start_longitudinal;
10091045
output.finish_distance_to_path_change = sl_back.end_longitudinal;
10101046

1011-
const uint16_t steering_factor_direction = std::invoke([&output]() {
1012-
return output.lateral_shift > 0.0 ? SteeringFactor::LEFT : SteeringFactor::RIGHT;
1013-
});
1014-
steering_factor_interface_ptr_->updateSteeringFactor(
1015-
{sl_front.start, sl_back.end},
1016-
{output.start_distance_to_path_change, output.finish_distance_to_path_change},
1017-
PlanningBehavior::AVOIDANCE, steering_factor_direction, SteeringFactor::APPROACHING, "");
1018-
10191047
output.path_candidate = shifted_path.path;
10201048
return output;
10211049
}

0 commit comments

Comments
 (0)