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 
66 class DynamicModel {
67 public:
68  using Ptr = std::shared_ptr<DynamicModel>;
69  using Vector3d = Eigen::Vector3d;
70  using Matrix3d = Eigen::Matrix3d;
71  using ComPos = Eigen::Vector3d;
72  using AngVel = Eigen::Vector3d;
73  using BaseAcc = Eigen::Matrix<double,6,1>;
74  using Jac = Eigen::SparseMatrix<double, Eigen::RowMajor>;
75  using EEPos = std::vector<Eigen::Vector3d>;
76  using EELoad = EEPos;
77  using EE = uint;
78 
89  void SetCurrent(const ComPos& com_W, const Vector3d com_acc_W,
90  const Matrix3d& w_R_b, const AngVel& omega_W, const Vector3d& omega_dot_W,
91  const EELoad& force_W, const EEPos& pos_W);
92 
97  virtual BaseAcc GetDynamicViolation() const = 0;
98 
107  virtual Jac GetJacobianWrtBaseLin(const Jac& jac_base_lin_pos,
108  const Jac& jac_base_lin_acc) const = 0;
109 
118  virtual Jac GetJacobianWrtBaseAng(const EulerConverter& base_angular,
119  double t) const = 0;
120 
129  virtual Jac GetJacobianWrtForce(const Jac& ee_force, EE ee) const = 0;
130 
139  virtual Jac GetJacobianWrtEEPos(const Jac& ee_pos, EE ee) const = 0;
140 
144  double g() const { return g_; };
145 
149  double m() const { return m_; };
150 
154  int GetEECount() const { return ee_pos_.size(); };
155 
156 protected:
157  ComPos com_pos_;
159 
163 
166 
171  DynamicModel(double mass, int ee_count);
172  virtual ~DynamicModel () = default;
173 
174 private:
175  double g_;
176  double m_;
177 };
178 
179 } /* namespace towr */
180 
181 #endif /* TOWR_MODELS_DYNAMIC_MODEL_H_ */
double m() const
Vector3d com_acc_
x-y-z acceleration of the Center-of-Mass.
Eigen::Vector3d AngVel
Definition: dynamic_model.h:72
int GetEECount() const
the number of endeffectors that this robot has.
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:75
Eigen::Matrix3d Matrix3d
Definition: dynamic_model.h:70
Eigen::Matrix< double, 6, 1 > BaseAcc
Definition: dynamic_model.h:73
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:69
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:66
std::shared_ptr< DynamicModel > Ptr
Definition: dynamic_model.h:68
Eigen::Vector3d ComPos
Definition: dynamic_model.h:71
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.
Eigen::SparseMatrix< double, Eigen::RowMajor > Jac
Definition: dynamic_model.h:74
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 g() const


towr
Author(s): Alexander W. Winkler
autogenerated on Mon Feb 28 2022 23:54:22