Skip to content

Commit 17a20f7

Browse files
committed
Parse the actual period to the read and write methods
1 parent 3e31fb4 commit 17a20f7

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
@@ -1630,9 +1630,12 @@ HardwareReadWriteStatus ResourceManager::read(
16301630
1.0 / resource_storage_->hardware_info_map_[component.get_name()].read_rate);
16311631
if (
16321632
component.get_last_read_time().seconds() == 0 ||
1633-
(time - component.get_last_read_time()).seconds() >= hw_read_period.seconds())
1633+
(time - component.get_last_read_time()) >= hw_read_period)
16341634
{
1635-
ret_val = component.read(time, hw_read_period);
1635+
const rclcpp::Duration actual_period = component.get_last_read_time().seconds() == 0
1636+
? hw_read_period
1637+
: time - component.get_last_read_time();
1638+
ret_val = component.read(time, actual_period);
16361639
}
16371640
}
16381641
const auto component_group = component.get_group_name();
@@ -1707,9 +1710,12 @@ HardwareReadWriteStatus ResourceManager::write(
17071710
1.0 / resource_storage_->hardware_info_map_[component.get_name()].write_rate);
17081711
if (
17091712
component.get_last_write_time().seconds() == 0 ||
1710-
(time - component.get_last_write_time()).seconds() >= hw_write_period.seconds())
1713+
(time - component.get_last_write_time()) >= hw_write_period)
17111714
{
1712-
ret_val = component.write(time, hw_write_period);
1715+
const rclcpp::Duration actual_period = component.get_last_write_time().seconds() == 0
1716+
? hw_write_period
1717+
: time - component.get_last_read_time();
1718+
ret_val = component.write(time, actual_period);
17131719
}
17141720
}
17151721
const auto component_group = component.get_group_name();

0 commit comments

Comments
 (0)