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