Cheetah Software  1.0
Quadruped.h
Go to the documentation of this file.
1 
10 #ifndef LIBBIOMIMETICS_QUADRUPED_H
11 #define LIBBIOMIMETICS_QUADRUPED_H
12 
13 #include "Dynamics/ActuatorModel.h"
16 
17 #include <eigen3/Eigen/StdVector>
18 
19 #include <vector>
20 
21 namespace cheetah {
22 constexpr size_t num_act_joint = 12;
23 constexpr size_t num_q = 19;
24 constexpr size_t dim_config = 18;
25 constexpr size_t num_leg = 4;
26 constexpr size_t num_leg_joint = 3;
27 constexpr float servo_rate = 0.001;
28 } // namespace cheetah
29 
30 namespace linkID {
31 constexpr size_t FR = 9; // Front Right Foot
32 constexpr size_t FL = 11; // Front Left Foot
33 constexpr size_t HR = 13; // Hind Right Foot
34 constexpr size_t HL = 15; // Hind Left Foot
35 
36 constexpr size_t FR_abd = 2; // Front Right Abduction
37 constexpr size_t FL_abd = 0; // Front Left Abduction
38 constexpr size_t HR_abd = 3; // Hind Right Abduction
39 constexpr size_t HL_abd = 1; // Hind Left Abduction
40 } // namespace linkID
41 
42 using std::vector;
43 
55 template <typename T>
56 class Quadruped {
57  public:
58  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
60  T _bodyLength, _bodyWidth, _bodyHeight, _bodyMass;
61  T _abadGearRatio, _hipGearRatio, _kneeGearRatio;
62  T _abadLinkLength, _hipLinkLength, _kneeLinkLength, _maxLegLength;
63  T _motorKT, _motorR, _batteryV;
65  T _jointDamping, _jointDryFriction;
66  SpatialInertia<T> _abadInertia, _hipInertia, _kneeInertia, _abadRotorInertia,
67  _hipRotorInertia, _kneeRotorInertia, _bodyInertia;
68  Vec3<T> _abadLocation, _abadRotorLocation, _hipLocation, _hipRotorLocation,
69  _kneeLocation, _kneeRotorLocation;
70  FloatingBaseModel<T> buildModel();
71  bool buildModel(FloatingBaseModel<T>& model);
72  std::vector<ActuatorModel<T>> buildActuatorModels();
73 
74  static T getSideSign(int leg) {
75  const T sideSigns[4] = {-1, 1, -1, 1};
76  assert(leg >= 0 && leg < 4);
77  return sideSigns[leg];
78  }
79 
84  assert(leg >= 0 && leg < 4);
85  Vec3<T> pHip((leg == 0 || leg == 1) ? _abadLocation(0) : -_abadLocation(0),
86  (leg == 1 || leg == 3) ? _abadLocation(1) : -_abadLocation(1),
87  _abadLocation(2));
88  return pHip;
89  }
90 };
91 
92 template <typename T, typename T2>
93 Vec3<T> withLegSigns(const Eigen::MatrixBase<T2>& v, int legID);
94 
95 #endif // LIBBIOMIMETICS_QUADRUPED_H
constexpr size_t num_q
Definition: Quadruped.h:23
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
constexpr size_t num_act_joint
Definition: Quadruped.h:22
constexpr size_t num_leg_joint
Definition: Quadruped.h:26
Vec3< T > getHipLocation(int leg)
Definition: Quadruped.h:83
static T getSideSign(int leg)
Definition: Quadruped.h:74
T _kneeGearRatio
Definition: Quadruped.h:61
Class representing spatial inertia tensors.
Vec3< T > withLegSigns(const Eigen::MatrixBase< T2 > &v, int legID)
Definition: Quadruped.cpp:207
T _bodyWidth
Definition: Quadruped.h:60
constexpr float servo_rate
Definition: Quadruped.h:27
EIGEN_MAKE_ALIGNED_OPERATOR_NEW RobotType _robotType
Definition: Quadruped.h:59
Vec3< T > _kneeRotorLocation
Definition: Quadruped.h:68
constexpr size_t num_leg
Definition: Quadruped.h:25
RobotType
Definition: cppTypes.h:120
T _maxLegLength
Definition: Quadruped.h:62
T _jointDryFriction
Definition: Quadruped.h:65
Model of actuator Includes friction, max torque, and motor torque speed curve.
SpatialInertia< T > _kneeRotorInertia
Definition: Quadruped.h:66
Implementation of Rigid Body Floating Base model data structure.
T _motorTauMax
Definition: Quadruped.h:64
constexpr size_t dim_config
Definition: Quadruped.h:24