Skip to content

Commit

Permalink
feat(rtc_inteface): add function to check force deactivate (autowaref…
Browse files Browse the repository at this point in the history
…oundation#8221)

add function to check for deactivation

Signed-off-by: Go Sakayori <[email protected]>
  • Loading branch information
go-sakayori authored Jul 29, 2024
1 parent 936703d commit 687aa93
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class RTCInterface
void clearCooperateStatus();
bool isActivated(const UUID & uuid) const;
bool isForceActivated(const UUID & uuid) const;
bool isForceDeactivated(const UUID & UUID) const;
bool isRegistered(const UUID & uuid) const;
bool isRTCEnabled(const UUID & uuid) const;
bool isTerminated(const UUID & uuid) const;
Expand Down
24 changes: 24 additions & 0 deletions planning/autoware_rtc_interface/src/rtc_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,30 @@ bool RTCInterface::isForceActivated(const UUID & uuid) const
return false;
}

bool RTCInterface::isForceDeactivated(const UUID & uuid) const
{
std::lock_guard<std::mutex> lock(mutex_);
const auto itr = std::find_if(
registered_status_.statuses.begin(), registered_status_.statuses.end(),
[uuid](const auto & s) { return s.uuid == uuid; });

if (itr != registered_status_.statuses.end()) {
if (itr->state.type != State::RUNNING) {
return false;
}
if (itr->command_status.type == Command::DEACTIVATE && itr->safe && !itr->auto_mode) {
return true;
} else {
return false;
}
}

RCLCPP_WARN_STREAM(
getLogger(),
"[isForceDeactivated] uuid : " << uuid_to_string(uuid) << " is not found" << std::endl);
return false;
}

bool RTCInterface::isRegistered(const UUID & uuid) const
{
std::lock_guard<std::mutex> lock(mutex_);
Expand Down

0 comments on commit 687aa93

Please sign in to comment.