Ravelin
FSABAlgorithm.h
1 /****************************************************************************
2  * Copyright 2005 Evan Drumwright
3  * This library is distributed under the terms of the Apache V2.0
4  * License (obtainable from http://www.apache.org/licenses/LICENSE-2.0).
5  ****************************************************************************/
6 
7 #ifndef FSAB_ALGORITHM
8 #error This class is not to be included by the user directly. Use FSABAlgorithmd.h or FSABAlgorithmf.h instead.
9 #endif
10 
12 
14 
36 {
37  friend class RC_ARTICULATED_BODY;
38 
39  public:
41  ~FSAB_ALGORITHM() {}
42  boost::shared_ptr<RC_ARTICULATED_BODY> get_body() const { return boost::shared_ptr<RC_ARTICULATED_BODY>(_body); }
43  void set_body(boost::shared_ptr<RC_ARTICULATED_BODY> body) { _body = body; }
44  void calc_fwd_dyn();
48  void apply_generalized_impulse(const VECTORN& gj);
49  void apply_impulse(const SMOMENTUM& j, boost::shared_ptr<RIGIDBODY> link);
50  void calc_spatial_inertias(boost::shared_ptr<RC_ARTICULATED_BODY> body);
51 
53  boost::weak_ptr<RC_ARTICULATED_BODY> _body;
54 
56  std::vector<SACCEL> _a;
57 
59  std::vector<SPATIAL_AB_INERTIA> _I;
60 
62  std::vector<SFORCE> _Z;
63 
65  std::vector<SVELOCITY> _dv;
66 
68  std::vector<SACCEL> _c;
69 
71  std::vector<std::vector<SMOMENTUM> > _Is;
72 
74  std::vector<MATRIXN> _sIs;
75 
77  std::vector<MATRIXN> _usIs, _vsIs;
78  std::vector<VECTORN> _ssIs;
79 
81  std::vector<bool> _rank_deficient;
82 
84  std::vector<VECTORN> _mu;
85 
86  private:
87  // pointer to the linear algebra routines
88  boost::shared_ptr<LINALG> _LA;
89 
91  VECTORN _workv, _workv2, _sTY, _qd_delta, _sIsmu, _Qi, _Q;
92  MATRIXN _sIss, _workM;
93  std::vector<SMOMENTUM> _Y;
94 
96  std::vector<bool> _processed;
97 
98  void calc_fwd_dyn_special();
99  static REAL sgn(REAL x);
100  static void push_children(boost::shared_ptr<RIGIDBODY> link, std::queue<boost::shared_ptr<RIGIDBODY> >& q);
101  void apply_coulomb_joint_friction(boost::shared_ptr<RC_ARTICULATED_BODY> body);
102  void apply_generalized_impulse(unsigned index, VECTORN& vgj);
103  void set_spatial_velocities(boost::shared_ptr<RC_ARTICULATED_BODY> body);
104  void calc_spatial_accelerations(boost::shared_ptr<RC_ARTICULATED_BODY> body);
105  void calc_spatial_zero_accelerations(boost::shared_ptr<RC_ARTICULATED_BODY> body);
106  void calc_spatial_coriolis_vectors(boost::shared_ptr<RC_ARTICULATED_BODY> body);
107  VECTORN& solve_sIs(unsigned idx, const VECTORN& v, VECTORN& result) const;
108  MATRIXN& solve_sIs(unsigned idx, const MATRIXN& v, MATRIXN& result) const;
109  MATRIXN& transpose_solve_sIs(unsigned idx, const std::vector<SVELOCITY>& m, MATRIXN& result) const;
110 }; // end class
111 
112 
std::vector< MATRIXN > _sIs
Cholesky factorizations sIs.
Definition: FSABAlgorithm.h:74
boost::shared_ptr< LINALG > _LA
Linear algebra object.
Definition: RCArticulatedBody.h:139
void calc_fwd_dyn()
Computes the joint accelerations (forward dynamics) for an articulated body.
Definition: FSABAlgorithm.cpp:1034
A spatial (six dimensional) momentum.
Definition: SMomentum.h:12
void solve_generalized_inertia_noprecalc(SHAREDVECTORN &v)
Solves the equation Mx = b, where M is the generalized inertia matrix.
Definition: FSABAlgorithm.cpp:74
std::vector< std::vector< SMOMENTUM > > _Is
The expressions I*s.
Definition: FSABAlgorithm.h:71
std::vector< SFORCE > _Z
The articulated body spatial zero accelerations.
Definition: FSABAlgorithm.h:62
A generic, possibly non-square matrix.
Definition: MatrixN.h:18
std::vector< SPATIAL_AB_INERTIA > _I
The articulated body inertias.
Definition: FSABAlgorithm.h:59
virtual void apply_impulse(const SMOMENTUM &w, boost::shared_ptr< RIGIDBODY > link)
Abstract method for applying an impulse to this articulated body.
A generic, possibly non-square matrix using shared data.
Definition: SharedMatrixN.h:59
std::vector< SACCEL > _c
The spatial coriolis vectors.
Definition: FSABAlgorithm.h:68
Defines an articulated body for use with reduced-coordinate dynamics algorithms.
Definition: RCArticulatedBody.h:29
A generic N-dimensional floating point vector.
Definition: SharedVectorN.h:15
std::vector< SACCEL > _a
The spatial accelerations.
Definition: FSABAlgorithm.h:56
Implements Featherstone's algorithm for forward dynamics.
Definition: FSABAlgorithm.h:35
A generic N-dimensional floating point vector.
Definition: VectorN.h:16
std::vector< unsigned > _processed
Vector for processing links.
Definition: ArticulatedBody.h:77
std::vector< MATRIXN > _usIs
SVDs of sIs.
Definition: FSABAlgorithm.h:77
std::vector< bool > _rank_deficient
Determines whether the equations for a joint are rank deficient.
Definition: FSABAlgorithm.h:81
std::vector< SVELOCITY > _dv
Vector of link velocity updates.
Definition: FSABAlgorithm.h:65
boost::weak_ptr< RC_ARTICULATED_BODY > _body
The body that this algorithm operates on.
Definition: FSABAlgorithm.h:53
void apply_generalized_impulse(const VECTORN &gj)
Applies a generalized impulse using the algorithm of Drumwright.
Definition: FSABAlgorithm.cpp:376
std::vector< VECTORN > _mu
The temporary expression Q - I*s'*c - s'*Z.
Definition: FSABAlgorithm.h:84
void calc_inverse_generalized_inertia_noprecalc(MATRIXN &iM)
Calculates the inverse generalized inertia matrix.
Definition: FSABAlgorithm.cpp:100