Cheetah Software  1.0
GaitScheduler.h
Go to the documentation of this file.
1 #ifndef GAIT_SCHEDULER_H
2 #define GAIT_SCHEDULER_H
3 
4 #include <cppTypes.h>
5 #include <iostream>
6 #include "Dynamics/Quadruped.h"
7 
11 enum class GaitType {
12  STAND,
15  AMBLE,
16  TROT_WALK,
17  TROT,
18  TROT_RUN,
19  PACE,
20  BOUND,
23  PRONK,
24  THREE_FOOT,
25  CUSTOM,
27 };
28 
32 template <typename T>
33 struct GaitData {
34  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
35  GaitData() { zero(); }
36 
37  // Zero out all of the data
38  void zero();
39 
40  // The current GaitType
42 
43  // Next GaitType to transition into
45 
46  // Gait name string
47  std::string gaitName;
48 
49  // Gait descriptors
50  T periodTimeNominal; // overall period time to scale
51  T initialPhase; // initial phase to offset
52  T switchingPhaseNominal; // nominal phase to switch contacts
53 
54  // Enable flag for each foot
55  Eigen::Vector4i gaitEnabled; // enable gaint controlled legs
56 
57  // Time based descriptors
58  Vec4<T> periodTime; // overall foot scaled gait period time
59  Vec4<T> timeStance; // total stance time
60  Vec4<T> timeSwing; // total swing time
61  Vec4<T> timeStanceRemaining; // stance time remaining
62  Vec4<T> timeSwingRemaining; // swing time remaining
63 
64  // Phase based descriptors
65  Vec4<T> switchingPhase; // phase to switch to swing
66  Vec4<T> phaseVariable; // overall gait phase for each foot
67  Vec4<T> phaseOffset; // nominal gait phase offsets
68  Vec4<T> phaseScale; // phase scale relative to variable
69  Vec4<T> phaseStance; // stance subphase
70  Vec4<T> phaseSwing; // swing subphase
71 
72  // Scheduled contact states
73  Eigen::Vector4i contactStateScheduled; // contact state of the foot
74  Eigen::Vector4i contactStatePrev; // previous contact state of the foot
75  Eigen::Vector4i touchdownScheduled; // scheduled touchdown event flag
76  Eigen::Vector4i liftoffScheduled; // scheduled touchdown event flag
77 
78  // Position of the feet in the world frame at takeoff time
79  Mat34<T> posFootLiftoffWorld; // foot position when scheduled to lift off
80  Mat34<T> posFootTouchdownWorld; // foot position when scheduled to touchdown
81 };
82 
86 template <typename T>
88  public:
89  // Constructors for the GaitScheduler
90  GaitScheduler();
92 
93  // Initialize the Gait Scheduler
94  void initialize();
95 
96  // Iteration step for scheduler logic
97  void step();
98 
99  // Creates a new gait from predefined library
100  void createGait();
101 
102  // Prints the characteristic info and curret state
103  void printGaitInfo();
104 
105  // Struct containing all of the gait relevant data
107 
108  private:
109  // The quadruped model
110  // Quadruped<T>& _quadruped;
111 
112  // Control loop timestep change
113  T dt = 0.001;
114 
115  // Phase change at each step
117 
118  // Choose how often to print info, every N iterations
119  int printNum = 5; // N*(0.001s) in simulation time
120 
121  // Track the number of iterations since last info print
122  int printIter = 0;
123 };
124 
125 #endif
Vec4< T > timeStance
Definition: GaitScheduler.h:59
Eigen::Vector4i liftoffScheduled
Definition: GaitScheduler.h:76
Vec4< T > phaseSwing
Definition: GaitScheduler.h:70
Mat34< T > posFootLiftoffWorld
Definition: GaitScheduler.h:79
Vec4< T > phaseScale
Definition: GaitScheduler.h:68
Data structure containing parameters for quadruped robot.
GaitData< T > gaitData
EIGEN_MAKE_ALIGNED_OPERATOR_NEW GaitData()
Definition: GaitScheduler.h:35
GaitType
Definition: GaitScheduler.h:11
Eigen::Matrix< T, 3, 4 > Mat34
Definition: cppTypes.h:86
Vec4< T > phaseOffset
Definition: GaitScheduler.h:67
Eigen::Vector4i gaitEnabled
Definition: GaitScheduler.h:55
Mat34< T > posFootTouchdownWorld
Definition: GaitScheduler.h:80
Eigen::Vector4i touchdownScheduled
Definition: GaitScheduler.h:75
Vec4< T > timeSwingRemaining
Definition: GaitScheduler.h:62
Vec4< T > phaseStance
Definition: GaitScheduler.h:69
Vec4< T > timeSwing
Definition: GaitScheduler.h:60
Eigen::Vector4i contactStateScheduled
Definition: GaitScheduler.h:73
typename Eigen::Matrix< T, 4, 1 > Vec4
Definition: cppTypes.h:30
Vec4< T > timeStanceRemaining
Definition: GaitScheduler.h:61
GaitType _currentGait
Definition: GaitScheduler.h:41
T periodTimeNominal
Definition: GaitScheduler.h:50
std::string gaitName
Definition: GaitScheduler.h:47
Vec4< T > periodTime
Definition: GaitScheduler.h:58
GaitType _nextGait
Definition: GaitScheduler.h:44
Vec4< T > switchingPhase
Definition: GaitScheduler.h:65
T switchingPhaseNominal
Definition: GaitScheduler.h:52
Eigen::Vector4i contactStatePrev
Definition: GaitScheduler.h:74
Vec4< T > phaseVariable
Definition: GaitScheduler.h:66