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 phi;
00040 DifferentialState theta;
00041 DifferentialState dphi;
00042 DifferentialState dtheta;
00043
00044 Control u1;
00045 Control u2;
00046
00047 IntermediateState c;
00048 DifferentialEquation f;
00049
00050
00051 const double R = 1.00;
00052 const double Omega = 1.00;
00053 const double m = 0.80;
00054 const double r = 1.00;
00055 const double A = 0.15;
00056
00057 const double rho = 1.20;
00058 const double CL = 1.00;
00059 const double CD = 0.15;
00060 const double b = 15.00;
00061 const double g = 9.81;
00062
00063
00064
00065 c = ( (R*R*Omega*Omega)
00066 + (r*r)*( (Omega+dphi)*(Omega+dphi) + dtheta*dtheta )
00067 + (2.0*r*R*Omega)*( (Omega+dphi)*sin(theta)*cos(phi)
00068 + dtheta*cos(theta)*sin(phi) ) ) * ( A*rho/( 2.0*m ) );
00069
00070 f << dot( phi ) == dphi;
00071 f << dot( theta ) == dtheta;
00072
00073 f << dot( dphi ) == ( 2.0*r*(Omega+dphi)*dtheta*cos(theta)
00074 + (R*Omega*Omega)*sin(phi)
00075 + c*(CD*(1.0+u2)+CL*(1.0+0.5*u2)*phi) ) / (-r*sin(theta));
00076
00077 f << dot( dtheta ) == ( (R*Omega*Omega)*cos(theta)*cos(phi)
00078 + r*(Omega+dphi)*sin(theta)*cos(theta)
00079 + g*sin(theta) - c*( CL*u1 + b*dtheta ) ) / r;
00080
00081
00082 Function h, hN;
00083 h << phi << theta << dphi << dtheta << u1 << u2;
00084 hN << phi << theta << dphi << dtheta;
00085
00086 DMatrix W = eye<double>( h.getDim() );
00087 DMatrix WN = eye<double>( hN.getDim() );
00088
00089 W(0,0) = 5.000;
00090 W(1,1) = 1.000;
00091 W(2,2) = 10.000;
00092 W(3,3) = 10.000;
00093 W(4,4) = 0.1;
00094 W(5,5) = 0.1;
00095
00096 WN(0,0) = 1.0584373059248833e+01;
00097 WN(0,1) = 1.2682415889087276e-01;
00098 WN(0,2) = 1.2922232012424681e+00;
00099 WN(0,3) = 3.7982078044271374e-02;
00100 WN(1,0) = 1.2682415889087265e-01;
00101 WN(1,1) = 3.2598407653299275e+00;
00102 WN(1,2) = -1.1779732282636639e-01;
00103 WN(1,3) = 9.8830655348904548e-02;
00104 WN(2,0) = 1.2922232012424684e+00;
00105 WN(2,1) = -1.1779732282636640e-01;
00106 WN(2,2) = 4.3662024133354898e+00;
00107 WN(2,3) = -5.9269992411260908e-02;
00108 WN(3,0) = 3.7982078044271367e-02;
00109 WN(3,1) = 9.8830655348904534e-02;
00110 WN(3,2) = -5.9269992411260901e-02;
00111 WN(3,3) = 3.6495564367004318e-01;
00112
00113
00114
00115
00116
00117
00118 OCP ocp( 0.0, 2.0 * M_PI, 10 );
00119
00120 ocp.subjectTo( f );
00121
00122 ocp.minimizeLSQ(W, h);
00123 ocp.minimizeLSQEndTerm(WN, hN);
00124
00125 ocp.subjectTo( 18.0 <= u1 <= 22.0 );
00126 ocp.subjectTo( -0.2 <= u2 <= 0.2 );
00127
00128
00129 OCPexport mpc(ocp);
00130
00131 mpc.set( INTEGRATOR_TYPE , INT_RK4 );
00132 mpc.set( NUM_INTEGRATOR_STEPS , 30 );
00133 mpc.set( HESSIAN_APPROXIMATION, GAUSS_NEWTON );
00134 mpc.set( HOTSTART_QP, YES );
00135 mpc.set( GENERATE_TEST_FILE, NO );
00136
00137 if (mpc.exportCode("kite_carousel_export") != SUCCESSFUL_RETURN)
00138 exit( EXIT_FAILURE );
00139
00140 mpc.printDimensionsQP( );
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 return EXIT_SUCCESS;
00174 }
00175
00176