37 #include "acado_common.h" 38 #include "acado_auxiliary_functions.h" 64 memset(&acadoWorkspace, 0,
sizeof( acadoWorkspace ));
70 acado_initializeSolver();
76 for (i = 0; i <
N + 1; ++i)
90 for (i = 0; i <
N; ++i)
111 for (i = 0; i <
NX; ++i)
117 vector< vector< double > >
log;
120 for (i = 0; i <
log.size(); ++i)
121 log[ i ].resize(NX +
NXA +
NU + 5, 0.0);
127 acado_preparationStep();
132 for( iter = 0; iter <
NUM_STEPS; iter++ )
135 status = acado_feedbackStep( );
136 t2 = acado_toc( &t );
145 cout <<
"Iteration:" << iter <<
", QP problem! QP status: " << status << endl;
154 for(i = 0; i <
NX; i++)
156 for(j = 0; i < NX +
NXA; i++, j++)
158 for(j = 0; i < NX +
NXA +
NU; i++, j++)
161 log[ iter ][ i++ ] = t1;
162 log[ iter ][ i++ ] = t2;
163 log[ iter ][ i++ ] = acado_getObjective();
164 log[ iter ][ i++ ] = acado_getKKT();
165 log[ iter ][ i++ ] = acado_getNWSR();
168 cout <<
"Iteration #" << setw( 4 ) << iter
169 <<
", KKT value: " << scientific << acado_getKKT()
170 <<
", objective value: " << scientific << acado_getObjective()
180 for (i = 0; i <
NX; ++i)
184 acado_shiftStates(2, 0, 0);
185 acado_shiftControls( 0 );
188 acado_preparationStep();
189 t1 = acado_toc( &t );
199 cout <<
"Average feedback time: " << scientific << fdbSum / NUM_STEPS * 1e6 <<
" microseconds" << endl;
200 cout <<
"Average preparation time: " << scientific << prepSum / NUM_STEPS * 1e6 <<
" microseconds" << endl;
206 ofstream dataLog(
"./pendulum_dae_nmpc_test_sim_log.txt" );
207 if ( dataLog.is_open() )
209 for (i = 0; i <
log.size(); i++)
211 for (j = 0; j <
log[ i ].size(); j++)
212 dataLog <<
log[ i ][ j ] <<
" ";
220 cout <<
"Log file could not be opened" << endl;
228 cout <<
"Solver failed!" << endl;
IntermediateState sqrt(const Expression &arg)
ACADOvariables acadoVariables
ACADOworkspace acadoWorkspace
IntermediateState log(const Expression &arg)