Skip to content
Snippets Groups Projects
Commit 664cff91 authored by Olivier Stasse's avatar Olivier Stasse
Browse files

Improve the computation of the initial time.

parent f75ef1ab
No related branches found
No related tags found
No related merge requests found
...@@ -52,10 +52,11 @@ void Log::init(unsigned int nbDofs, unsigned int length) ...@@ -52,10 +52,11 @@ void Log::init(unsigned int nbDofs, unsigned int length)
nbDofs_=nbDofs; nbDofs_=nbDofs;
length_=length; length_=length;
StoredData_.init(nbDofs,length); StoredData_.init(nbDofs,length);
struct timeval current;
gettimeofday(&current,0);
timeorigin_ = (double)current.tv_sec + 0.000001 * ((double)current.tv_usec); gettimeofday(timeorigin_tv_,0);
timeorigin_ = (double)timeorigin_tv_.tv_sec +
0.000001 * ((double)timeorigin_tv_.tv_usec);
} }
...@@ -97,7 +98,8 @@ void Log::record(DataToLog &aDataToLog) ...@@ -97,7 +98,8 @@ void Log::record(DataToLog &aDataToLog)
gettimeofday(&current,0); gettimeofday(&current,0);
StoredData_.timestamp[lrefts_] = StoredData_.timestamp[lrefts_] =
((double)current.tv_sec + 0.000001 * (double)current.tv_usec) - timeorigin_; ((double)(current.tv_sec - time_origin_tv_.tv_sec)
+ 0.000001 * (double)(current.tv_usec - time_origin_tv_.tv_usec));
StoredData_.duration[lrefts_] = time_stop_it_ - time_start_it_; StoredData_.duration[lrefts_] = time_stop_it_ - time_start_it_;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <sys/time.h>
namespace rc_sot_system { namespace rc_sot_system {
...@@ -62,8 +63,8 @@ namespace rc_sot_system { ...@@ -62,8 +63,8 @@ namespace rc_sot_system {
// Circular buffer for all the data. // Circular buffer for all the data.
DataToLog StoredData_; DataToLog StoredData_;
double timeorigin_; double timeorigin_;
struct timeval timeorigin_tv_;
double time_start_it_; double time_start_it_;
double time_stop_it_; double time_stop_it_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment