Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timstamp modified #19

Closed
wants to merge 2 commits into from

Conversation

@kanirudh54
Copy link

commented Jun 12, 2015

ros::Time( double(pFrameData->timeStamp) * 1.e-4); was giving the time since the duo_node started, but the ros time is different. I was not able to get the pointcloud as the published pointcloud is very old. The above change worked. I was getting pointcloud. I am doubtful about the type of leftImage.header.stamp .

ros::Time( double(pFrameData->timeStamp) * 1.e-4); was giving the time since the duo_node started, but the ros time is different. I was not able to get the pointcloud as the published pointcloud is very old. The above change worked. I was getting pointcloud. I am doubtful about the type of **leftImage.header.stamp** .
@bsubei

This comment has been minimized.

Copy link
Collaborator

commented Jun 12, 2015

I'm pretty sure header.stamp is not of type double:
http://docs.ros.org/indigo/api/std_msgs/html/msg/Header.html

It's of type time, probably this one here:
http://docs.ros.org/diamondback/api/rostime/html/classros_1_1Time.html

@bsubei

This comment has been minimized.

Copy link
Collaborator

commented Jun 12, 2015

according to the DUO API, the timestamp is a uint32 given in increments of 100 microseconds. So multiplying them by 10^-4 makes them into seconds. Then ros::Time() takes seconds as an argument. It looks correct to me.

@bsubei

This comment has been minimized.

Copy link
Collaborator

commented Jun 12, 2015

Also, the point of using the timestamp from the DUO camera itself (instead of using ros::Time::now) is that it's more accurate (not sure if that's needed, though).

If you want, I guess you could just do:
leftImage.header.stamp = ros::Time::now();

@kanirudh54

This comment has been minimized.

Copy link
Author

commented Jun 12, 2015

ok, so that line has to be changed to ros::Time( double(ros::Time::now().toSec()) ) instead of double(ros::Time::now().toSec()) , also I am suggesting that the timestamp given by the frame should not be used as it starts only since the node is activated. ros time is the system time or the time since the epoch(I think).

or some global variable has to be initialized when the duo node is started and that constant has to be added to the timestamp given by the frame.

Also should I be making a new pull request ? I don't how to modify my previous change

@bsubei

This comment has been minimized.

Copy link
Collaborator

commented Jun 12, 2015

ok, sorry I previously missed your point about the timestamp being since start. Yes, your suggested fix (variable to store start time) sounds right.

For a quick fix (like your code attempts), just do:
leftImage.header.stamp = ros::Time::now();

You can modify your existing pull request by pushing more commits to it (or preferably overwriting the existing one). I recommend doing a git commit --amend and then force pushing to your fork (overwriting the existing commit).

@bsubei

This comment has been minimized.

Copy link
Collaborator

commented Jun 12, 2015

or you could squash commits. There's tons of hints online :)

I did the change but I dont know if [this](#16) problem will arise. **stereo_image_proc** was giving me good disparity maps even after making the change.
@kanirudh54

This comment has been minimized.

Copy link
Author

commented Jun 12, 2015

I did the change, but I dont know if this problem will arise. stereo_image_proc was giving me good disparity maps even after making the change.

@bsubei

This comment has been minimized.

Copy link
Collaborator

commented Jun 12, 2015

That looks good. Not sure @l0g1x would want to use ros::Time::now, though, because you don't get the real time when the frame was actually captured by the camera hardware (which is what pFrameData->timeStamp gives, I assume). I'm sure he can implement your suggestion (to make it the same as ros time and not from beginning of node startup), unless you do it first :)

@kanirudh54

This comment has been minimized.

Copy link
Author

commented Jun 12, 2015

I tried the changes , but I keep getting undefined reference globalvar. I think it is due my lesser understanding of namespaces. I tried few changes suggested on how to declare global variables but I keep getting this error.

What I did was:
driverDUOstereo.h
extern double starttime; // declared the global variable after the include statements outside the namespace(tried inside the namspace but getting error:storage class specified for 'starttime')

node.cpp
double starttime = ros::Time::now().toSec(); //before the ros::Spin() and after the duoDriver.startDUO();

driverDUOstereo.cpp
ros::Time(g_startTime + (double(pFrameData->timeStamp)_1.e-4 ) );// replaced *_ros::Time::now()

@l0g1x

This comment has been minimized.

Copy link
Owner

commented Jun 12, 2015

dont make it extern. just put it under the private variables in the header file. move the starttime = ros::Time::now().toSec(); into the startDUO() function, and dont redefine it since you already prototyped it in the class header. Im not saying this is the solution, but this should allow you to compile

@bsubei

This comment has been minimized.

Copy link
Collaborator

commented Jun 12, 2015

@kanirudh54 I believe this^ is what you're trying to do. No need for a global var, just make a private variable for starttime.

Please try running it (I don't have a DUO right now), but it compiles fine :)

@kanirudh54

This comment has been minimized.

Copy link
Author

commented Jun 12, 2015

Yes that's what I tried but I used double instead of int.It compiles and works(point cloud on rviz and disparity maps using stereo_image_proc) . I will try it with int and let you know.

@bsubei

This comment has been minimized.

Copy link
Collaborator

commented Jun 12, 2015

actually, I just realized toSecs() returns double, so you're right about that.

@kanirudh54

This comment has been minimized.

Copy link
Author

commented Jun 12, 2015

okay

@l0g1x

This comment has been minimized.

Copy link
Owner

commented Jun 12, 2015

So im a bit confused as to what the issue your saying actually is.. For me, i can get a pointcloud just fine (refer to image) without making any changes to the time stamps. I would need to ask some people this question who may know better, but i believe sending the time in which the camera's hardware captured the image is the time that should be used. Are you getting a error when trying to use the tf or tf2 library functions like lookupTransform? if you are then it would make a bit more sense as to why you are having a issue. Im viewing the data in the duo3d_camera frame in rviz.

steps i did:

roslaunch duo3d_ros duo.launch

ROS_NAMESPACE=duo3d_camera rosrun stereo_image_proc stereo_image_proc

rosrun image_view stereo_view stereo:=duo3d_camera image:=image_raw

rosrun rviz rviz

and then change the global frame in rviz to duo3d_camera

@kanirudh54

This comment has been minimized.

Copy link
Author

commented Jun 12, 2015

I am also using tf library. I am trying to run viso2_ros and fovis. Though I am not getting the desired results, I don't get errors like the transform is missing or messages are dropped.(I think I used to get them due to the difference in timestamps). Did you try any visual odometry algorithms?

@l0g1x

This comment has been minimized.

Copy link
Owner

commented Jun 12, 2015

okay im going to post a question on ros answers about this as i dont know truely what should be done as I used different other camera drivers as a reference for the data timestamp. I will hopefully have your answer by tomorrow.

As for trying a visual odometry algorithm, i have not. But after looking at how viso2 processes frame data, i think you would need to use ros::time::now(). Not 100% sure though.

@kanirudh54

This comment has been minimized.

Copy link
Author

commented Jun 12, 2015

okay, thanks

@gitunit

This comment has been minimized.

Copy link
Contributor

commented Jun 13, 2015

so far i tried viso2_ros, fovis and rtabmap. neither of them worked for me. could be very much related to the timestamp. not sure though.

@l0g1x l0g1x closed this Mar 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.