Skip to content

Commit

Permalink
changed timestamp to be ROS timestamp.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobEngel committed Sep 29, 2014
1 parent b948119 commit f363ee7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lsd_slam_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ add_definitions("-DENABLE_SSE")

# Also add some useful compiler flag
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} ${SSE_FLAGS} -std=c++0x -g"
"${CMAKE_CXX_FLAGS} ${SSE_FLAGS} -march=native -std=c++0x"
)

# Set source files
Expand Down
5 changes: 4 additions & 1 deletion lsd_slam_core/src/IOWrapper/ROS/ROSImageStreamThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ void ROSImageStreamThread::vidCb(const sensor_msgs::ImageConstPtr img)
lastSEQ = img->header.seq;

TimestampedMat bufferItem;
bufferItem.timestamp = Timestamp::now(); // TODO: should use time of img object, but should be consistent with other timestamps
if(img->header.stamp.toSec() != 0)
bufferItem.timestamp = Timestamp(img->header.stamp.toSec());
else
bufferItem.timestamp = Timestamp(ros::Time::now().toSec());

if(undistorter != 0)
{
Expand Down
7 changes: 7 additions & 0 deletions lsd_slam_core/src/IOWrapper/Timestamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ boost::mutex Timestamp::localtimeMutex;

Timestamp::Timestamp()
{
externalStamp = 0;
}

Timestamp::Timestamp(double seconds)
{
externalStamp = seconds;
}

double Timestamp::toSec() const
{
if(externalStamp!=0) return externalStamp;
return std::chrono::duration<double>(timePoint - startupTimePoint).count();
}

Expand Down
3 changes: 3 additions & 0 deletions lsd_slam_core/src/IOWrapper/Timestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Timestamp
* Creates an uninitialized timestamp.
*/
Timestamp();
Timestamp(double seconds);

/**
* Returns the timestamp as the time in seconds which has passed since the
Expand Down Expand Up @@ -79,6 +80,8 @@ class Timestamp

static const std::chrono::monotonic_clock::time_point startupTimePoint;
static boost::mutex localtimeMutex;

double externalStamp;
};
}
#endif

0 comments on commit f363ee7

Please sign in to comment.