ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

I want to reset ros::time::now [closed]

asked 2022-09-30 03:07:02 -0500

nemunatu gravatar image

updated 2022-09-30 05:14:27 -0500

gvdhoorn gravatar image

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?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by nemunatu
close date 2022-10-04 23:48:26.581297

Comments

Btw:

child_frame_id: "1"

1 is an illegal frame name. ROS resource names cannot start with a digit. See wiki/Names.

gvdhoorn gravatar image gvdhoorn  ( 2022-09-30 05:06:41 -0500 )edit

This is a STRING type, so it is not a problem.

nemunatu gravatar image nemunatu  ( 2022-09-30 06:20:19 -0500 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2022-09-30 07:59:27 -0500 )edit

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.

nemunatu gravatar image nemunatu  ( 2022-10-01 00:23:42 -0500 )edit

I'm not claiming it's a cause of anything right now.

I'm pointing out that it's incorrect and should be fixed.

gvdhoorn gravatar image gvdhoorn  ( 2022-10-01 02:53:32 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-09-30 05:05:29 -0500

gvdhoorn gravatar image

updated 2022-10-01 02:58:33 -0500

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).

edit flag offensive delete link more

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)

nemunatu gravatar image nemunatu  ( 2022-09-30 06:16:15 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-09-30 03:07:02 -0500

Seen: 115 times

Last updated: Oct 01 '22