periodic_reference_trajectory.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 {
48 }
49 
50 
51 // PeriodicReferenceTrajectory::PeriodicReferenceTrajectory( const Curve& _yRef
52 // ) : StaticReferenceTrajectory( _yRef )
53 // {
54 // }
55 
56 
58  ) : StaticReferenceTrajectory( _yRef )
59 {
60 }
61 
62 
64  ) : StaticReferenceTrajectory( _yRefFileName )
65 {
66 }
67 
68 
71 {
72  //yRef = rhs.yRef;
73 }
74 
75 
77 {
78 }
79 
80 
82 {
83  if ( this != &rhs )
84  {
86  //yRef = rhs.yRef;
87  }
88 
89  return *this;
90 }
91 
92 
94 {
95  return new PeriodicReferenceTrajectory( *this );
96 }
97 
98 
100  double tEnd,
101  VariablesGrid& _yRef
102  ) const
103 {
104  if ( acadoIsStrictlyGreater( tStart,tEnd ) == BT_TRUE )
106 
107  double T = yRef.getLastTime() - yRef.getFirstTime(); // cycle duration
108  int nStart = (int)floor( (double) (tStart/T+100.0*EPS) ); // cycle number at start
109  int nEnd = (int)floor( (double) (tEnd /T-100.0*EPS) ); // cycle number at end
110 
111  if ( nStart == nEnd )
112  {
113  _yRef = (yRef.getTimeSubGrid( tStart-T*(double)nStart,tEnd-T*(double)nStart )).shiftTimes( T*(double)nStart );
114  }
115  else
116  {
117  _yRef = (yRef.getTimeSubGrid( tStart-T*(double)nStart,yRef.getLastTime() )).shiftTimes( T*(double)nStart );
118 
119  for( int i=nStart+1; i<nEnd; ++i )
120  _yRef.appendTimes( VariablesGrid(yRef).shiftTimes( T*(double)i ),MM_KEEP );
121 
122  _yRef.appendTimes( (yRef.getTimeSubGrid( yRef.getFirstTime(),tEnd-T*(double)nEnd )).shiftTimes( T*(double)nEnd ) );
123  }
124 
125  return SUCCESSFUL_RETURN;
126 }
127 
128 
129 
130 //
131 // PROTECTED MEMBER FUNCTIONS:
132 //
133 
134 
135 
136 
138 
139 // end of file.
VariablesGrid & shiftTimes(double timeShift)
StaticReferenceTrajectory & operator=(const StaticReferenceTrajectory &rhs)
Allows to define a static periodic reference trajectory that the ControlLaw aims to track...
USING_NAMESPACE_ACADO typedef TaylorVariable< Interval > T
Abstract base class to define a reference trajectory that the ControlLaw aims to track.
double getFirstTime() const
BEGIN_NAMESPACE_ACADO const double EPS
Provides a time grid consisting of vector-valued optimization variables at each grid point...
Allows to pass back messages to the calling function.
virtual returnValue getReference(double tStart, double tEnd, VariablesGrid &_yRef) const
PeriodicReferenceTrajectory & operator=(const PeriodicReferenceTrajectory &rhs)
#define CLOSE_NAMESPACE_ACADO
VariablesGrid getTimeSubGrid(uint startIdx, uint endIdx) const
returnValue appendTimes(const VariablesGrid &arg, MergeMethod _mergeMethod=MM_DUPLICATE)
virtual ReferenceTrajectory * clone() const
Allows to define a static reference trajectory that the ControlLaw aims to track. ...
void rhs(const real_t *x, real_t *f)
#define BT_TRUE
Definition: acado_types.hpp:47
double getLastTime() const
#define BEGIN_NAMESPACE_ACADO
BooleanType acadoIsStrictlyGreater(double x, double y, double TOL)
#define ACADOERROR(retval)


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