Skip to content

Commit 84d00da

Browse files
committed
Parse the actual period to the read and write methods
1 parent 603935f commit 84d00da

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

hardware_interface/src/resource_manager.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,9 +1678,12 @@ HardwareReadWriteStatus ResourceManager::read(
16781678
1.0 / resource_storage_->hardware_info_map_[component.get_name()].read_rate);
16791679
if (
16801680
component.get_last_read_time().seconds() == 0 ||
1681-
(time - component.get_last_read_time()).seconds() >= hw_read_period.seconds())
1681+
(time - component.get_last_read_time()) >= hw_read_period)
16821682
{
1683-
ret_val = component.read(time, hw_read_period);
1683+
const rclcpp::Duration actual_period = component.get_last_read_time().seconds() == 0
1684+
? hw_read_period
1685+
: time - component.get_last_read_time();
1686+
ret_val = component.read(time, actual_period);
16841687
}
16851688
}
16861689
const auto component_group = component.get_group_name();
@@ -1755,9 +1758,12 @@ HardwareReadWriteStatus ResourceManager::write(
17551758
1.0 / resource_storage_->hardware_info_map_[component.get_name()].write_rate);
17561759
if (
17571760
component.get_last_write_time().seconds() == 0 ||
1758-
(time - component.get_last_write_time()).seconds() >= hw_write_period.seconds())
1761+
(time - component.get_last_write_time()) >= hw_write_period)
17591762
{
1760-
ret_val = component.write(time, hw_write_period);
1763+
const rclcpp::Duration actual_period = component.get_last_write_time().seconds() == 0
1764+
? hw_write_period
1765+
: time - component.get_last_read_time();
1766+
ret_val = component.write(time, actual_period);
17611767
}
17621768
}
17631769
const auto component_group = component.get_group_name();

0 commit comments

Comments
 (0)