Skip to content

Commit 3ba1ecd

Browse files
authored
feat(intersection_occlusion): quickly delete occlusion wall on change from green to yellow/red (#6608)
Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
1 parent 10ed352 commit 3ba1ecd

File tree

4 files changed

+40
-17
lines changed

4 files changed

+40
-17
lines changed

planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,18 @@ static std::string formatOcclusionType(const IntersectionModule::OcclusionType &
148148
intersection::DecisionResult IntersectionModule::modifyPathVelocityDetail(
149149
PathWithLaneId * path, [[maybe_unused]] StopReason * stop_reason)
150150
{
151-
const auto traffic_prioritized_level = getTrafficPrioritizedLevel();
152-
const bool is_prioritized =
153-
traffic_prioritized_level == TrafficPrioritizedLevel::FULLY_PRIORITIZED;
154-
155-
const auto prepare_data = prepareIntersectionData(is_prioritized, path);
151+
const auto prepare_data = prepareIntersectionData(path);
156152
if (!prepare_data) {
157153
return prepare_data.err();
158154
}
159155
const auto [interpolated_path_info, intersection_stoplines, path_lanelets] = prepare_data.ok();
160156
const auto & intersection_lanelets = intersection_lanelets_.value();
161157

158+
// NOTE: this level is based on the updateTrafficSignalObservation() which is latest
159+
const auto traffic_prioritized_level = getTrafficPrioritizedLevel();
160+
const bool is_prioritized =
161+
traffic_prioritized_level == TrafficPrioritizedLevel::FULLY_PRIORITIZED;
162+
162163
// ==========================================================================================
163164
// stuck detection
164165
//

planning/behavior_velocity_intersection_module/src/scene_intersection.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,9 @@ class IntersectionModule : public SceneModuleInterface
442442
//! unavailable)
443443
std::optional<std::pair<lanelet::Id, lanelet::ConstPoint3d>> tl_id_and_point_;
444444
std::optional<TrafficSignalStamped> last_tl_valid_observation_{std::nullopt};
445+
446+
//! save previous priority level to detect change from NotPrioritized to Prioritized
447+
TrafficPrioritizedLevel previous_prioritized_level_{TrafficPrioritizedLevel::NOT_PRIORITIZED};
445448
/** @} */
446449

447450
private:
@@ -548,7 +551,7 @@ class IntersectionModule : public SceneModuleInterface
548551
* To simplify modifyPathVelocityDetail(), this function is used at first
549552
*/
550553
intersection::Result<BasicData, intersection::InternalError> prepareIntersectionData(
551-
const bool is_prioritized, PathWithLaneId * path);
554+
PathWithLaneId * path);
552555

553556
/**
554557
* @brief find the associated stopline road marking of assigned lanelet

planning/behavior_velocity_intersection_module/src/scene_intersection_occlusion.cpp

+17-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,23 @@ IntersectionModule::getOcclusionStatus(
6363
!is_amber_or_red_or_no_tl_info_ever)
6464
? detectOcclusion(interpolated_path_info)
6565
: NotOccluded{};
66-
occlusion_stop_state_machine_.setStateWithMarginTime(
67-
std::holds_alternative<NotOccluded>(occlusion_status) ? StateMachine::State::GO
68-
: StateMachine::STOP,
69-
logger_.get_child("occlusion_stop"), *clock_);
66+
67+
// ==========================================================================================
68+
// if the traffic light changed from green to yellow/red, hysteresis time for occlusion is
69+
// unnecessary
70+
// ==========================================================================================
71+
const auto transition_to_prioritized =
72+
(previous_prioritized_level_ == TrafficPrioritizedLevel::NOT_PRIORITIZED &&
73+
traffic_prioritized_level != TrafficPrioritizedLevel::NOT_PRIORITIZED);
74+
if (transition_to_prioritized) {
75+
occlusion_stop_state_machine_.setState(StateMachine::State::GO);
76+
} else {
77+
occlusion_stop_state_machine_.setStateWithMarginTime(
78+
std::holds_alternative<NotOccluded>(occlusion_status) ? StateMachine::State::GO
79+
: StateMachine::STOP,
80+
logger_.get_child("occlusion_stop"), *clock_);
81+
}
82+
7083
const bool is_occlusion_cleared_with_margin =
7184
(occlusion_stop_state_machine_.getState() == StateMachine::State::GO); // module's detection
7285
// distinguish if ego detected occlusion or RTC detects occlusion

planning/behavior_velocity_intersection_module/src/scene_intersection_prepare_data.cpp

+13-7
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ using intersection::make_ok;
166166
using intersection::Result;
167167

168168
Result<IntersectionModule::BasicData, intersection::InternalError>
169-
IntersectionModule::prepareIntersectionData(const bool is_prioritized, PathWithLaneId * path)
169+
IntersectionModule::prepareIntersectionData(PathWithLaneId * path)
170170
{
171171
const auto lanelet_map_ptr = planner_data_->route_handler_->getLaneletMapPtr();
172172
const auto routing_graph_ptr = planner_data_->route_handler_->getRoutingGraphPtr();
@@ -175,6 +175,18 @@ IntersectionModule::prepareIntersectionData(const bool is_prioritized, PathWithL
175175
const auto footprint = planner_data_->vehicle_info_.createFootprint(0.0, 0.0);
176176
const auto & current_pose = planner_data_->current_odometry->pose;
177177

178+
// ==========================================================================================
179+
// update traffic light information
180+
// updateTrafficSignalObservation() must be called at first because other traffic signal
181+
// fuctions use last_valid_observation_
182+
// ==========================================================================================
183+
// save previous information before calling updateTrafficSignalObservation()
184+
previous_prioritized_level_ = getTrafficPrioritizedLevel();
185+
updateTrafficSignalObservation();
186+
const auto traffic_prioritized_level = getTrafficPrioritizedLevel();
187+
const bool is_prioritized =
188+
traffic_prioritized_level == TrafficPrioritizedLevel::FULLY_PRIORITIZED;
189+
178190
// spline interpolation
179191
const auto interpolated_path_info_opt = util::generateInterpolatedPath(
180192
lane_id_, associative_ids_, *path, planner_param_.common.path_interpolation_ds, logger_);
@@ -264,13 +276,7 @@ IntersectionModule::prepareIntersectionData(const bool is_prioritized, PathWithL
264276
planner_data_->occupancy_grid->info.resolution);
265277
}
266278

267-
// ==========================================================================================
268-
// update traffic light information
269-
// updateTrafficSignalObservation() must be called at first to because other traffic signal
270-
// fuctions use last_valid_observation_
271-
// ==========================================================================================
272279
if (has_traffic_light_) {
273-
updateTrafficSignalObservation();
274280
const bool is_green_solid_on = isGreenSolidOn();
275281
if (is_green_solid_on && !initial_green_light_observed_time_) {
276282
const auto assigned_lane_begin_point = assigned_lanelet.centerline().front();

0 commit comments

Comments
 (0)