controller/getting_started_classical.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
27 
35 #include <acado_toolkit.hpp>
36 #include <acado_gnuplot.hpp>
37 
38 
39 int main( )
40 {
42 
43 
44  // SETTING UP THE FEEDBACK CONTROLLER:
45  // -----------------------------------
46  PIDcontroller pid( 4,1,0.01 );
47 
48  DVector pWeights( 4 );
49  pWeights(0) = 1000.0;
50  pWeights(1) = -1000.0;
51  pWeights(2) = 1000.0;
52  pWeights(3) = -1000.0;
53 
54  DVector dWeights( 4 );
55  dWeights(0) = 0.0;
56  dWeights(1) = 0.0;
57  dWeights(2) = 20.0;
58  dWeights(3) = -20.0;
59 
60  pid.setProportionalWeights( pWeights );
61  pid.setDerivativeWeights( dWeights );
62 
63  pid.setControlLowerLimit( 0,-200.0 );
64  pid.setControlUpperLimit( 0, 200.0 );
65 
66 
67 // DMatrix K( 1,4 );
68 // K(0,0) = -3.349222044080232e+04;
69 // K(0,1) = -3.806600292165519e+03;
70 // K(0,2) = 9.999999999999985e+02;
71 // K(0,3) = -1.040810121403324e+03;
72 //
73 // LinearStateFeedback lqr( K,0.025 );
74 //
75 // lqr.setControlLowerLimit( 0,-200.0 );
76 // lqr.setControlUpperLimit( 0, 200.0 );
77 
78 
79  StaticReferenceTrajectory zeroReference;
80 
81  Controller controller( pid,zeroReference );
82 // Controller controller( lqr,zeroReference );
83 
84 
85  // INITIALIZE CONTROLLER AND PERFORM A STEP:
86  // -----------------------------------------
87  DVector y( 4 );
88  y.setZero( );
89  y(0) = 0.01;
90 
91  controller.init( 0.0,y );
92  controller.step( 0.0,y );
93 
94 
95  DVector u;
96  controller.getU( u );
97  u.print( "Feedback control" );
98 
99  return 0;
100 }
101 
102 
103 
Calculates the control inputs of the Process based on the Process outputs.
Definition: controller.hpp:71
#define USING_NAMESPACE_ACADO
virtual returnValue step(double currentTime, const DVector &_y, const VariablesGrid &_yRef=emptyConstVariablesGrid)
Definition: controller.cpp:338
virtual returnValue init(double startTime=0.0, const DVector &_x0=emptyConstVector, const DVector &_p=emptyConstVector, const VariablesGrid &_yRef=emptyConstVariablesGrid)
Definition: controller.cpp:270
virtual returnValue print(std::ostream &stream=std::cout, const std::string &name=DEFAULT_LABEL, const std::string &startString=DEFAULT_START_STRING, const std::string &endString=DEFAULT_END_STRING, uint width=DEFAULT_WIDTH, uint precision=DEFAULT_PRECISION, const std::string &colSeparator=DEFAULT_COL_SEPARATOR, const std::string &rowSeparator=DEFAULT_ROW_SEPARATOR) const
Definition: vector.cpp:97
Derived & setZero(Index size)
Allows to define a static reference trajectory that the ControlLaw aims to track. ...
returnValue getU(DVector &_u) const
Implements a PID control law to be used within a Controller.


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:39