Skip to content

Commit

Permalink
fix(static_obstacle_avoidance): turn signal chattering
Browse files Browse the repository at this point in the history
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
  • Loading branch information
satoshi-ota committed Feb 28, 2025
1 parent ece3809 commit 57e9251
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include <limits>
#include <memory>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
Expand Down Expand Up @@ -459,7 +460,7 @@ class StaticObstacleAvoidanceModule : public SceneModuleInterface

bool safe_{true};

std::optional<UUID> ignore_signal_{std::nullopt};
std::set<std::string> ignore_signal_ids_;

std::shared_ptr<AvoidanceHelper> helper_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,15 +962,13 @@ auto StaticObstacleAvoidanceModule::getTurnSignal(
using autoware::motion_utils::calcSignedArcLength;

const auto is_ignore_signal = [this](const UUID & uuid) {
if (!ignore_signal_.has_value()) {
return false;
}

return ignore_signal_.value() == uuid;
return ignore_signal_ids_.find(toHexString(uuid)) != ignore_signal_ids_.end();
};

const auto update_ignore_signal = [this](const UUID & uuid, const bool is_ignore) {
ignore_signal_ = is_ignore ? std::make_optional(uuid) : std::nullopt;
if (is_ignore) {
ignore_signal_ids_.insert(toHexString(uuid));
}

Check notice on line 971 in planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/src/scene.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Complex Method

StaticObstacleAvoidanceModule::getTurnSignal decreases in cyclomatic complexity from 16 to 15, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
};

const auto is_large_deviation = [this](const auto & path) {
Expand Down Expand Up @@ -1509,6 +1507,7 @@ void StaticObstacleAvoidanceModule::initVariables()
resetPathCandidate();
resetPathReference();
arrived_path_end_ = false;
ignore_signal_ids_.clear();
}

void StaticObstacleAvoidanceModule::initRTCStatus()
Expand Down

0 comments on commit 57e9251

Please sign in to comment.