Skip to content

Commit bc3d5c2

Browse files
committed
Parse the actual period to the read and write methods
1 parent fda0f0c commit bc3d5c2

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
@@ -1676,9 +1676,12 @@ HardwareReadWriteStatus ResourceManager::read(
16761676
1.0 / resource_storage_->hardware_info_map_[component.get_name()].read_rate);
16771677
if (
16781678
component.get_last_read_time().seconds() == 0 ||
1679-
(time - component.get_last_read_time()).seconds() >= hw_read_period.seconds())
1679+
(time - component.get_last_read_time()) >= hw_read_period)
16801680
{
1681-
ret_val = component.read(time, hw_read_period);
1681+
const rclcpp::Duration actual_period = component.get_last_read_time().seconds() == 0
1682+
? hw_read_period
1683+
: time - component.get_last_read_time();
1684+
ret_val = component.read(time, actual_period);
16821685
}
16831686
}
16841687
const auto component_group = component.get_group_name();
@@ -1753,9 +1756,12 @@ HardwareReadWriteStatus ResourceManager::write(
17531756
1.0 / resource_storage_->hardware_info_map_[component.get_name()].write_rate);
17541757
if (
17551758
component.get_last_write_time().seconds() == 0 ||
1756-
(time - component.get_last_write_time()).seconds() >= hw_write_period.seconds())
1759+
(time - component.get_last_write_time()) >= hw_write_period)
17571760
{
1758-
ret_val = component.write(time, hw_write_period);
1761+
const rclcpp::Duration actual_period = component.get_last_write_time().seconds() == 0
1762+
? hw_write_period
1763+
: time - component.get_last_read_time();
1764+
ret_val = component.write(time, actual_period);
17591765
}
17601766
}
17611767
const auto component_group = component.get_group_name();

0 commit comments

Comments
 (0)