Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
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 
00043 
00044 
00045 StaticReferenceTrajectory::StaticReferenceTrajectory( ) : ReferenceTrajectory( )
00046 {
00047 }
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
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 
00069         yRef = _yRef;
00070 
00071         
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 
00088         yRef = _yRef;
00089 
00090         
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 
00172 
00173         if ( acadoIsSmaller( tEnd,yRef.getLastTime() ) == BT_TRUE )
00174         {
00175                 _yRef = yRef.getTimeSubGrid( tStart,tEnd );
00176         }
00177         else
00178         {
00179                 
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 
00200         return yRef.getNumValues( );
00201 }
00202 
00203 
00204 
00205 
00206 
00207 
00208 
00209 
00210 
00211 CLOSE_NAMESPACE_ACADO
00212 
00213