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
00032 #include <acado_code_generation.hpp>
00033
00034 int main( )
00035 {
00036 USING_NAMESPACE_ACADO
00037
00038
00039 DifferentialState p ;
00040 DifferentialState v ;
00041 DifferentialState phi ;
00042 DifferentialState omega;
00043 Control a ;
00044
00045 const double g = 9.81;
00046 const double b = 0.20;
00047
00048
00049 DifferentialEquation f;
00050
00051 f << dot( p ) == v;
00052 f << dot( v ) == a;
00053 f << dot( phi ) == omega;
00054 f << dot( omega ) == -g * sin(phi) - a * cos(phi) - b * omega;
00055
00056
00057 Function h, hN;
00058 h << p << v << phi << omega << a;
00059 hN << p << v << phi << omega;
00060
00061
00062 DMatrix W = eye<double>( h.getDim() );
00063 DMatrix WN = eye<double>( hN.getDim() );
00064 WN *= 5;
00065
00066
00067
00068
00069
00070
00071
00072
00073 OCP ocp(0.0, 3.0, 10);
00074
00075 ocp.subjectTo( f );
00076
00077 ocp.minimizeLSQ(W, h);
00078 ocp.minimizeLSQEndTerm(WN, hN);
00079
00080 ocp.subjectTo( -1.0 <= a <= 1.0 );
00081 ocp.subjectTo( -0.5 <= v <= 1.5 );
00082
00083
00084 OCPexport mpc( ocp );
00085
00086 mpc.set( HESSIAN_APPROXIMATION, GAUSS_NEWTON );
00087 mpc.set( DISCRETIZATION_TYPE, SINGLE_SHOOTING );
00088 mpc.set( INTEGRATOR_TYPE, INT_RK4 );
00089 mpc.set( NUM_INTEGRATOR_STEPS, 30 );
00090
00091 mpc.set( QP_SOLVER, QP_QPOASES );
00092
00093
00094 mpc.set( GENERATE_TEST_FILE, YES );
00095 mpc.set( GENERATE_MAKE_FILE, YES );
00096 mpc.set( GENERATE_MATLAB_INTERFACE, YES );
00097 mpc.set( GENERATE_SIMULINK_INTERFACE, YES );
00098
00099
00100
00101 if (mpc.exportCode( "getting_started_export" ) != SUCCESSFUL_RETURN)
00102 exit( EXIT_FAILURE );
00103
00104 mpc.printDimensionsQP( );
00105
00106 return EXIT_SUCCESS;
00107 }