dynamic_model.h
Go to the documentation of this file.
1 /******************************************************************************
2 Copyright (c) 2018, Alexander W. Winkler. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6 
7 * Redistributions of source code must retain the above copyright notice, this
8  list of conditions and the following disclaimer.
9 
10 * Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 * Neither the name of the copyright holder nor the names of its
15  contributors may be used to endorse or promote products derived from
16  this software without specific prior written permission.
17 
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 ******************************************************************************/
29 
30 #ifndef TOWR_MODELS_DYNAMIC_MODEL_H_
31 #define TOWR_MODELS_DYNAMIC_MODEL_H_
32 
33 #include <memory>
34 #include <vector>
35 
36 #include <Eigen/Dense>
37 #include <Eigen/Sparse>
38 
40 
41 namespace towr {
42 
58 class DynamicModel {
59 public:
60  using Ptr = std::shared_ptr<DynamicModel>;
61  using Vector3d = Eigen::Vector3d;
62  using Matrix3d = Eigen::Matrix3d;
63  using ComPos = Eigen::Vector3d;
64  using AngVel = Eigen::Vector3d;
65  using BaseAcc = Eigen::Matrix<double,6,1>;
66  using Jac = Eigen::SparseMatrix<double, Eigen::RowMajor>;
67  using EEPos = std::vector<Eigen::Vector3d>;
68  using EELoad = EEPos;
69  using EE = uint;
70 
81  void SetCurrent(const ComPos& com_W, const Vector3d com_acc_W,
82  const Matrix3d& w_R_b, const AngVel& omega_W, const Vector3d& omega_dot_W,
83  const EELoad& force_W, const EEPos& pos_W);
84 
89  virtual BaseAcc GetDynamicViolation() const = 0;
90 
99  virtual Jac GetJacobianWrtBaseLin(const Jac& jac_base_lin_pos,
100  const Jac& jac_base_lin_acc) const = 0;
101 
110  virtual Jac GetJacobianWrtBaseAng(const EulerConverter& base_angular,
111  double t) const = 0;
112 
121  virtual Jac GetJacobianWrtForce(const Jac& ee_force, EE ee) const = 0;
122 
131  virtual Jac GetJacobianWrtEEPos(const Jac& ee_pos, EE ee) const = 0;
132 
136  double g() const { return g_; };
137 
141  double m() const { return m_; };
142 
146  int GetEECount() const { return ee_pos_.size(); };
147 
148 protected:
149  ComPos com_pos_;
151 
155 
158 
163  DynamicModel(double mass, int ee_count);
164  virtual ~DynamicModel () = default;
165 
166 private:
167  double g_;
168  double m_;
169 };
170 
171 } /* namespace towr */
172 
173 #endif /* TOWR_MODELS_DYNAMIC_MODEL_H_ */
Vector3d com_acc_
x-y-z acceleration of the Center-of-Mass.
Eigen::Vector3d AngVel
Definition: dynamic_model.h:64
virtual Jac GetJacobianWrtEEPos(const Jac &ee_pos, EE ee) const =0
How the endeffector positions affect the dynamic violation.
Matrix3d w_R_b_
rotation matrix from base (b) to world (w) frame.
std::vector< Eigen::Vector3d > EEPos
Definition: dynamic_model.h:67
Eigen::Matrix3d Matrix3d
Definition: dynamic_model.h:62
Eigen::Matrix< double, 6, 1 > BaseAcc
Definition: dynamic_model.h:65
double g() const
Vector3d omega_dot_
angular acceleration expressed in world frame.
ComPos com_pos_
x-y-z position of the Center-of-Mass.
Eigen::Vector3d Vector3d
Definition: dynamic_model.h:61
AngVel omega_
angular velocity expressed in world frame.
Converts Euler angles and derivatives to angular quantities.
A interface for the the system dynamics of a legged robot.
Definition: dynamic_model.h:58
std::shared_ptr< DynamicModel > Ptr
Definition: dynamic_model.h:60
Eigen::Vector3d ComPos
Definition: dynamic_model.h:63
void SetCurrent(const ComPos &com_W, const Vector3d com_acc_W, const Matrix3d &w_R_b, const AngVel &omega_W, const Vector3d &omega_dot_W, const EELoad &force_W, const EEPos &pos_W)
Sets the current state and input of the system.
EELoad ee_force_
The endeffector force expressed in world frame.
EEPos ee_pos_
The x-y-z position of each endeffector.
DynamicModel(double mass, int ee_count)
Construct a dynamic object. Protected as this is abstract base class.
double g_
gravity acceleration [m/s^2]
virtual Jac GetJacobianWrtBaseAng(const EulerConverter &base_angular, double t) const =0
How the base orientation affects the dynamic violation.
virtual ~DynamicModel()=default
virtual Jac GetJacobianWrtBaseLin(const Jac &jac_base_lin_pos, const Jac &jac_base_lin_acc) const =0
How the base position affects the dynamic violation.
int GetEECount() const
the number of endeffectors that this robot has.
Eigen::SparseMatrix< double, Eigen::RowMajor > Jac
Definition: dynamic_model.h:66
virtual BaseAcc GetDynamicViolation() const =0
The violation of the system dynamics incurred by the current values.
double m_
mass of the robot
virtual Jac GetJacobianWrtForce(const Jac &ee_force, EE ee) const =0
How the endeffector forces affect the dynamic violation.
double m() const


towr_core
Author(s): Alexander W. Winkler
autogenerated on Sat Apr 7 2018 02:15:57