periodic_reference_trajectory.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 
00034 #include <acado/reference_trajectory/periodic_reference_trajectory.hpp>
00035 
00036 
00037 
00038 BEGIN_NAMESPACE_ACADO
00039 
00040 
00041 
00042 //
00043 // PUBLIC MEMBER FUNCTIONS:
00044 //
00045 
00046 PeriodicReferenceTrajectory::PeriodicReferenceTrajectory( ) : StaticReferenceTrajectory( )
00047 {
00048 }
00049 
00050 
00051 // PeriodicReferenceTrajectory::PeriodicReferenceTrajectory(    const Curve& _yRef
00052 //                                                                                                                      ) : StaticReferenceTrajectory( _yRef )
00053 // {
00054 // }
00055 
00056 
00057 PeriodicReferenceTrajectory::PeriodicReferenceTrajectory(       const VariablesGrid& _yRef
00058                                                                                                                         ) : StaticReferenceTrajectory( _yRef )
00059 {
00060 }
00061 
00062 
00063 PeriodicReferenceTrajectory::PeriodicReferenceTrajectory(       const char* const _yRefFileName
00064                                                                                                                         ) : StaticReferenceTrajectory( _yRefFileName )
00065 {
00066 }
00067 
00068 
00069 PeriodicReferenceTrajectory::PeriodicReferenceTrajectory( const PeriodicReferenceTrajectory& rhs )
00070                             :StaticReferenceTrajectory( rhs )
00071 {
00072         //yRef = rhs.yRef;
00073 }
00074 
00075 
00076 PeriodicReferenceTrajectory::~PeriodicReferenceTrajectory( )
00077 {
00078 }
00079 
00080 
00081 PeriodicReferenceTrajectory& PeriodicReferenceTrajectory::operator=( const PeriodicReferenceTrajectory& rhs )
00082 {
00083         if ( this != &rhs )
00084         {
00085                 StaticReferenceTrajectory::operator=( rhs );
00086                 //yRef = rhs.yRef;
00087         }
00088 
00089         return *this;
00090 }
00091 
00092 
00093 ReferenceTrajectory* PeriodicReferenceTrajectory::clone( ) const
00094 {
00095         return new PeriodicReferenceTrajectory( *this );
00096 }
00097 
00098 
00099 returnValue PeriodicReferenceTrajectory::getReference(  double tStart,
00100                                                                                                                 double tEnd,
00101                                                                                                                 VariablesGrid& _yRef
00102                                                                                                                 ) const
00103 {
00104         if ( acadoIsStrictlyGreater( tStart,tEnd ) == BT_TRUE )
00105                 return ACADOERROR( RET_INVALID_ARGUMENTS );
00106 
00107         double T = yRef.getLastTime() - yRef.getFirstTime();         // cycle duration
00108         int nStart = (int)floor( (double) (tStart/T+100.0*EPS) );  // cycle number at start
00109         int nEnd   = (int)floor( (double) (tEnd  /T-100.0*EPS) );  // cycle number at end
00110 
00111         if ( nStart == nEnd )
00112         {
00113                 _yRef = (yRef.getTimeSubGrid( tStart-T*(double)nStart,tEnd-T*(double)nStart )).shiftTimes( T*(double)nStart );
00114         }
00115         else
00116         {
00117                 _yRef = (yRef.getTimeSubGrid( tStart-T*(double)nStart,yRef.getLastTime() )).shiftTimes( T*(double)nStart );
00118                 
00119                 for( int i=nStart+1; i<nEnd; ++i )
00120                         _yRef.appendTimes( VariablesGrid(yRef).shiftTimes( T*(double)i ),MM_KEEP );
00121                 
00122                 _yRef.appendTimes( (yRef.getTimeSubGrid( yRef.getFirstTime(),tEnd-T*(double)nEnd )).shiftTimes( T*(double)nEnd ) );
00123         }
00124         
00125         return SUCCESSFUL_RETURN;
00126 }
00127 
00128 
00129 
00130 //
00131 // PROTECTED MEMBER FUNCTIONS:
00132 //
00133 
00134 
00135 
00136 
00137 CLOSE_NAMESPACE_ACADO
00138 
00139 // end of file.


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:38:34