ipa320 / softkinetic

This repository holds a ROS driver package for an interactive gesture camera (softkinetic).
23 stars 40 forks source link

Timestamps, Camera Info, Depth Image and more #41

Open mklingen opened 9 years ago

mklingen commented 9 years ago

EDIT: Looks like most of my problems were solved already in the unreleased "indigo" branch. That's confusing.

Hi guys, Today I was working on improving the ROS driver for some robotics experiments we've been running at Carnegie Mellon. First of all, thank you very much for getting this thing started. It really has sped up our development process.

Unfortunately, there are a few problems with the driver:

When we're done making our changes, we can create a pull request for this.

Regards, Matt

gavanderhoorn commented 9 years ago

@mklingen: sorry about that. The readme was just updated to avoid these kind of things in the future.

corot commented 9 years ago

Yes... apologies for the confusing situation. I suggest you to try indigo branch, but most of the problems you report are NOT fixed there, except for the depth image and for the camera intrinsics published on camera_info. Point by point:

mklingen commented 9 years ago

Okay, thanks for clearing that up! We're going to merge in the indigo branch, and then try fixing the timestamps. Intrinsics, extrinsics, and depth image seem to be fixed in the indigo branch.

mklingen commented 9 years ago

Alright, we figured out how the timestamps work. The timestamps given by the driver are in microseconds of CLOCK_MONOTONIC time (ie, time since the machine started up). We made this little helper function to convert to ROS standard UTC time:

// Assuming timestamp is in microseconds since startup (CLOCK_MONOTONIC), and is earlier
// than the current time, calculates the UTC time in seconds when the timestamp occurred.
double timeStampToRosTime(uint64_t timestamp)
{
    timespec time;
    clock_gettime(CLOCK_MONOTONIC, &time);
    double monotonic_time = time.tv_sec  + time.tv_nsec * 1.0e-9;
    double ros_time = ros::Time::now().toSec();
    return ros_time - (monotonic_time - 1.0e-6 * timestamp);
}

This can be used to create a ROS timestamp in this way:

ros::Time stamp = ros::Time(timeStampToRosTime(data.timeOfCapture));

where "data" is a color or depth callback. Not sure what the best way to contribute this back to the codebase is. We could maybe make a branch off of indigo?

corot commented 9 years ago

Cool! PR on indigo or hydro would be great. We can cherry-pick to the other maintained branch.