Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
0cde075b
Commit
0cde075b
authored
6 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
removed old commented code
parent
42766f58
No related branches found
No related tags found
1 merge request
!209
Time stamp
Pipeline
#1873
failed
6 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/time_stamp.cpp
+0
-27
0 additions, 27 deletions
src/time_stamp.cpp
src/time_stamp.h
+0
-22
0 additions, 22 deletions
src/time_stamp.h
with
0 additions
and
49 deletions
src/time_stamp.cpp
+
0
−
27
View file @
0cde075b
...
@@ -5,15 +5,6 @@ namespace wolf {
...
@@ -5,15 +5,6 @@ namespace wolf {
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
TimeStamp
&
_ts
)
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
TimeStamp
&
_ts
)
{
{
// std::ios_base::fmtflags fmtfl;
//
// //get/set ostream flags and precision digits
// fmtfl = os.flags(std::ios::left);
// os.setf(std::ios::fixed, std::ios::floatfield);
// std::streamsize nn;
// nn = os.precision(TimeStamp::TIME_STAMP_DIGITS_);
os
<<
_ts
.
getSeconds
()
<<
"."
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
9
)
<<
std
::
right
<<
_ts
.
getNanoSeconds
();
// write obj to stream
os
<<
_ts
.
getSeconds
()
<<
"."
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
9
)
<<
std
::
right
<<
_ts
.
getNanoSeconds
();
// write obj to stream
return
os
;
return
os
;
}
}
...
@@ -34,14 +25,12 @@ TimeStamp::TimeStamp(const TimeStamp& _ts) :
...
@@ -34,14 +25,12 @@ TimeStamp::TimeStamp(const TimeStamp& _ts) :
}
}
TimeStamp
::
TimeStamp
(
const
Scalar
&
_ts
)
:
TimeStamp
::
TimeStamp
(
const
Scalar
&
_ts
)
:
//time_stamp_(_ts)
time_stamp_nano_
(
_ts
>
0
?
(
unsigned
long
int
)(
_ts
*
1e9
)
:
0
)
time_stamp_nano_
(
_ts
>
0
?
(
unsigned
long
int
)(
_ts
*
1e9
)
:
0
)
{
{
//
//
}
}
TimeStamp
::
TimeStamp
(
const
unsigned
long
int
&
_sec
,
const
unsigned
long
int
&
_nsec
)
:
TimeStamp
::
TimeStamp
(
const
unsigned
long
int
&
_sec
,
const
unsigned
long
int
&
_nsec
)
:
//time_stamp_((Scalar)_sec + (Scalar)_nsec/(Scalar)1e9)
time_stamp_nano_
(
_sec
*
NANOSECS
+
_nsec
)
time_stamp_nano_
(
_sec
*
NANOSECS
+
_nsec
)
{
{
//
//
...
@@ -76,27 +65,11 @@ TimeStamp TimeStamp::operator -(const Scalar& dt) const
...
@@ -76,27 +65,11 @@ TimeStamp TimeStamp::operator -(const Scalar& dt) const
inline
void
TimeStamp
::
operator
-=
(
const
Scalar
&
dt
)
inline
void
TimeStamp
::
operator
-=
(
const
Scalar
&
dt
)
{
{
unsigned
long
int
dt_nano
=
(
unsigned
long
int
)(
dt
*
NANOSECS
);
unsigned
long
int
dt_nano
=
(
unsigned
long
int
)(
dt
*
NANOSECS
);
//time_stamp_ -= dt;
time_stamp_nano_
=
(
dt_nano
>
time_stamp_nano_
?
0
:
time_stamp_nano_
-
dt_nano
);
time_stamp_nano_
=
(
dt_nano
>
time_stamp_nano_
?
0
:
time_stamp_nano_
-
dt_nano
);
}
}
void
TimeStamp
::
print
(
std
::
ostream
&
ost
)
const
void
TimeStamp
::
print
(
std
::
ostream
&
ost
)
const
{
{
//std::streamsize nn;
//std::ios_base::fmtflags fmtfl;
//
////get/set ostream flags and precision digits
//fmtfl = ost.flags(std::ios::left);
//ost.setf(std::ios::fixed, std::ios::floatfield);
//nn = ost.precision(TIME_STAMP_DIGITS_);
//
////send to ostream
//ost << this->time_stamp_;
//
////restore flags and precision
//ost.flags(fmtfl);
//ost.precision(nn);
ost
<<
*
this
;
ost
<<
*
this
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/time_stamp.h
+
0
−
22
View file @
0cde075b
...
@@ -23,8 +23,6 @@ class TimeStamp
...
@@ -23,8 +23,6 @@ class TimeStamp
{
{
protected:
protected:
unsigned
long
int
time_stamp_nano_
;
///< Time stamp. Expressed in nanoseconds from 1th jan 1970.
unsigned
long
int
time_stamp_nano_
;
///< Time stamp. Expressed in nanoseconds from 1th jan 1970.
//Scalar time_stamp_; ///< Time stamp. Expressed in seconds from 1th jan 1970.
//static const unsigned int TIME_STAMP_DIGITS_ = 10; ///< Number of digits to print time stamp values
public:
public:
/** \brief Constructor
/** \brief Constructor
...
@@ -178,101 +176,81 @@ class TimeStamp
...
@@ -178,101 +176,81 @@ class TimeStamp
inline
void
TimeStamp
::
set
(
const
Scalar
&
ts
)
inline
void
TimeStamp
::
set
(
const
Scalar
&
ts
)
{
{
//time_stamp_ = ts;
time_stamp_nano_
=
(
ts
>
0
?
(
unsigned
long
int
)(
ts
*
NANOSECS
)
:
0
);
time_stamp_nano_
=
(
ts
>
0
?
(
unsigned
long
int
)(
ts
*
NANOSECS
)
:
0
);
}
}
inline
void
TimeStamp
::
set
(
const
unsigned
long
int
&
sec
,
const
unsigned
long
int
&
nanosec
)
inline
void
TimeStamp
::
set
(
const
unsigned
long
int
&
sec
,
const
unsigned
long
int
&
nanosec
)
{
{
//time_stamp_ = (Scalar)(sec) + (Scalar)(nanosec) / (Scalar)(1e9);
time_stamp_nano_
=
sec
*
NANOSECS
+
nanosec
;
time_stamp_nano_
=
sec
*
NANOSECS
+
nanosec
;
}
}
inline
void
TimeStamp
::
set
(
const
timeval
&
ts
)
inline
void
TimeStamp
::
set
(
const
timeval
&
ts
)
{
{
//time_stamp_ = (Scalar)(ts.tv_sec) + (Scalar)(ts.tv_usec) / 1e6;
time_stamp_nano_
=
(
unsigned
long
int
)(
ts
.
tv_sec
*
NANOSECS
)
+
(
unsigned
long
int
)(
ts
.
tv_usec
*
1000
);
time_stamp_nano_
=
(
unsigned
long
int
)(
ts
.
tv_sec
*
NANOSECS
)
+
(
unsigned
long
int
)(
ts
.
tv_usec
*
1000
);
}
}
inline
Scalar
TimeStamp
::
get
()
const
inline
Scalar
TimeStamp
::
get
()
const
{
{
//return time_stamp_;
return
((
Scalar
)(
time_stamp_nano_
))
*
1e-9
;
return
((
Scalar
)(
time_stamp_nano_
))
*
1e-9
;
}
}
inline
unsigned
long
int
TimeStamp
::
getSeconds
()
const
inline
unsigned
long
int
TimeStamp
::
getSeconds
()
const
{
{
//unsigned long int ts;
//ts = (unsigned long int)(((floor(time_stamp_))));
//return ts;
return
time_stamp_nano_
/
NANOSECS
;
return
time_stamp_nano_
/
NANOSECS
;
}
}
inline
unsigned
long
int
TimeStamp
::
getNanoSeconds
()
const
inline
unsigned
long
int
TimeStamp
::
getNanoSeconds
()
const
{
{
//Scalar ts;
//ts = (Scalar)((floor(time_stamp_)));
//return (unsigned long int)(((time_stamp_ - ts) * 1e9));
return
time_stamp_nano_
%
NANOSECS
;
return
time_stamp_nano_
%
NANOSECS
;
}
}
inline
void
TimeStamp
::
operator
=
(
const
TimeStamp
&
ts
)
inline
void
TimeStamp
::
operator
=
(
const
TimeStamp
&
ts
)
{
{
//time_stamp_ = ts.get();
time_stamp_nano_
=
ts
.
time_stamp_nano_
;
time_stamp_nano_
=
ts
.
time_stamp_nano_
;
}
}
inline
void
TimeStamp
::
operator
=
(
const
Scalar
&
ts
)
inline
void
TimeStamp
::
operator
=
(
const
Scalar
&
ts
)
{
{
//time_stamp_ = ts;
time_stamp_nano_
=
(
unsigned
long
int
)(
ts
*
NANOSECS
);
time_stamp_nano_
=
(
unsigned
long
int
)(
ts
*
NANOSECS
);
}
}
inline
bool
TimeStamp
::
operator
==
(
const
TimeStamp
&
ts
)
const
inline
bool
TimeStamp
::
operator
==
(
const
TimeStamp
&
ts
)
const
{
{
//return (time_stamp_ == ts.get());
return
(
time_stamp_nano_
==
ts
.
time_stamp_nano_
);
return
(
time_stamp_nano_
==
ts
.
time_stamp_nano_
);
}
}
inline
bool
TimeStamp
::
operator
!=
(
const
TimeStamp
&
ts
)
const
inline
bool
TimeStamp
::
operator
!=
(
const
TimeStamp
&
ts
)
const
{
{
//return (time_stamp_ != ts.get());
return
(
time_stamp_nano_
!=
ts
.
time_stamp_nano_
);
return
(
time_stamp_nano_
!=
ts
.
time_stamp_nano_
);
}
}
inline
bool
TimeStamp
::
operator
<
(
const
TimeStamp
&
ts
)
const
inline
bool
TimeStamp
::
operator
<
(
const
TimeStamp
&
ts
)
const
{
{
//return (time_stamp_ < ts.get());
return
(
time_stamp_nano_
<
ts
.
time_stamp_nano_
);
return
(
time_stamp_nano_
<
ts
.
time_stamp_nano_
);
}
}
inline
bool
TimeStamp
::
operator
>
(
const
TimeStamp
&
ts
)
const
inline
bool
TimeStamp
::
operator
>
(
const
TimeStamp
&
ts
)
const
{
{
//return (time_stamp_ > ts.get());
return
(
time_stamp_nano_
>
ts
.
time_stamp_nano_
);
return
(
time_stamp_nano_
>
ts
.
time_stamp_nano_
);
}
}
inline
bool
TimeStamp
::
operator
<=
(
const
TimeStamp
&
ts
)
const
inline
bool
TimeStamp
::
operator
<=
(
const
TimeStamp
&
ts
)
const
{
{
//return (time_stamp_ <= ts.get());
return
(
time_stamp_nano_
<=
ts
.
time_stamp_nano_
);
return
(
time_stamp_nano_
<=
ts
.
time_stamp_nano_
);
}
}
inline
bool
TimeStamp
::
operator
>=
(
const
TimeStamp
&
ts
)
const
inline
bool
TimeStamp
::
operator
>=
(
const
TimeStamp
&
ts
)
const
{
{
//return (time_stamp_ >= ts.get());
return
(
time_stamp_nano_
>=
ts
.
time_stamp_nano_
);
return
(
time_stamp_nano_
>=
ts
.
time_stamp_nano_
);
}
}
inline
void
TimeStamp
::
operator
+=
(
const
Scalar
&
dt
)
inline
void
TimeStamp
::
operator
+=
(
const
Scalar
&
dt
)
{
{
//time_stamp_ += dt;
time_stamp_nano_
+=
(
unsigned
long
int
)(
dt
*
NANOSECS
);
time_stamp_nano_
+=
(
unsigned
long
int
)(
dt
*
NANOSECS
);
}
}
inline
Scalar
TimeStamp
::
operator
-
(
const
TimeStamp
&
ts
)
const
inline
Scalar
TimeStamp
::
operator
-
(
const
TimeStamp
&
ts
)
const
{
{
//return (time_stamp_ - ts.get());
return
Scalar
((
long
int
)(
time_stamp_nano_
-
ts
.
time_stamp_nano_
))
*
1e-9
;
// long int cast fix overflow in case of negative substraction result
return
Scalar
((
long
int
)(
time_stamp_nano_
-
ts
.
time_stamp_nano_
))
*
1e-9
;
// long int cast fix overflow in case of negative substraction result
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment