getting_started_classical.cpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  */
00025 
00026 
00027 
00035 #include <acado_toolkit.hpp>
00036 #include <acado_gnuplot.hpp>
00037 
00038 
00039 int main( )
00040 {
00041     USING_NAMESPACE_ACADO
00042 
00043 
00044     // SETTING UP THE FEEDBACK CONTROLLER:
00045     // -----------------------------------
00046         PIDcontroller pid( 4,1,0.01 );
00047 
00048         DVector pWeights( 4 );
00049         pWeights(0) = 1000.0;
00050         pWeights(1) = -1000.0;
00051         pWeights(2) = 1000.0;
00052         pWeights(3) = -1000.0;
00053 
00054         DVector dWeights( 4 );
00055         dWeights(0) = 0.0;
00056         dWeights(1) = 0.0;
00057         dWeights(2) = 20.0;
00058         dWeights(3) = -20.0;
00059 
00060         pid.setProportionalWeights( pWeights );
00061         pid.setDerivativeWeights( dWeights );
00062 
00063         pid.setControlLowerLimit( 0,-200.0 );
00064         pid.setControlUpperLimit( 0, 200.0 );
00065 
00066 
00067 //      DMatrix K( 1,4 );
00068 //      K(0,0) = -3.349222044080232e+04;
00069 //      K(0,1) = -3.806600292165519e+03;
00070 //      K(0,2) =  9.999999999999985e+02;
00071 //      K(0,3) = -1.040810121403324e+03;
00072 // 
00073 //      LinearStateFeedback lqr( K,0.025 );
00074 // 
00075 //      lqr.setControlLowerLimit( 0,-200.0 );
00076 //      lqr.setControlUpperLimit( 0, 200.0 );
00077 
00078 
00079         StaticReferenceTrajectory zeroReference;
00080 
00081         Controller controller( pid,zeroReference );
00082 //      Controller controller( lqr,zeroReference );
00083 
00084 
00085         // INITIALIZE CONTROLLER AND PERFORM A STEP:
00086         // -----------------------------------------
00087         DVector y( 4 );
00088         y.setZero( );
00089         y(0) = 0.01;
00090 
00091         controller.init( 0.0,y );
00092         controller.step( 0.0,y );
00093 
00094 
00095         DVector u;
00096         controller.getU( u );
00097         u.print( "Feedback control" );
00098 
00099     return 0;
00100 }
00101 
00102 
00103 


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:58:24