Skip to content

Commit

Permalink
don't write in the first tick
Browse files Browse the repository at this point in the history
  • Loading branch information
VX792 committed Apr 4, 2024
1 parent 5110243 commit 67da21c
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ class AsyncComponentThread
auto measured_period = current_time - previous_time;
previous_time = current_time;

component->write(clock_interface_->get_clock()->now(), measured_period);
if (!first_iteration)
{
component->write(clock_interface_->get_clock()->now(), measured_period);
}
component->read(clock_interface_->get_clock()->now(), measured_period);
first_iteration = false;
}
next_iteration_time += period;
std::this_thread::sleep_until(next_iteration_time);
Expand All @@ -109,6 +113,7 @@ class AsyncComponentThread
std::thread write_and_read_{};

unsigned int cm_update_rate_;
bool first_iteration = true;
rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface_;
};

Expand Down

0 comments on commit 67da21c

Please sign in to comment.