truncating ros time
Hi, Is there anyway i could truncate the ros time value to certain length, lets say i need the time value to be only up to a certain decimal points
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
Hi, Is there anyway i could truncate the ros time value to certain length, lets say i need the time value to be only up to a certain decimal points
I'll jump in here because I think exactly how the TF system works needs to be clarified.
TF doesn't look for a transform with exactly the right time stamp when you lookup a transform, it almost always interpolates the two nearest TF samples. It can also extrapolate into the future a short time based on previous data but this is not recommended.
Are you getting the Lookup would require extrapolation at time X
error? In this case adding a timeout Duration to the lookupTransform call would be the preferred method of solving this.
But as @gvdhoorn says, it would be helpful to know the actual problem you're trying to solve before we can suggest the best solution for you.
Update:
Thanks for clarifying the problem you're trying to solve, I see two possible solutions you can look into.
Use message filters to synchronise the messages as @tfoote has suggested
You could request the most recent data when looking up the transform by setting the time to zero. This achieves exactly what you suggested initially via a different mechanism.
Hope this helps.
Hi Peter,
I know this, lemme explain my specific problem.
I have depth image from a sensor which i actually get using a another API and I convert to a ROS message. The odometry is also taken similarly and tf is broadcasted, I assign the time stamps myself. They are running on two separate threads.
The time stamps do not match because of this, I convert the depth to PCL and i need to transform it to another frame. The lookup gives an error. I cannot hang my conversion until a transform is taken. I just need to find a way to transform it in some viable rate. My sensors run on 15-25 Hz
So a time stamp in this range is okay for me. So i thought i would cap the initial stamp at some decimal place. Don't know whether it is viable or possible. Or maybe I'm just shooting in some uselss direction.
From your use case you should not be truncating your timestamps. What you're trying to do is basically extrapolate into the future by a small bit, but rounding all your timestamps. This has been explored many times and almost always leads to unintended consequences.
You cannot apply a transform until the data is available. It can actually make a difference when during the 40ms between a 25Hz signal is processed. I'd strongly recommend that you look at using a Message Filter in your pipeline to hold the data for the few milliseconds until the data is available.
@tfoote, Thanks didn't know about this message filter. Another small question what's your advice use tf since pcl_ros still has tf in its conversions, or shift to tf2?
Asked: 2018-10-09 14:25:48 -0600
Seen: 603 times
Last updated: Oct 10 '18
How can I get both tf and tf2 working in ROS
openCV transform datatypes to ROS msg tf/goal
Transform relative to absolute position
Is there a robot monitor node?
Get an error when import tf2_ros
TF exception in openni_launch [closed]
octomap_server doesn't create map
So you want to reduce the precision of timestamps by truncating them?
If so, could I ask you for a topic title change? Right now it seems like you're asking about the precision of rostime and/or ROS timestamps. But that is not actually the case.
And to avoid an xy-problem: can you describe why you'd want to do this?
Hi, I want to stop tf from looking into the exact time stamp to find a transform
And why do you want to do that? What is it exactly that you are trying to achieve?