Assign Header stamp.sec/nanosec from external source
I have data from some simulated sensors generated not for ROS2. I am trying to have a series of nodes that take as input the folders where are the sensor data and from them generate ROS2 topics. I already created my publisher nodes and they are working fine. However, I am now facing the issue of what to put in the header
field of the messages I am publishing.
For convenience, I will do the example of a camera output which in my case is an image (.png
). Each .png
file has a filename that contains the the "simulation" timestamp, for example: camera1_000669401_sim2.png
. The number 000669401
is the simulation timestamp in milliseconds. At first I was thinking to take this value and put it in the sec
field of the header
file. Then, I realized that the sec
field must be an int
. Then, a doubt came to my mind: what I am doing makes sense or I should do it differently?
Let's imagine that I have the following files in a folder:
camera1_000669401_sim2.png
camera1_000669601_sim2.png
camera1_000669801_sim2.png
camera1_000670001_sim2.png
camera1_000670201_sim2.png
I would like to publish msgs with the header files with:
000669401
000669601
000669801
...
milliseconds