fixed time timer
ros2 example recommends to use create_wall_timer
to make a periodic task.
But I think it waits the time after doing the callback. So it will wait longer time when the processing of callback takes longer time than usual.
I want to wait the fixed time no matter time the callback takes. What is the best way to do this in ros2? This is the sample code in c++ where it waits 1 ms to publish data:
auto next = std::chrono::steady_clock::now();
while (IsAlive()) {
next += std::chrono::microseconds(1000);
Publish(data);
std::this_thread::sleep_until(next);
}