Skip to content

Commit

Permalink
fix(rtc_interface): use clock created by node to judge expired cooper…
Browse files Browse the repository at this point in the history
…ate status (#7083)

Signed-off-by: satoshi-ota <[email protected]>
  • Loading branch information
satoshi-ota authored May 21, 2024
1 parent 3ad43de commit a792d4b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class RTCInterface
rclcpp::Service<AutoMode>::SharedPtr srv_auto_mode_;
rclcpp::CallbackGroup::SharedPtr callback_group_;
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Clock::SharedPtr clock_;
rclcpp::Logger logger_;

Module module_;
Expand Down
7 changes: 3 additions & 4 deletions planning/rtc_interface/src/rtc_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ Module getModuleType(const std::string & module_name)
namespace rtc_interface
{
RTCInterface::RTCInterface(rclcpp::Node * node, const std::string & name, const bool enable_rtc)
: logger_{node->get_logger().get_child("RTCInterface[" + name + "]")},
: clock_{node->get_clock()},
logger_{node->get_logger().get_child("RTCInterface[" + name + "]")},
is_auto_mode_enabled_{!enable_rtc},
is_locked_{false}
{
Expand Down Expand Up @@ -270,9 +271,7 @@ 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;
});
[this](const auto & status) { return (clock_->now() - status.stamp).seconds() > 10.0; });

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

0 comments on commit a792d4b

Please sign in to comment.