Cheetah Software  1.0
DesiredStateCommand< T > Class Template Reference

#include <DesiredStateCommand.h>

+ Inheritance diagram for DesiredStateCommand< T >:
+ Collaboration diagram for DesiredStateCommand< T >:

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW DesiredStateCommand (GamepadCommand *command, StateEstimate< T > *sEstimate)
 
void convertToStateCommands ()
 
void desiredStateTrajectory (int N, Vec10< T > dtVec)
 
void printRawInfo ()
 
void printStateCommandInfo ()
 
float deadband (float command, T minVal, T maxVal)
 

Public Attributes

maxRoll = 0.4
 
minRoll = -0.4
 
maxPitch = 0.4
 
minPitch = -0.4
 
maxVelX = 1.0
 
minVelX = -1.0
 
maxVelY = 0.5
 
minVelY = -0.5
 
maxTurnRate = 2.0
 
minTurnRate = -2.0
 
DesiredStateData< T > data
 

Private Attributes

GamepadCommandgamepadCommand
 
StateEstimate< T > * stateEstimate
 
Mat12< T > A
 
dt = 0.001
 
deadbandRegion = 0.075
 
int printNum = 5
 
int printIter = 0
 

Detailed Description

template<typename T>
class DesiredStateCommand< T >

Definition at line 35 of file DesiredStateCommand.h.

Constructor & Destructor Documentation

template<typename T>
EIGEN_MAKE_ALIGNED_OPERATOR_NEW DesiredStateCommand< T >::DesiredStateCommand ( GamepadCommand command,
StateEstimate< T > *  sEstimate 
)
inline

Definition at line 39 of file DesiredStateCommand.h.

39  {
40  gamepadCommand = command;
41  stateEstimate = sEstimate;
42  }
GamepadCommand * gamepadCommand
StateEstimate< T > * stateEstimate

Member Function Documentation

template<typename T >
void DesiredStateCommand< T >::convertToStateCommands ( )

Definition at line 26 of file DesiredStateCommand.cpp.

References deadband().

26  {
27  data.zero();
28 
29  // Forward linear velocity
30  data.stateDes(6) =
32 
33  // Lateral linear velocity
34  data.stateDes(7) =
36 
37  // VErtical linear velocity
38  data.stateDes(8) = 0.0;
39 
40  // X position
41  data.stateDes(0) = stateEstimate->position(0) + dt * data.stateDes(6);
42 
43  // Y position
44  data.stateDes(1) = stateEstimate->position(1) + dt * data.stateDes(7);
45 
46  // Z position height
47  data.stateDes(2) = 0.45;
48 
49  // Roll rate
50  data.stateDes(9) = 0.0;
51 
52  // Pitch rate
53  data.stateDes(10) = 0.0;
54 
55  // Yaw turn rate
56  data.stateDes(11) =
58 
59  // Roll
60  data.stateDes(3) = 0.0;
61 
62  // Pitch
63  data.stateDes(4) =
65 
66  // Yaw
67  data.stateDes(5) = stateEstimate->rpy(2) + dt * data.stateDes(11);
68 }
Vec2< float > rightStickAnalog
Vec2< float > leftStickAnalog
GamepadCommand * gamepadCommand
StateEstimate< T > * stateEstimate
float deadband(float command, T minVal, T maxVal)
DesiredStateData< T > data

+ Here is the call graph for this function:

template<typename T>
float DesiredStateCommand< T >::deadband ( float  command,
minVal,
maxVal 
)

Definition at line 110 of file DesiredStateCommand.cpp.

110  {
111  if (command < deadbandRegion && command > -deadbandRegion) {
112  return 0.0;
113  } else {
114  return (command / (2)) * (maxVal - minVal);
115  }
116 }
template<typename T>
void DesiredStateCommand< T >::desiredStateTrajectory ( int  N,
Vec10< T >  dtVec 
)

Definition at line 74 of file DesiredStateCommand.cpp.

74  {
75  A = Mat12<T>::Zero();
76  A(0, 0) = 1;
77  A(1, 1) = 1;
78  A(2, 2) = 1;
79  A(3, 3) = 1;
80  A(4, 4) = 1;
81  A(5, 5) = 1;
82  A(6, 6) = 1;
83  A(7, 7) = 1;
84  A(8, 8) = 1;
85  A(9, 9) = 1;
86  A(10, 10) = 1;
87  A(11, 11) = 1;
88  data.stateTrajDes.col(0) = data.stateDes;
89 
90  for (int k = 1; k < N; k++) {
91  A(0, 6) = dtVec(k - 1);
92  A(1, 7) = dtVec(k - 1);
93  A(2, 8) = dtVec(k - 1);
94  A(3, 9) = dtVec(k - 1);
95  A(4, 10) = dtVec(k - 1);
96  A(5, 11) = dtVec(k - 1);
97  data.stateTrajDes.col(k) = A * data.stateTrajDes.col(k - 1);
98  for (int i = 0; i < 12; i++) {
99  // std::cout << data.stateTrajDes(i, k) << " ";
100  }
101  // std::cout << std::endl;
102  }
103  // std::cout << std::endl;
104 }
typename Eigen::Matrix< T, 12, 12 > Mat12
Definition: cppTypes.h:74
DesiredStateData< T > data
template<typename T >
void DesiredStateCommand< T >::printRawInfo ( )

Definition at line 122 of file DesiredStateCommand.cpp.

122  {
123  // Increment printing iteration
124  printIter++;
125 
126  // Print at requested frequency
127  if (printIter == printNum) {
128  std::cout << "[DESIRED STATE COMMAND] Printing Raw Gamepad Info...\n";
129  std::cout << "---------------------------------------------------------\n";
130  std::cout << "Button Start: " << gamepadCommand->start
131  << " | Back: " << gamepadCommand->back << "\n";
132  std::cout << "Button A: " << gamepadCommand->a
133  << " | B: " << gamepadCommand->b << " | X: " << gamepadCommand->x
134  << " | Y: " << gamepadCommand->y << "\n";
135  std::cout << "Left Stick Button: " << gamepadCommand->leftStickButton
136  << " | X: " << gamepadCommand->leftStickAnalog[0]
137  << " | Y: " << gamepadCommand->leftStickAnalog[1] << "\n";
138  std::cout << "Right Analog Button: " << gamepadCommand->rightStickButton
139  << " | X: " << gamepadCommand->rightStickAnalog[0]
140  << " | Y: " << gamepadCommand->rightStickAnalog[1] << "\n";
141  std::cout << "Left Bumper: " << gamepadCommand->leftBumper
142  << " | Trigger Switch: " << gamepadCommand->leftTriggerButton
143  << " | Trigger Value: " << gamepadCommand->leftTriggerAnalog
144  << "\n";
145  std::cout << "Right Bumper: " << gamepadCommand->rightBumper
146  << " | Trigger Switch: " << gamepadCommand->rightTriggerButton
147  << " | Trigger Value: " << gamepadCommand->rightTriggerAnalog
148  << "\n\n";
149  std::cout << std::endl;
150 
151  // Reset iteration counter
152  printIter = 0;
153  }
154 }
Vec2< float > rightStickAnalog
Vec2< float > leftStickAnalog
float rightTriggerAnalog
GamepadCommand * gamepadCommand
float leftTriggerAnalog
template<typename T >
void DesiredStateCommand< T >::printStateCommandInfo ( )

Definition at line 160 of file DesiredStateCommand.cpp.

160  {
161  // Increment printing iteration
162  printIter++;
163 
164  // Print at requested frequency
165  if (printIter == printNum) {
166  std::cout << "[DESIRED STATE COMMAND] Printing State Command Info...\n";
167  std::cout << "---------------------------------------------------------\n";
168  std::cout << "Position X: " << data.stateDes(0)
169  << " | Y: " << data.stateDes(1) << " | Z: " << data.stateDes(2)
170  << "\n";
171  std::cout << "Orientation Roll: " << data.stateDes(3)
172  << " | Pitch: " << data.stateDes(4)
173  << " | Yaw: " << data.stateDes(5) << "\n";
174  std::cout << "Velocity X: " << data.stateDes(6)
175  << " | Y: " << data.stateDes(7) << " | Z: " << data.stateDes(8)
176  << "\n";
177  std::cout << "Angular Velocity X: " << data.stateDes(9)
178  << " | Y: " << data.stateDes(10) << " | Z: " << data.stateDes(11)
179  << "\n";
180  std::cout << std::endl;
181  std::cout << std::endl;
182 
183  // Reset iteration counter
184  printIter = 0;
185  }
186 }
DesiredStateData< T > data

Member Data Documentation

template<typename T>
Mat12<T> DesiredStateCommand< T >::A
private

Definition at line 70 of file DesiredStateCommand.h.

template<typename T>
DesiredStateData<T> DesiredStateCommand< T >::data

Definition at line 63 of file DesiredStateCommand.h.

template<typename T>
T DesiredStateCommand< T >::deadbandRegion = 0.075
private

Definition at line 76 of file DesiredStateCommand.h.

template<typename T>
T DesiredStateCommand< T >::dt = 0.001
private

Definition at line 73 of file DesiredStateCommand.h.

template<typename T>
GamepadCommand* DesiredStateCommand< T >::gamepadCommand
private

Definition at line 66 of file DesiredStateCommand.h.

template<typename T>
T DesiredStateCommand< T >::maxPitch = 0.4

Definition at line 53 of file DesiredStateCommand.h.

template<typename T>
T DesiredStateCommand< T >::maxRoll = 0.4

Definition at line 51 of file DesiredStateCommand.h.

template<typename T>
T DesiredStateCommand< T >::maxTurnRate = 2.0

Definition at line 59 of file DesiredStateCommand.h.

template<typename T>
T DesiredStateCommand< T >::maxVelX = 1.0

Definition at line 55 of file DesiredStateCommand.h.

template<typename T>
T DesiredStateCommand< T >::maxVelY = 0.5

Definition at line 57 of file DesiredStateCommand.h.

template<typename T>
T DesiredStateCommand< T >::minPitch = -0.4

Definition at line 54 of file DesiredStateCommand.h.

template<typename T>
T DesiredStateCommand< T >::minRoll = -0.4

Definition at line 52 of file DesiredStateCommand.h.

template<typename T>
T DesiredStateCommand< T >::minTurnRate = -2.0

Definition at line 60 of file DesiredStateCommand.h.

template<typename T>
T DesiredStateCommand< T >::minVelX = -1.0

Definition at line 56 of file DesiredStateCommand.h.

template<typename T>
T DesiredStateCommand< T >::minVelY = -0.5

Definition at line 58 of file DesiredStateCommand.h.

template<typename T>
int DesiredStateCommand< T >::printIter = 0
private

Definition at line 82 of file DesiredStateCommand.h.

template<typename T>
int DesiredStateCommand< T >::printNum = 5
private

Definition at line 79 of file DesiredStateCommand.h.

template<typename T>
StateEstimate<T>* DesiredStateCommand< T >::stateEstimate
private

Definition at line 67 of file DesiredStateCommand.h.


The documentation for this class was generated from the following files: