A sparse MPC solver for walking motion generation (old version).
|
00001 00007 #include "WMG.h" 00008 00009 00016 IPM::IPM (const double sampling_time) 00017 { 00018 A = new double[9]; 00019 B = new double[3]; 00020 00021 A[0] = A[4] = A[8] = 1; 00022 A[1] = A[2] = A[5] = 0; 00023 A[3] = A[7] = sampling_time; 00024 A[6] = sampling_time * sampling_time/2; 00025 00026 B[0] = sampling_time * sampling_time * sampling_time / 6; 00027 B[1] = sampling_time * sampling_time/2; 00028 B[2] = sampling_time; 00029 } 00030 00031 00032 00036 IPM::~IPM() 00037 { 00038 if (A != NULL) 00039 { 00040 delete A; 00041 } 00042 if (B != NULL) 00043 { 00044 delete B; 00045 } 00046 } 00047 00048 00049 00056 void IPM::calculateNextState (smpc::control &control, smpc::state_orig &state) 00057 { 00058 state.x() = state.x() * A[0] 00059 + state.vx() * A[3] 00060 + state.ax() * A[6] 00061 + control.jx() * B[0]; 00062 00063 state.vx() = state.vx() * A[4] 00064 + state.ax() * A[7] 00065 + control.jx() * B[1]; 00066 00067 state.ax() = state.ax() * A[8] 00068 + control.jx() * B[2]; 00069 00070 00071 state.y() = state.y() * A[0] 00072 + state.vy() * A[3] 00073 + state.ay() * A[6] 00074 + control.jy() * B[0]; 00075 00076 state.vy() = state.vy() * A[4] 00077 + state.ay() * A[7] 00078 + control.jy() * B[1]; 00079 00080 state.ay() = state.ay() * A[8] 00081 + control.jy() * B[2]; 00082 } 00083