16 stateTrajDes = Eigen::Matrix<T, 12, 10>::Zero();
31 deadband(gamepadCommand->leftStickAnalog[1], minVelX, maxVelX);
35 deadband(gamepadCommand->leftStickAnalog[0], minVelY, maxVelY);
38 data.stateDes(8) = 0.0;
41 data.stateDes(0) = stateEstimate->position(0) + dt * data.stateDes(6);
44 data.stateDes(1) = stateEstimate->position(1) + dt * data.stateDes(7);
47 data.stateDes(2) = 0.45;
50 data.stateDes(9) = 0.0;
53 data.stateDes(10) = 0.0;
57 deadband(gamepadCommand->rightStickAnalog[0], minTurnRate, maxTurnRate);
60 data.stateDes(3) = 0.0;
64 deadband(gamepadCommand->rightStickAnalog[1], minPitch, maxPitch);
67 data.stateDes(5) = stateEstimate->rpy(2) + dt * data.stateDes(11);
88 data.stateTrajDes.col(0) = data.stateDes;
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++) {
109 template <
typename T>
111 if (command < deadbandRegion && command > -deadbandRegion) {
114 return (command / (2)) * (maxVal - minVal);
121 template <
typename T>
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
145 std::cout <<
"Right Bumper: " << gamepadCommand->rightBumper
146 <<
" | Trigger Switch: " << gamepadCommand->rightTriggerButton
147 <<
" | Trigger Value: " << gamepadCommand->rightTriggerAnalog
149 std::cout << std::endl;
159 template <
typename T>
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)
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)
177 std::cout <<
"Angular Velocity X: " << data.stateDes(9)
178 <<
" | Y: " << data.stateDes(10) <<
" | Z: " << data.stateDes(11)
180 std::cout << std::endl;
181 std::cout << std::endl;
typename Eigen::Matrix< T, 12, 12 > Mat12
void printStateCommandInfo()
Eigen::Matrix< T, 10, 1 > Vec10
Eigen::Matrix< T, 12, 1 > Vec12
float deadband(float command, T minVal, T maxVal)
void desiredStateTrajectory(int N, Vec10< T > dtVec)
void convertToStateCommands()