feedforward_law.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 
44 
45 
47 
48 
49 
50 //
51 // PUBLIC MEMBER FUNCTIONS:
52 //
53 
55 {
57 }
58 
59 
61  const Curve& _u,
62  double _samplingTime
63  ) : ControlLaw( _samplingTime )
64 {
65  nx=_nx;
66  uRef=_u;
68 }
69 
70 
72 {
73  nx=rhs.nx;
74  uRef=rhs.uRef;
75 }
76 
77 
79 {
80 }
81 
82 
84 {
85  if ( this != &rhs )
86  {
87  ControlLaw::operator=( rhs );
88 
89  }
90 
91  return *this;
92 }
93 
94 
96 {
97  return new FeedforwardLaw( *this );
98 }
99 
100 
102  const DVector &x0_,
103  const DVector &p_,
104  const VariablesGrid& _yRef
105  )
106 {
107  u.init(getNU());
108  u.setZero();
109 
110  p.init( 0 );
111  p.setZero( );
112 
113  setStatus( BS_READY );
114 
115  return SUCCESSFUL_RETURN;
116 }
117 
118 
119 returnValue FeedforwardLaw::step( double currentTime,
120  const DVector& _x,
121  const DVector& _p,
122  const VariablesGrid& _yRef
123  )
124 {
125  if ( getStatus( ) != BS_READY )
127 
128  if ( _x.getDim( ) != getNX( ) )
130 
131 
132  // use reference control as control
133  DVector uEv;
134  uRef.evaluate(currentTime,uEv);
135  //printf("FeedforwardLaw controllor outputs %d #.\n",uRef.getDim());
136  //printf(" -- yref: %d samples of size (%d,%d) -- \n",_yRef.getNumPoints(),_yRef.getNumRows(),_yRef.getNumCols());
137 
138  u = uEv;
139  p = _p;
140 
141  //printf(" -- u: [%.3e,%.3e,%.3e] -- \n",u(0),u(1),u(2));
142 
143  return SUCCESSFUL_RETURN;
144 }
145 
146 
147 
149 {
150  return nx;
151 }
152 
153 
155 {
156  return 0;
157 }
158 
159 
161 {
162  return uRef.getDim( );
163 }
164 
165 
167 {
168  return 0;
169 }
170 
171 
173 {
174  return 0;
175 }
176 
177 
179 {
180  return getNX( );
181 }
182 
183 
185 {
186  return BT_FALSE;
187 }
188 
189 
191 {
192  if ( isDynamic() == BT_TRUE )
193  return BT_FALSE;
194  else
195  return BT_TRUE;
196 }
197 
198 
199 
200 //
201 // PROTECTED MEMBER FUNCTIONS:
202 //
203 
204 
205 
206 
208 
209 // end of file.
ControlLaw & operator=(const ControlLaw &rhs)
Definition: control_law.cpp:68
virtual BooleanType isDynamic() const
virtual uint getNU() const
virtual uint getNX() const
returnValue evaluate(double t, double *result) const
Definition: curve.cpp:314
returnValue setStatus(BlockStatus _status)
void init(unsigned _dim=0)
Definition: vector.hpp:155
Provides a time grid consisting of vector-valued optimization variables at each grid point...
Allows to pass back messages to the calling function.
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
FeedforwardLaw & operator=(const FeedforwardLaw &rhs)
#define CLOSE_NAMESPACE_ACADO
virtual uint getNW() const
virtual uint getNY() const
virtual uint getNP() const
virtual returnValue step(double currentTime, const DVector &_x, const DVector &_p=emptyConstVector, const VariablesGrid &_yRef=emptyConstVariablesGrid)
BlockStatus getStatus() const
unsigned getDim() const
Definition: vector.hpp:172
virtual uint getNXA() const
Derived & setZero(Index size)
Allows to work with piecewise-continous function defined over a scalar time interval.
Definition: curve.hpp:52
void rhs(const real_t *x, real_t *f)
#define BT_TRUE
Definition: acado_types.hpp:47
virtual ~FeedforwardLaw()
virtual BooleanType isStatic() const
#define BEGIN_NAMESPACE_ACADO
#define BT_FALSE
Definition: acado_types.hpp:49
virtual returnValue init(double startTime=0.0, const DVector &x0_=emptyConstVector, const DVector &p_=emptyConstVector, const VariablesGrid &_yRef=emptyConstVariablesGrid)
Implements a feedforward law to be used within a Controller.
Base class for interfacing online feedback laws to be used within a Controller.
Definition: control_law.hpp:64
virtual ControlLaw * clone() const
int getDim() const
#define ACADOERROR(retval)


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