Skip to content

Commit

Permalink
fix(bpp, bvp): keep rtc cooperate status even after manager stops mod…
Browse files Browse the repository at this point in the history
…ule execution (autowarefoundation#7032)

* feat(rtc_interface): add new function to remove old status

Signed-off-by: satoshi-ota <[email protected]>

* fix(bpp): don't remove rtc cooperate status

Signed-off-by: satoshi-ota <[email protected]>

* fix(bvp): don't remove rtc cooperate status

Signed-off-by: satoshi-ota <[email protected]>

---------

Signed-off-by: satoshi-ota <[email protected]>
  • Loading branch information
satoshi-ota authored and karishma1911 committed Jun 3, 2024
1 parent 22a0b40 commit 1115452
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ class SceneModuleInterface
RCLCPP_DEBUG(getLogger(), "%s %s", name_.c_str(), __func__);

clearWaitingApproval();
removeRTCStatus();
unlockNewModuleLaunch();
unlockOutputPath();
steering_factor_interface_ptr_->clearSteeringFactors();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class SceneModuleManagerInterface
{
for (const auto & [module_name, ptr] : rtc_interface_ptr_map_) {
if (ptr) {
ptr->removeExpiredCooperateStatus();
ptr->publishCooperateStatus(rclcpp::Clock(RCL_ROS_TIME).now());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,11 @@ class SceneModuleManagerInterfaceWithRTC : public SceneModuleManagerInterface

void removeRTCStatus(const UUID & uuid) { rtc_interface_.removeCooperateStatus(uuid); }

void publishRTCStatus(const Time & stamp) { rtc_interface_.publishCooperateStatus(stamp); }
void publishRTCStatus(const Time & stamp)
{
rtc_interface_.removeExpiredCooperateStatus();
rtc_interface_.publishCooperateStatus(stamp);
}

UUID getUUID(const int64_t & module_id) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ void SceneModuleManagerInterfaceWithRTC::deleteExpiredModules(

for (const auto & scene_module : copied_scene_modules) {
if (isModuleExpired(scene_module)) {
removeRTCStatus(getUUID(scene_module->getModuleId()));
const UUID uuid = getUUID(scene_module->getModuleId());
updateRTCStatus(
uuid, scene_module->isSafe(), State::SUCCEEDED, std::numeric_limits<double>::lowest(),
clock_->now());
removeUUID(scene_module->getModuleId());
unregisterModule(scene_module);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class RTCInterface
const UUID & uuid, const bool safe, const uint8_t state, const double start_distance,
const double finish_distance, const rclcpp::Time & stamp);
void removeCooperateStatus(const UUID & uuid);
void removeExpiredCooperateStatus();
void clearCooperateStatus();
bool isActivated(const UUID & uuid) const;
bool isRegistered(const UUID & uuid) const;
Expand Down
12 changes: 12 additions & 0 deletions planning/rtc_interface/src/rtc_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,18 @@ void RTCInterface::removeStoredCommand(const UUID & uuid)
}
}

void RTCInterface::removeExpiredCooperateStatus()
{
std::lock_guard<std::mutex> lock(mutex_);
const auto itr = std::remove_if(
registered_status_.statuses.begin(), registered_status_.statuses.end(),
[](const auto & status) {
return (rclcpp::Clock{RCL_ROS_TIME}.now() - status.stamp).seconds() > 10.0;
});

registered_status_.statuses.erase(itr, registered_status_.statuses.end());
}

void RTCInterface::clearCooperateStatus()
{
std::lock_guard<std::mutex> lock(mutex_);
Expand Down

0 comments on commit 1115452

Please sign in to comment.