I want to reset ros::time::now
Hello. I want to reset the result of ros::time::now every time I run a node. However, as shown in the output below
transforms:
-
header:
seq: 0
stamp:
secs: 1664524435
nsecs: 660256768
frame_id: "camera"
child_frame_id: "1"
transform:
translation:
x: -0.0287569508381
y: 0.0157000928516
z: 0.279627278172
rotation:
x: -0.0995996226652
y: 0.863107914335
z: -0.493947224387
w: -0.0337754777654
and I cannot reset secs and nsecs.
Could you please tell me how to solve this problem?
Asked by nemunatu on 2022-09-30 03:07:02 UTC
Answers
This is going to start to sound repetitive -- as I also answered like this in #q407159 -- but: you can't. That's not how this works.
ros::Time
(in ROS 1) wraps your system clock, unless it's been setup to use simulation time. See wiki/roscpp/overview/time for more info.
If your node is responsible for publishing Clock
messages, you could theoretically do what you ask, but that's not very common, and most likely also not what you should be doing.
And as in #q407159: could you perhaps clarify why you're trying to do this? If you could explain what it is you're actually trying to achieve, perhaps we can provide you with a way to do that.
Edit:
I am looking to extract velocity and angular velocity information from the position and orientation information of an AR marker.
Also, I want to reset ros::time::now in order to calculate the micro time to calculate the velocity. I can actually calculate the micro-time without resetting the timer, but I want to set the value of the timer to 0 when the node is executed to make it look better.
I'd suggest using a separate variable to keep track of the passage of time in that case. You don't need to (nor should you want to) "reset ros::time::now" (note: that's a function, not a variable, so it cannot be reset).
Just keep a variable in your algorithm which stores the "previous time" instance, compares it to the current time and calculates delta-t. Then dX/dT
(for simple finite differencing).
Asked by gvdhoorn on 2022-09-30 05:05:29 UTC
Comments
I am looking to extract velocity and angular velocity information from the position and orientation information of an AR marker.
I asked this question this because the /tf topic delivers a transform for the camera position in addition to the AR marker transform, and I would like to subscribe to only one of the two topics.
Also, I want to reset ros::time::now in order to calculate the micro time to calculate the velocity. I can actually calculate the micro-time without resetting the timer, but I want to set the value of the timer to 0 when the node is executed to make it look better.
Translated with www.DeepL.com/Translator (free version)
Asked by nemunatu on 2022-09-30 06:16:15 UTC
Comments
Btw:
1
is an illegal frame name. ROS resource names cannot start with a digit. See wiki/Names.Asked by gvdhoorn on 2022-09-30 05:06:41 UTC
This is a STRING type, so it is not a problem.
Asked by nemunatu on 2022-09-30 06:20:19 UTC
The issue is not the type. The issue is the value.
1
is a digit. That's not a valid character to start a TF frame name with.Asked by gvdhoorn on 2022-09-30 07:59:27 UTC
But that is not the essential problem. The topic is still being delivered normally in this state, and I don't think it has anything to do with ros::Time.
Asked by nemunatu on 2022-10-01 00:23:42 UTC
I'm not claiming it's a cause of anything right now.
I'm pointing out that it's incorrect and should be fixed.
Asked by gvdhoorn on 2022-10-01 02:53:32 UTC