Robotics StackExchange | Archived questions

Delay a ROS Topic by a certain amount of time

Actual problem:

I have a controller node that subscribes to 2 topics and publishes to 1 topic. Although, in simulation everything seems to be working as expected, in actual HW, the performance degrades. I suspect the problem is that one of the two input topics is lagging behind the other one by a significant amount of time.

Question:

I want to re-create this behavior in simulation in order to test the robustness of the controller. Therefore, I need to delay one of the topics by a certain amount of time - ideally this should be configurable parameter. I could write a node that has a FIFO memory buffer and adjust the delay-time by monitoring the frequency of the topic. Before I do that, is there a command line tool that I can use?

Asked by csg on 2020-05-18 09:40:05 UTC

Comments

Answers

you can firstly record the bag file, then check the timestamp of each topic. I mean, each msg has it's timepoint, by checking it, you should know whether there is a lag.

Asked by piupiu_island on 2021-03-31 15:34:14 UTC

Comments

You can use ros::topic::waitForMessage

Asked by mohamed ahmed on 2021-04-01 08:31:17 UTC

Comments

Hi, If your simulation is constantly outputting data, you can reduce the throughput dropping messages using topic_tools drop. It's not a delay though but a change in frequency. Not sure if you could use topic_tools transform to change the timestamp, the message would be passed straight away just with the changed timestamp.

Asked by martimorta on 2021-04-02 05:48:59 UTC

Comments