Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00031 #include <acado_code_generation.hpp>
00032
00033 int main( )
00034 {
00035 USING_NAMESPACE_ACADO
00036
00037
00038 DifferentialState p ;
00039 DifferentialState v ;
00040 DifferentialState phi ;
00041 DifferentialState omega;
00042 Control a ;
00043
00044 const double g = 9.81;
00045 const double b = 0.20;
00046
00047
00048 DifferentialEquation f;
00049
00050 f << dot( p ) == v;
00051 f << dot( v ) == a;
00052 f << dot( phi ) == omega;
00053 f << dot( omega ) == -g * sin(phi) - a * cos(phi) - b * omega;
00054
00055
00056 Function h, hN;
00057 h << p << v << phi << omega << a;
00058 hN << p << v << phi << omega;
00059
00060 BMatrix W = eye<bool>( h.getDim() );
00061 BMatrix WN = eye<bool>( hN.getDim() );
00062
00063
00064
00065
00066 OCP ocp(0.0, 3.0, 10);
00067
00068 ocp.subjectTo( f );
00069
00070 ocp.minimizeLSQ(W, h);
00071 ocp.minimizeLSQEndTerm(WN, hN);
00072
00073 ocp.subjectTo( -1.0 <= a <= 1.0 );
00074 ocp.subjectTo( -0.5 <= v <= 1.5 );
00075
00076
00077 OCPexport mpc( ocp );
00078
00079 mpc.set( HESSIAN_APPROXIMATION, GAUSS_NEWTON );
00080 mpc.set( DISCRETIZATION_TYPE, MULTIPLE_SHOOTING );
00081 mpc.set( INTEGRATOR_TYPE, INT_RK4 );
00082 mpc.set( NUM_INTEGRATOR_STEPS, 30 );
00083
00084 mpc.set( SPARSE_QP_SOLUTION, CONDENSING );
00085 mpc.set( QP_SOLVER, QP_QPOASES );
00086
00087
00088
00089
00090 mpc.set( HOTSTART_QP, YES );
00091 mpc.set( GENERATE_TEST_FILE, NO);
00092 mpc.set( GENERATE_MAKE_FILE, NO );
00093 mpc.set( GENERATE_MATLAB_INTERFACE, NO );
00094 mpc.set( GENERATE_SIMULINK_INTERFACE, YES );
00095
00096
00097 mpc.set( CG_MODULE_NAME, "nmpc" );
00098
00099 if (mpc.exportCode( "crane_cl_nmpc_export" ) != SUCCESSFUL_RETURN)
00100 exit( EXIT_FAILURE );
00101
00102 mpc.printDimensionsQP( );
00103
00104 return EXIT_SUCCESS;
00105 }