Combination of timer and subscriber
Hello, I am currently struggling to write a node for synchronous processing while subscribing to a topic.
Specifically,
- There is a topic that is published at 100~150 Hz.
- Then I have a synchronization process that I want to do at 2 ms (500 Hz).
- The node subscribes to the topic and updates its values, but if the topic cannot be subscribed to in 2 ms (500 Hz), it performs the calculation by referring to the data of the last topic it subscribed to.
I tried to write a node to accomplish this requirement, but ros::subscriber
cannot perform the 2 ms (500 Hz) synchronization process because the process stops until the topic is subscribed.
Is there any solution?
Asked by nemunatu on 2022-11-15 22:07:32 UTC
Comments
It would be nice to share a minimal reproducible example
Asked by ravijoshi on 2022-11-15 22:49:41 UTC
@nemunatu you need to spend more time studying how publish/subscribe systems work. You subscribe once when the app starts, and then after that ros will call a function that you specified for each message that arrives. Setting up a subscribe does take some time, but once it is set up it runs very quick.
Asked by Mike Scheutzow on 2022-11-16 20:46:45 UTC