linear_state_feedback.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 
35 
36 
37 
39 
40 
41 
42 //
43 // PUBLIC MEMBER FUNCTIONS:
44 //
45 
47 {
49 }
50 
51 
53  double _samplingTime
54  ) : ControlLaw( _samplingTime ), ClippingFunctionality( _K.getNumRows() )
55 {
56  K = _K;
58 }
59 
60 
62 {
63  K = rhs.K;
64 }
65 
66 
68 {
69 }
70 
71 
73 {
74  if ( this != &rhs )
75  {
76  ControlLaw::operator=( rhs );
78 
79  K = rhs.K;
80  }
81 
82  return *this;
83 }
84 
85 
87 {
88  return new LinearStateFeedback( *this );
89 }
90 
91 
93  const DVector &x0_,
94  const DVector &p_,
95  const VariablesGrid& _yRef
96  )
97 {
99  return SUCCESSFUL_RETURN;
100 }
101 
102 
104  const DVector& _x,
105  const DVector& _p,
106  const VariablesGrid& _yRef
107  )
108 {
109  if ( getStatus( ) != BS_READY )
111 
112  if ( _x.getDim( ) != getNX( ) )
114 
115 
116  /* 1) Use reference trajectory if it is defined */
117  // set default reference to zero
118  DVector xRef( _x );
119 
120  if ( _yRef.getNumPoints( ) > 0 )
121  {
122  if ( _yRef.getNumValues( ) != getNX( ) )
124 
125  xRef = _yRef.getVector( 0 );
126  }
127  else
128  {
129  xRef.setZero( );
130  }
131 
132 
133  /* 2) Linear state feedback. */
134  u = K * ( xRef - _x );
135  p = _p;
136 
137 
138  /* 3) Call output transformator. */
139  if ( clipSignals( u,p ) != SUCCESSFUL_RETURN )
141 
142  return SUCCESSFUL_RETURN;
143 }
144 
145 
146 
148 {
149  return K.getNumCols( );
150 }
151 
152 
154 {
155  return 0;
156 }
157 
158 
160 {
161  return K.getNumRows( );
162 }
163 
164 
166 {
167  return 0;
168 }
169 
170 
172 {
173  return 0;
174 }
175 
176 
178 {
179  return getNX( );
180 }
181 
182 
184 {
185  return BT_FALSE;
186 }
187 
188 
190 {
191  if ( isDynamic() == BT_TRUE )
192  return BT_FALSE;
193  else
194  return BT_TRUE;
195 }
196 
197 
198 
199 //
200 // PROTECTED MEMBER FUNCTIONS:
201 //
202 
203 
204 
205 
207 
208 // end of file.
LinearStateFeedback & operator=(const LinearStateFeedback &rhs)
ControlLaw & operator=(const ControlLaw &rhs)
Definition: control_law.cpp:68
virtual BooleanType isStatic() const
virtual returnValue init(double startTime=0.0, const DVector &x0_=emptyConstVector, const DVector &p_=emptyConstVector, const VariablesGrid &_yRef=emptyConstVariablesGrid)
returnValue setStatus(BlockStatus _status)
Provides a time grid consisting of vector-valued optimization variables at each grid point...
Allows to pass back messages to the calling function.
ClippingFunctionality & operator=(const ClippingFunctionality &rhs)
virtual uint getNP() const
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
#define CLOSE_NAMESPACE_ACADO
virtual uint getNXA() const
virtual BooleanType isDynamic() const
BlockStatus getStatus() const
unsigned getDim() const
Definition: vector.hpp:172
virtual uint getNX() const
Derived & setZero(Index size)
void rhs(const real_t *x, real_t *f)
Implements a linear state feedback law to be used within a Controller.
unsigned getNumRows() const
Definition: matrix.hpp:185
#define BT_TRUE
Definition: acado_types.hpp:47
unsigned getNumCols() const
Definition: matrix.hpp:189
uint getNumPoints() const
virtual uint getNW() const
Allows to transform the output of the ControlLaw before passing it to the Process.
DVector getVector(uint pointIdx) const
#define BEGIN_NAMESPACE_ACADO
#define BT_FALSE
Definition: acado_types.hpp:49
virtual uint getNU() const
virtual uint getNY() const
Base class for interfacing online feedback laws to be used within a Controller.
Definition: control_law.hpp:64
virtual returnValue step(double currentTime, const DVector &_x, const DVector &_p=emptyConstVector, const VariablesGrid &_yRef=emptyConstVariablesGrid)
returnValue clipSignals(VariablesGrid &_u, VariablesGrid &_p=emptyVariablesGrid)
#define ACADOERROR(retval)
virtual ControlLaw * clone() const


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