Skip to content

Commit

Permalink
Parse the actual period to the read and write methods
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Jul 16, 2024
1 parent 31365de commit 3033380
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions hardware_interface/src/resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1801,9 +1801,12 @@ HardwareReadWriteStatus ResourceManager::read(
1.0 / resource_storage_->hardware_info_map_[component.get_name()].read_rate);
if (
component.get_last_read_time().seconds() == 0 ||
(time - component.get_last_read_time()).seconds() >= hw_read_period.seconds())
(time - component.get_last_read_time()) >= hw_read_period)
{
ret_val = component.read(time, hw_read_period);
const rclcpp::Duration actual_period = component.get_last_read_time().seconds() == 0
? hw_read_period
: time - component.get_last_read_time();
ret_val = component.read(time, actual_period);
}
}
const auto component_group = component.get_group_name();
Expand Down Expand Up @@ -1878,9 +1881,12 @@ HardwareReadWriteStatus ResourceManager::write(
1.0 / resource_storage_->hardware_info_map_[component.get_name()].write_rate);
if (
component.get_last_write_time().seconds() == 0 ||
(time - component.get_last_write_time()).seconds() >= hw_write_period.seconds())
(time - component.get_last_write_time()) >= hw_write_period)
{
ret_val = component.write(time, hw_write_period);
const rclcpp::Duration actual_period = component.get_last_write_time().seconds() == 0
? hw_write_period
: time - component.get_last_read_time();
ret_val = component.write(time, actual_period);
}
}
const auto component_group = component.get_group_name();
Expand Down

0 comments on commit 3033380

Please sign in to comment.