time-stamp.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 /* --------------------------------------------------------------------- */
11 /* --- INCLUDE --------------------------------------------------------- */
12 /* --------------------------------------------------------------------- */
13 
14 /* SOT */
15 #include <dynamic-graph/factory.h>
16 
19 #include <sot/core/time-stamp.hh>
20 
21 /* --------------------------------------------------------------------- */
22 /* --- CLASS ----------------------------------------------------------- */
23 /* --------------------------------------------------------------------- */
24 
25 using namespace dynamicgraph;
26 using namespace dynamicgraph::sot;
27 
29 
30 /* --- CONSTRUCTION ---------------------------------------------------- */
31 TimeStamp::TimeStamp(const std::string &name)
32  : Entity(name),
33  offsetValue(0),
34  offsetSet(false),
35  timeSOUT("TimeStamp(" + name + ")::output(vector2)::time"),
36  timeDoubleSOUT("TimeStamp(" + name + ")::output(double)::timeDouble"),
37  timeOnceSOUT(boost::bind(&TimeStamp::getTimeStamp, this, _1, _2),
39  "TimeStamp(" + name + ")::output(vector2)::synchro"),
40  timeOnceDoubleSOUT(
41  boost::bind(&TimeStamp::getTimeStampDouble, this,
42  SOT_CALL_SIG(timeSOUT, dynamicgraph::Vector), _1),
43  timeSOUT, "TimeStamp(" + name + ")::output(double)::synchroDouble") {
44  sotDEBUGIN(15);
45 
46  timeSOUT.setFunction(boost::bind(&TimeStamp::getTimeStamp, this, _1, _2));
48  boost::bind(&TimeStamp::getTimeStampDouble, this,
50  timeOnceSOUT.setNeedUpdateFromAllChildren(true);
51  timeOnceDoubleSOUT.setNeedUpdateFromAllChildren(true);
54 
55  gettimeofday(&val, NULL);
56 
57  sotDEBUGOUT(15);
58 }
59 
60 /* --- DISPLAY --------------------------------------------------------- */
61 void TimeStamp::display(std::ostream &os) const {
62  os << "TimeStamp <> : " << val.tv_sec << "s; " << val.tv_usec << "us."
63  << std::endl;
64 }
65 
66 /* --------------------------------------------------------------------- */
67 /* --- CONTROL --------------------------------------------------------- */
68 /* --------------------------------------------------------------------- */
69 
71  const sigtime_t & /*time*/) {
72  sotDEBUGIN(15);
73  gettimeofday(&val, NULL);
74  if (res.size() != 2) res.resize(2);
75 
76  res(0) = static_cast<double>(val.tv_sec);
77  res(1) = static_cast<double>(val.tv_usec);
78  sotDEBUGOUT(15);
79  return res;
80 }
81 
83  double &res) {
84  sotDEBUGIN(15);
85 
86  if (offsetSet)
87  res = (vect(0) - (double)offsetValue) * 1000;
88  else
89  res = vect(0) * 1000;
90  res += vect(1) / 1000;
91  sotDEBUGOUT(15);
92  return res;
93 }
dynamicgraph::sot::TimeStamp::TimeStamp
TimeStamp(const std::string &name)
Definition: time-stamp.cpp:31
dynamicgraph::sot::TimeStamp::offsetSet
bool offsetSet
Definition: time-stamp.hh:62
dynamicgraph
dynamicgraph::Entity
boost
dynamicgraph::sot::TimeStamp::display
virtual void display(std::ostream &os) const
Definition: time-stamp.cpp:61
dynamicgraph::sot::TimeStamp::getTimeStamp
dynamicgraph::Vector & getTimeStamp(dynamicgraph::Vector &res, const sigtime_t &time)
Definition: time-stamp.cpp:70
dynamicgraph::Signal::setFunction
virtual void setFunction(boost::function2< T &, T &, Time > t, Mutex *mutexref=NULL)
dynamicgraph::sot::TimeStamp::timeOnceDoubleSOUT
dynamicgraph::SignalTimeDependent< double, sigtime_t > timeOnceDoubleSOUT
Definition: time-stamp.hh:81
dynamicgraph::sot::DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(FeaturePosture, "FeaturePosture")
res
res
sotDEBUGOUT
#define sotDEBUGOUT(level)
Definition: debug.hh:215
dynamicgraph::sigtime_t
int64_t sigtime_t
sotDEBUGIN
#define sotDEBUGIN(level)
Definition: debug.hh:214
macros-signal.hh
dynamicgraph::sot::TimeStamp::timeDoubleSOUT
dynamicgraph::Signal< double, sigtime_t > timeDoubleSOUT
Definition: time-stamp.hh:75
dynamicgraph::sotNOSIGNAL
SignalArray< sigtime_t > sotNOSIGNAL(0)
SOT_CALL_SIG
#define SOT_CALL_SIG(sotName, sotType)
Definition: macros-signal.hh:14
dynamicgraph::Vector
Eigen::VectorXd Vector
dynamicgraph::sot::double
double
Definition: fir-filter.cpp:49
dynamicgraph::sot::TimeStamp
Definition: time-stamp.hh:54
matrix-geometry.hh
time-stamp.hh
dynamicgraph::sot
dynamicgraph::sot::TimeStamp::getTimeStampDouble
double & getTimeStampDouble(const dynamicgraph::Vector &vect, double &res)
Definition: time-stamp.cpp:82
dynamicgraph::sot::TimeStamp::val
struct timeval val
Definition: time-stamp.hh:60
dynamicgraph::sot::TimeStamp::timeOnceSOUT
dynamicgraph::SignalTimeDependent< dynamicgraph::Vector, sigtime_t > timeOnceSOUT
Definition: time-stamp.hh:80
dynamicgraph::sot::TimeStamp::timeSOUT
dynamicgraph::Signal< dynamicgraph::Vector, sigtime_t > timeSOUT
Definition: time-stamp.hh:74
dynamicgraph::Entity::signalRegistration
void signalRegistration(const SignalArray< sigtime_t > &signals)
dynamicgraph::sot::TimeStamp::offsetValue
std::size_t offsetValue
Definition: time-stamp.hh:61
compile.name
name
Definition: compile.py:23


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:32