sot-talos-balance  1.6.0
pose-quaternion-to-matrix-homo.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 #include <sot/core/stop-watch.hh>
23 
24 #include <Eigen/Core>
25 
26 namespace dynamicgraph
27 {
28  namespace sot
29  {
30  namespace talos_balance
31  {
32  namespace dg = ::dynamicgraph;
33  using namespace dg;
34  using namespace dg::command;
35 
36 //Size to be aligned "-------------------------------------------------------"
37 #define PROFILE_POSEQUATERNIONTOMATRIXHOMO_COMPUTATION "PoseQuaternionToMatrixHomo computation "
38 
39 #define INPUT_SIGNALS m_sinSIN
40 
41 #define OUTPUT_SIGNALS m_soutSOUT
42 
45  typedef PoseQuaternionToMatrixHomo EntityClassName;
46 
47  /* --- DG FACTORY ---------------------------------------------------- */
48  DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(PoseQuaternionToMatrixHomo,
49  "PoseQuaternionToMatrixHomo");
50 
51  /* ------------------------------------------------------------------- */
52  /* --- CONSTRUCTION -------------------------------------------------- */
53  /* ------------------------------------------------------------------- */
55  : Entity(name)
56  , CONSTRUCT_SIGNAL_IN(sin, dynamicgraph::Vector)
57  , CONSTRUCT_SIGNAL_OUT(sout, MatrixHomogeneous, INPUT_SIGNALS)
58  {
59  Entity::signalRegistration( INPUT_SIGNALS << OUTPUT_SIGNALS );
60 
61  /* Commands. */
62  addCommand("init", makeCommandVoid0(*this, &PoseQuaternionToMatrixHomo::init, docCommandVoid0("Initialize the entity.")));
63  }
64 
65  /* ------------------------------------------------------------------- */
66  /* --- SIGNALS ------------------------------------------------------- */
67  /* ------------------------------------------------------------------- */
68 
69  DEFINE_SIGNAL_OUT_FUNCTION(sout, MatrixHomogeneous)
70  {
72 
73  const dynamicgraph::Vector & vect = m_sinSIN(iter);
74 
75  const Eigen::Map<const Eigen::Quaterniond> q(vect.segment<4>(3).data());
76 
77  s.translation() = vect.head<3>();
78  s.linear() = q.toRotationMatrix();
79 
81 
82  return s;
83  }
84 
85  /* --- COMMANDS ---------------------------------------------------------- */
86 
87  /* ------------------------------------------------------------------- */
88  /* --- ENTITY -------------------------------------------------------- */
89  /* ------------------------------------------------------------------- */
90 
91  void PoseQuaternionToMatrixHomo::display(std::ostream& os) const
92  {
93  os << "PoseQuaternionToMatrixHomo " << getName();
94  try
95  {
96  getProfiler().report_all(3, os);
97  }
98  catch (ExceptionSignal e) {}
99  }
100 
101  } // namespace talos_balance
102  } // namespace sot
103 } // namespace dynamicgraph
104 
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: math/fwd.hh:40
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(AdmittanceControllerEndEffector, "AdmittanceControllerEndEffector")
#define PROFILE_POSEQUATERNIONTOMATRIXHOMO_COMPUTATION
EIGEN_MAKE_ALIGNED_OPERATOR_NEW PoseQuaternionToMatrixHomo(const std::string &name)
#define OUTPUT_SIGNALS