- 3.0.2 rigid body dynamics module.
SelectionMatrix-impl.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4  **********************************************************************************************************************/
5 
6 #pragma once
7 
8 namespace ct {
9 namespace rbd {
10 
11 template <size_t CONTROL_DIM, size_t STATE_DIM, typename SCALAR>
13  : Eigen::Matrix<SCALAR, CONTROL_DIM, STATE_DIM>(other)
14 {
15 }
16 
17 template <size_t CONTROL_DIM, size_t STATE_DIM, typename SCALAR>
19  : Eigen::Matrix<SCALAR, CONTROL_DIM, STATE_DIM>()
20 {
21  setIdentity(floatingBase);
22 }
23 
24 template <size_t CONTROL_DIM, size_t STATE_DIM, typename SCALAR>
25 template <typename T>
26 typename std::enable_if<(STATE_DIM >= 6), T>::type SelectionMatrix<CONTROL_DIM, STATE_DIM, SCALAR>::setIdentity(
27  bool floatingBase)
28 {
29  this->setZero();
30 
31  if (floatingBase)
32  {
33  this->template bottomRightCorner<CONTROL_DIM, STATE_DIM - 6>().setIdentity();
34  }
35  else
36  {
37  this->template bottomRightCorner<CONTROL_DIM, CONTROL_DIM>().setIdentity();
38  }
39 }
40 
41 template <size_t CONTROL_DIM, size_t STATE_DIM, typename SCALAR>
42 template <typename T>
43 typename std::enable_if<(STATE_DIM < 6), T>::type SelectionMatrix<CONTROL_DIM, STATE_DIM, SCALAR>::setIdentity(
44  bool floatingBase)
45 {
46  if (floatingBase)
47  throw std::runtime_error("Selection Matrix for floating base systems should at least have 6 columns");
48 
49  this->setZero();
50  this->template bottomRightCorner<CONTROL_DIM, CONTROL_DIM>().setIdentity();
51 }
52 }
53 }
Definition: eigen_traits.h:23
CppAD::AD< CppAD::cg::CG< double > > SCALAR
EIGEN_MAKE_ALIGNED_OPERATOR_NEW SelectionMatrix()=delete
Selection Matrix for a Rigid Body Dynamics System.
Definition: SelectionMatrix.h:23