Skip to content

Commit

Permalink
Add rm_logger variable to avoid asking for logger every instance
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Jun 25, 2024
1 parent 04a8b73 commit 67fd09c
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions hardware_interface/src/resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ class ResourceStorage
sensor_loader_(pkg_name, sensor_interface_name),
system_loader_(pkg_name, system_interface_name),
cm_update_rate_(update_rate),
clock_interface_(clock_interface),
logger_interface_(logger_interface)
clock_interface_(clock_interface)
{
if (logger_interface)
{
rm_logger_ = logger_interface->get_logger().get_child("resource_manager");
}
}

template <class HardwareT, class HardwareInterfaceT>
Expand Down Expand Up @@ -916,17 +919,7 @@ class ResourceStorage
/**
* \return logger of the resource storage
*/
rclcpp::Logger get_logger() const
{
if (logger_interface_)
{
return logger_interface_->get_logger().get_child("resource_manager");
}
else
{
return rclcpp::get_logger("resource_manager");
}
}
const rclcpp::Logger & get_logger() const { return rm_logger_; }

/// Gets the clock for the resource storage
/**
Expand All @@ -952,6 +945,7 @@ class ResourceStorage
// Logger and Clock interfaces
rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface_;
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger_interface_;
rclcpp::Logger rm_logger_ = rclcpp::get_logger("resource_manager");

std::vector<Actuator> actuators_;
std::vector<Sensor> sensors_;
Expand Down

0 comments on commit 67fd09c

Please sign in to comment.