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
00036 #include <acado_toolkit.hpp>
00037 #include <acado_gnuplot.hpp>
00038
00039
00040 int main( )
00041 {
00042 USING_NAMESPACE_ACADO
00043
00044
00045
00046
00047 DifferentialState xB;
00048 DifferentialState xW;
00049 DifferentialState vB;
00050 DifferentialState vW;
00051
00052 Control F;
00053
00054
00055
00056
00057
00058 double h = 0.05;
00059 DiscretizedDifferentialEquation f( h );
00060
00061
00062
00063
00064
00065
00066 f << next(xB) == ( 0.9335*xB + 0.0252*xW + 0.048860*vB + 0.000677*vW + 3.324e-06*F );
00067 f << next(xW) == ( 0.1764*xB - 0.9821*xW + 0.004739*vB - 0.002591*vW - 8.822e-06*F );
00068 f << next(vB) == ( -2.5210*xB - 0.1867*xW + 0.933500*vB + 0.025200*vW + 0.0001261*F );
00069 f << next(vW) == ( -1.3070*xB + 11.670*xW + 0.176400*vB - 0.982100*vW + 6.536e-05*F );
00070
00071 OutputFcn g;
00072 g << xB;
00073 g << 500.0*vB + F;
00074
00075 DynamicSystem dynSys( f,g );
00076
00077
00078
00079
00080 DVector mean( 1 ), amplitude( 1 );
00081 mean.setZero( );
00082 amplitude.setAll( 50.0 );
00083
00084 GaussianNoise myNoise( mean,amplitude );
00085
00086 Actuator myActuator( 1 );
00087
00088 myActuator.setControlNoise( myNoise,0.1 );
00089 myActuator.setControlDeadTimes( 0.1 );
00090
00091
00092 mean.setZero( );
00093 amplitude.setAll( 0.001 );
00094 UniformNoise myOutputNoise1( mean,amplitude );
00095
00096 mean.setAll( 20.0 );
00097 amplitude.setAll( 10.0 );
00098 GaussianNoise myOutputNoise2( mean,amplitude );
00099
00100 Sensor mySensor( 2 );
00101 mySensor.setOutputNoise( 0,myOutputNoise1,0.1 );
00102 mySensor.setOutputNoise( 1,myOutputNoise2,0.1 );
00103 mySensor.setOutputDeadTimes( 0.15 );
00104
00105
00106 Process myProcess;
00107
00108 myProcess.setDynamicSystem( dynSys );
00109 myProcess.set( ABSOLUTE_TOLERANCE,1.0e-8 );
00110
00111 myProcess.setActuator( myActuator );
00112 myProcess.setSensor( mySensor );
00113
00114 DVector x0( 4 );
00115 x0.setZero( );
00116 x0( 0 ) = 0.01;
00117
00118 myProcess.initializeStartValues( x0 );
00119
00120 myProcess.set( PLOT_RESOLUTION,HIGH );
00121
00122
00123 myProcess.set( OUTPUT_PLOTTING,PLOT_REAL );
00124
00125 GnuplotWindow window;
00126 window.addSubplot( xB, "Body Position [m]" );
00127 window.addSubplot( xW, "Wheel Position [m]" );
00128 window.addSubplot( vB, "Body Velocity [m/s]" );
00129 window.addSubplot( vW, "Wheel Velocity [m/s]" );
00130
00131 window.addSubplot( F,"Damping Force [N]" );
00132 window.addSubplot( g(0),"Output 1" );
00133 window.addSubplot( g(1),"Output 2" );
00134
00135 myProcess << window;
00136
00137
00138
00139
00140 VariablesGrid u( 1,0.0,1.0,6 );
00141
00142 u( 0,0 ) = 10.0;
00143 u( 1,0 ) = -200.0;
00144 u( 2,0 ) = 200.0;
00145 u( 3,0 ) = 200.0;
00146 u( 4,0 ) = 0.0;
00147 u( 5,0 ) = 0.0;
00148
00149 myProcess.init( 0.0,x0,u.getFirstVector() );
00150 myProcess.run( u );
00151
00152
00153 VariablesGrid uNom, uSim, ySim, ySens, xSim;
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 return 0;
00165 }
00166
00167
00168