Cheetah Software  1.0
DesiredStateCommand.h
Go to the documentation of this file.
1 /*========================= Gamepad Control ==========================*/
5 #ifndef DESIRED_STATE_COMMAND_H
6 #define DESIRED_STATE_COMMAND_H
7 
9 #include <cppTypes.h>
10 #include <iostream>
12 
16 template <typename T>
18  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
20 
21  // Zero out all of the data
22  void zero();
23 
24  // Instantaneous desired state command
26 
27  // Desired future state trajectory (for up to 10 timestep MPC)
28  Eigen::Matrix<T, 12, 10> stateTrajDes;
29 };
30 
34 template <typename T>
36  public:
37  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
38  // Initialize with the GamepadCommand struct
40  gamepadCommand = command;
41  stateEstimate = sEstimate;
42  }
43 
44  void convertToStateCommands();
45  void desiredStateTrajectory(int N, Vec10<T> dtVec);
46  void printRawInfo();
47  void printStateCommandInfo();
48  float deadband(float command, T minVal, T maxVal);
49 
50  // These should come from the inferface
51  T maxRoll = 0.4;
52  T minRoll = -0.4;
53  T maxPitch = 0.4;
54  T minPitch = -0.4;
55  T maxVelX = 1.0;
56  T minVelX = -1.0;
57  T maxVelY = 0.5;
58  T minVelY = -0.5;
59  T maxTurnRate = 2.0;
60  T minTurnRate = -2.0;
61 
62  // Holds the instantaneous desired state and future desired state trajectory
64 
65  private:
68 
69  // Dynamics matrix for discrete time approximation
71 
72  // Control loop timestep change
73  T dt = 0.001;
74 
75  // Value cutoff for the analog stick deadband
76  T deadbandRegion = 0.075;
77 
78  // Choose how often to print info, every N iterations
79  int printNum = 5; // N*(0.001s) in simulation time
80 
81  // Track the number of iterations since last info print
82  int printIter = 0;
83 };
84 
85 #endif
typename Eigen::Matrix< T, 12, 12 > Mat12
Definition: cppTypes.h:74
EIGEN_MAKE_ALIGNED_OPERATOR_NEW DesiredStateData()
Eigen::Matrix< T, 12, 10 > stateTrajDes
T deadband(T x, T range)
Definition: utilities.h:46
GamepadCommand * gamepadCommand
Eigen::Matrix< T, 10, 1 > Vec10
Definition: cppTypes.h:38
EIGEN_MAKE_ALIGNED_OPERATOR_NEW DesiredStateCommand(GamepadCommand *command, StateEstimate< T > *sEstimate)
Eigen::Matrix< T, 12, 1 > Vec12
Definition: cppTypes.h:42
StateEstimate< T > * stateEstimate
The GamepadCommand type containing joystick information.
DesiredStateData< T > data