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
00026
00034 #include <acado_integrators.hpp>
00035 #include <acado_gnuplot.hpp>
00036
00037
00038 int main( ){
00039
00040 USING_NAMESPACE_ACADO;
00041
00042
00043 double h_hw = 10;
00044 double A_hw = 1.0;
00045 double T_hw = 5.0;
00046 double rho = 1000;
00047 double A = 1.0;
00048 double m = 100;
00049 double g = 9.81;
00050
00051
00052 double a = 1.0;
00053
00054
00055 DifferentialState h;
00056 DifferentialState v;
00057 DifferentialState w;
00058 TIME t;
00059
00060
00061 DifferentialEquation f;
00062
00063
00064 IntermediateState hw;
00065 hw = h_hw + A_hw*sin(2*M_PI*t/T_hw);
00066 f << dot(h) == v;
00067 f << dot(v) == rho*A*(hw-h)/m - g - a*v;
00068 f << dot(w) == a*v*v;
00069
00070
00071
00072 IntegratorRK45 integrator( f );
00073
00074
00075
00076 double x_start[3];
00077 x_start[0] = h_hw - 2*A_hw;
00078 x_start[1] = 0;
00079 x_start[2] = 0;
00080
00081 Grid timeInterval( 0.0, 25.0, 200 );
00082
00083 integrator.set( INTEGRATOR_PRINTLEVEL, MEDIUM );
00084 integrator.integrate( timeInterval, x_start );
00085
00086 VariablesGrid differentialStates;
00087 VariablesGrid intermediateStates;
00088
00089 integrator.getX ( differentialStates );
00090 integrator.getI ( intermediateStates );
00091
00092 GnuplotWindow window;
00093 window.addSubplot( differentialStates(0) );
00094 window.addSubplot( differentialStates(1) );
00095 window.addSubplot( differentialStates(2) );
00096
00097 window.plot();
00098
00099 return 0;
00100 }
00101
00102
00103