sot-talos-balance  1.7.0
round-double-to-int.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018, Gepetto team, LAAS-CNRS
3  *
4  * This file is part of sot-talos-balance.
5  * sot-talos-balance is free software: you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public License
7  * as published by the Free Software Foundation, either version 3 of
8  * the License, or (at your option) any later version.
9  * sot-talos-balance is distributed in the hope that it will be
10  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details. You should
13  * have received a copy of the GNU Lesser General Public License along
14  * with sot-talos-balance. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
18 
19 #include <sot/core/debug.hh>
20 #include <dynamic-graph/factory.h>
21 #include <dynamic-graph/all-commands.h>
22 
23 namespace dynamicgraph
24 {
25  namespace sot
26  {
27  namespace talos_balance
28  {
29  namespace dg = ::dynamicgraph;
30  using namespace dg;
31  using namespace dg::command;
32 
33 #define INPUT_SIGNALS m_sinSIN
34 
35 #define OUTPUT_SIGNALS m_soutSOUT
36 
39  typedef RoundDoubleToInt EntityClassName;
40 
41  /* --- DG FACTORY ---------------------------------------------------- */
42  DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(RoundDoubleToInt,
43  "RoundDoubleToInt");
44 
45  /* ------------------------------------------------------------------- */
46  /* --- CONSTRUCTION -------------------------------------------------- */
47  /* ------------------------------------------------------------------- */
48  RoundDoubleToInt::RoundDoubleToInt(const std::string& name)
49  : Entity(name)
50  , CONSTRUCT_SIGNAL_IN(sin, double)
51  , CONSTRUCT_SIGNAL_OUT(sout, int, INPUT_SIGNALS)
52  {
53  Entity::signalRegistration( INPUT_SIGNALS << OUTPUT_SIGNALS );
54 
55  /* Commands. */
56  addCommand("init", makeCommandVoid0(*this, &RoundDoubleToInt::init, docCommandVoid0("Initialize the entity.")));
57  }
58 
59  /* ------------------------------------------------------------------- */
60  /* --- SIGNALS ------------------------------------------------------- */
61  /* ------------------------------------------------------------------- */
62 
64  {
65  double in = m_sinSIN(iter);
66  s = int(round(in));
67  return s;
68  }
69 
70  /* ------------------------------------------------------------------- */
71  /* --- ENTITY -------------------------------------------------------- */
72  /* ------------------------------------------------------------------- */
73 
74  void RoundDoubleToInt::display(std::ostream& os) const
75  {
76  os << "RoundDoubleToInt " << getName();
77 // try
78 // {
79 // getProfiler().report_all(3, os);
80 // }
81 // catch (ExceptionSignal e) {}
82  }
83 
84  } // namespace talos_balance
85  } // namespace sot
86 } // namespace dynamicgraph
87 
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(AdmittanceControllerEndEffector, "AdmittanceControllerEndEffector")
#define OUTPUT_SIGNALS
#define INPUT_SIGNALS
EIGEN_MAKE_ALIGNED_OPERATOR_NEW RoundDoubleToInt(const std::string &name)