com-freezer.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 #include <dynamic-graph/factory.h>
11 
12 #include <sot/core/com-freezer.hh>
13 #include <sot/core/debug.hh>
14 
15 using namespace dynamicgraph;
16 using namespace dynamicgraph::sot;
17 
19 
20 CoMFreezer::CoMFreezer(const std::string &name)
21  : Entity(name),
22  m_lastCoM(3),
23  m_previousPGInProcess(false),
24  m_lastStopTime(-1)
25 
26  ,
27  CoMRefSIN(NULL, "CoMFreezer(" + name + ")::input(vector)::CoMRef"),
28  PGInProcessSIN(NULL,
29  "CoMFreezer(" + name + ")::input(bool)::PGInProcess"),
30  freezedCoMSOUT(boost::bind(&CoMFreezer::computeFreezedCoM, this, _1, _2),
31  CoMRefSIN << PGInProcessSIN,
32  "CoMFreezer(" + name + ")::output(vector)::freezedCoM") {
33  sotDEBUGIN(5);
34 
36 
37  sotDEBUGOUT(5);
38 }
39 
41  sotDEBUGIN(5);
42  sotDEBUGOUT(5);
43  return;
44 }
45 
47  dynamicgraph::Vector &freezedCoM, const sigtime_t &time) {
48  sotDEBUGIN(15);
49 
50  unsigned PGInProcess = PGInProcessSIN(time);
51  if (PGInProcess) /* CoM unfreezed */
52  {
53  m_lastCoM = CoMRefSIN(time);
54  m_previousPGInProcess = (PGInProcess == 0);
55  } else {
56  if (m_previousPGInProcess) /* pg.inprocess switch from 1 to 0 */
57  {
58  m_lastStopTime = time;
59  m_lastCoM = CoMRefSIN(time);
60  m_previousPGInProcess = (PGInProcess == 0);
61  } else if (time < m_lastStopTime + 200) /* keep updating for 1s */
62  {
63  m_lastCoM = CoMRefSIN(time);
64  }
65  }
66 
67  freezedCoM = m_lastCoM;
68 
69  sotDEBUGOUT(15);
70 
71  if (m_lastStopTime < 0) {
72  m_lastCoM = CoMRefSIN(time);
73  m_lastStopTime = time;
74  freezedCoM = m_lastCoM;
75  return freezedCoM;
76  }
77 
78  return m_lastCoM;
79 }
80 
81 void CoMFreezer::display(std::ostream &os) const {
82  os << "CoMFreezer " << getName() << "." << std::endl;
83 }
dynamicgraph::sot::CoMFreezer::PGInProcessSIN
dynamicgraph::SignalPtr< unsigned, sigtime_t > PGInProcessSIN
Definition: com-freezer.hh:61
dynamicgraph::sot::CoMFreezer::m_lastStopTime
sigtime_t m_lastStopTime
Definition: com-freezer.hh:53
dynamicgraph
dynamicgraph::sot::CoMFreezer::CoMFreezer
CoMFreezer(const std::string &name)
Definition: com-freezer.cpp:20
dynamicgraph::Entity
com-freezer.hh
boost
dynamicgraph::sot::CoMFreezer::m_lastCoM
dynamicgraph::Vector m_lastCoM
Definition: com-freezer.hh:51
dynamicgraph::sot::CoMFreezer
Definition: com-freezer.hh:45
dynamicgraph::sot::DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(FeaturePosture, "FeaturePosture")
dynamicgraph::Entity::getName
const std::string & getName() const
debug.hh
dynamicgraph::sot::CoMFreezer::m_previousPGInProcess
bool m_previousPGInProcess
Definition: com-freezer.hh:52
sotDEBUGOUT
#define sotDEBUGOUT(level)
Definition: debug.hh:215
dynamicgraph::sigtime_t
int64_t sigtime_t
dynamicgraph::sot::CoMFreezer::freezedCoMSOUT
dynamicgraph::SignalTimeDependent< dynamicgraph::Vector, sigtime_t > freezedCoMSOUT
Definition: com-freezer.hh:63
sotDEBUGIN
#define sotDEBUGIN(level)
Definition: debug.hh:214
dynamicgraph::sot::CoMFreezer::~CoMFreezer
virtual ~CoMFreezer(void)
Definition: com-freezer.cpp:40
dynamicgraph::Vector
Eigen::VectorXd Vector
dynamicgraph::sot::CoMFreezer::CoMRefSIN
dynamicgraph::SignalPtr< dynamicgraph::Vector, sigtime_t > CoMRefSIN
Definition: com-freezer.hh:60
dynamicgraph::sot::CoMFreezer::display
virtual void display(std::ostream &os) const
Definition: com-freezer.cpp:81
dynamicgraph::sot
dynamicgraph::sot::CoMFreezer::computeFreezedCoM
dynamicgraph::Vector & computeFreezedCoM(dynamicgraph::Vector &freezedCoM, const sigtime_t &time)
Definition: com-freezer.cpp:46
dynamicgraph::Entity::signalRegistration
void signalRegistration(const SignalArray< sigtime_t > &signals)
compile.name
name
Definition: compile.py:23


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