static_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 
00033 #include <acado/reference_trajectory/static_reference_trajectory.hpp>
00034 
00035 
00036 
00037 BEGIN_NAMESPACE_ACADO
00038 
00039 
00040 
00041 //
00042 // PUBLIC MEMBER FUNCTIONS:
00043 //
00044 
00045 StaticReferenceTrajectory::StaticReferenceTrajectory( ) : ReferenceTrajectory( )
00046 {
00047 }
00048 
00049 
00050 // StaticReferenceTrajectory::StaticReferenceTrajectory(        const Curve& _yRef
00051 //                                                                                                              ) : ReferenceTrajectory( )
00052 // {
00053 //      yRef = _yRef;
00054 // 
00055 //      setStatus( BS_READY );
00056 // }
00057 
00058 
00059 StaticReferenceTrajectory::StaticReferenceTrajectory(   const VariablesGrid& _yRef
00060                                                                                                                 )
00061 {
00062         if ( _yRef.isEmpty( ) == BT_TRUE )
00063         {
00064                 ACADOERROR( RET_INVALID_ARGUMENTS );
00065                 ASSERT( 1==0 );
00066         }
00067 
00068 //      yRef.add( _yRef );
00069         yRef = _yRef;
00070 
00071         //setStatus( BS_READY );
00072 }
00073 
00074 
00075 StaticReferenceTrajectory::StaticReferenceTrajectory(   const char* const _yRefFileName
00076                                                                                                                 )
00077 {
00078     VariablesGrid _yRef;
00079     _yRef.read( _yRefFileName );
00080 
00081         if ( _yRef.isEmpty( ) == BT_TRUE )
00082         {
00083                 ACADOERROR( RET_FILE_CAN_NOT_BE_OPENED );
00084                 ASSERT( 1==0 );
00085         }
00086 
00087 //      yRef.add( _yRef );
00088         yRef = _yRef;
00089 
00090         //setStatus( BS_READY );
00091 }
00092 
00093 
00094 
00095 StaticReferenceTrajectory::StaticReferenceTrajectory( const StaticReferenceTrajectory& rhs ) : ReferenceTrajectory( rhs )
00096 {
00097         yRef = rhs.yRef;
00098 }
00099 
00100 
00101 StaticReferenceTrajectory::~StaticReferenceTrajectory( )
00102 {
00103 }
00104 
00105 
00106 StaticReferenceTrajectory& StaticReferenceTrajectory::operator=( const StaticReferenceTrajectory& rhs )
00107 {
00108         if ( this != &rhs )
00109         {
00110                 ReferenceTrajectory::operator=( rhs );
00111 
00112                 yRef = rhs.yRef;
00113         }
00114 
00115     return *this;
00116 }
00117 
00118 
00119 ReferenceTrajectory* StaticReferenceTrajectory::clone( ) const
00120 {
00121         return new StaticReferenceTrajectory( *this );
00122 }
00123 
00124 
00125 returnValue StaticReferenceTrajectory::init(    double startTime,
00126                                                                                                 const DVector& _x,
00127                                                                                                 const DVector& _xa,
00128                                                                                                 const DVector& _u,
00129                                                                                                 const DVector& _p,
00130                                                                                                 const DVector& _w
00131                                                                                                 )
00132 {
00133         return SUCCESSFUL_RETURN;
00134 }
00135 
00136 
00137 returnValue StaticReferenceTrajectory::step(    double _currentTime,
00138                                                                                                 const DVector& _y,
00139                                                                                                 const DVector& _x,
00140                                                                                                 const DVector& _xa,
00141                                                                                                 const DVector& _u,
00142                                                                                                 const DVector& _p,
00143                                                                                                 const DVector& _w
00144                                                                                                 )
00145 {
00146         return SUCCESSFUL_RETURN;
00147 }
00148 
00149 
00150 returnValue StaticReferenceTrajectory::step(    const DVector& _x,
00151                                                                                                 const VariablesGrid& _u,
00152                                                                                                 const VariablesGrid& _p,
00153                                                                                                 const VariablesGrid& _w
00154                                                                                                 )
00155 {
00156         return SUCCESSFUL_RETURN;
00157 }
00158 
00159 
00160 returnValue StaticReferenceTrajectory::getReference(    double tStart,
00161                                                                                                                 double tEnd,
00162                                                                                                                 VariablesGrid& _yRef
00163                                                                                                                 ) const
00164 {
00165         if ( acadoIsSmaller( tStart,tEnd ) == BT_FALSE )
00166                 return ACADOERROR( RET_INVALID_ARGUMENTS );
00167 
00168         if ( acadoIsStrictlySmaller( tStart,yRef.getFirstTime() ) == BT_TRUE )
00169                 return ACADOERROR( RET_INVALID_ARGUMENTS );
00170         
00171 //     return yRef.evaluate( tStart,tEnd,_yRef );
00172 
00173         if ( acadoIsSmaller( tEnd,yRef.getLastTime() ) == BT_TRUE )
00174         {
00175                 _yRef = yRef.getTimeSubGrid( tStart,tEnd );
00176         }
00177         else
00178         {
00179                 // constant extrapolation beyond end of interval
00180                 if ( acadoIsSmaller( yRef.getLastTime(),tStart ) == BT_TRUE )
00181                 {
00182                         Grid grid( tStart,tEnd );
00183                         _yRef.init( yRef.getLastVector(),grid );
00184                 }
00185                 else
00186                 {
00187                         _yRef = yRef.getTimeSubGrid( tStart,yRef.getLastTime() );
00188                         _yRef.setTime( _yRef.getLastIndex(),tEnd );
00189                 }
00190         }
00191 
00192         return SUCCESSFUL_RETURN;
00193 }
00194 
00195 
00196 
00197 uint StaticReferenceTrajectory::getDim( ) const
00198 {
00199 //      return yRef.getDim( );
00200         return yRef.getNumValues( );
00201 }
00202 
00203 
00204 //
00205 // PROTECTED MEMBER FUNCTIONS:
00206 //
00207 
00208 
00209 
00210 
00211 CLOSE_NAMESPACE_ACADO
00212 
00213 // end of file.


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