TimeLaw.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 
00031 
00032 #ifndef TIMELAW_H
00033 #define TIMELAW_H
00034 
00035 #ifdef MIP_HOST_APPLE
00036 #include <applePatch.h>
00037 #endif
00038 
00039 #include<iostream>
00040 #include<math.h>
00041 #include<Time.h>
00042 #include"Path.h"
00043 using namespace std;
00044 
00047 enum TimeLawType{
00048  STILLNESS,
00049  CONST_SPEED,
00050  TRIANGULAR_SPEED,
00051  TRAPEZOIDAL_SPEED,
00052  CUBIC_SPEED,
00053  TRAPEZOIDAL_ACC,
00054  TRAPEZOIDAL_DEC,
00055  LAW_NUM
00056 };
00057 
00060 static const char* TimeLawNames[LAW_NUM] = {
00061  "Stillness",
00062  "Constant Speed",
00063  "Triangular Speed",
00064  "Trapezoidal Speed",
00065  "Cubic Speed",
00066  "Trapezoidal Acceleration",
00067  "Trapezoidal Deceleration"
00068 };
00069 
00070 namespace MipBaselib {
00071 
00076 class ConstSpeedParam{
00077  private:
00078   Decimal _speed; 
00079  public:
00081   ConstSpeedParam(){};
00083   ConstSpeedParam(Decimal speed){
00084    setSpeed(speed);
00085   }
00086   
00089   ConstSpeedParam(const ConstSpeedParam& p){
00090    _speed=p._speed;
00091   }
00092   
00095   ConstSpeedParam& operator=(const ConstSpeedParam& p){
00096    if (this != &p){
00097     _speed=p._speed;
00098    }
00099    return *this;
00100   }
00101 /***************************************************************************************************
00102 ***********************************        SET FUNCTIONS         ***********************************
00103 ***************************************************************************************************/
00105   void setSpeed(Decimal value){
00106    _speed=value;
00107   }
00108 /***************************************************************************************************
00109 ***********************************        GET FUNCTIONS         ***********************************
00110 ***************************************************************************************************/
00112   Decimal speed(){
00113    return _speed;
00114   }
00115   
00117   string print(){
00118    stringstream s;
00119    s.precision(3);
00120    s.setf(ios::fixed,ios::floatfield);
00121    s<<"Speed\t"<<_speed<<endl;
00122    return s.str();
00123   };
00124 };
00125 
00130 class TriangularSpeedParam{
00131  private:
00132   Decimal _acceleration; 
00133   Time _T;        
00134  public:
00136   TriangularSpeedParam(){};
00138   TriangularSpeedParam(Decimal acceleration, Time T){
00139    setAcceleration(acceleration);
00140    setT(T);
00141   }
00142   
00145   TriangularSpeedParam(const TriangularSpeedParam& p){
00146    _acceleration=p._acceleration;
00147    _T=p._T;
00148   }
00149   
00152   TriangularSpeedParam& operator=(const TriangularSpeedParam& p){
00153    if (this != &p){
00154     _acceleration=p._acceleration;
00155     _T=p._T;
00156    }
00157    return *this;
00158   }
00159 /***************************************************************************************************
00160 ***********************************        SET FUNCTIONS         ***********************************
00161 ***************************************************************************************************/
00163   void setAcceleration (Decimal value){
00164    _acceleration=value;
00165   }
00166   
00168   void setT (Time value){
00169    _T=value;
00170   }
00171 /***************************************************************************************************
00172 ***********************************        GET FUNCTIONS         ***********************************
00173 ***************************************************************************************************/
00175   Decimal acceleration(){
00176    return _acceleration;
00177   }
00178   
00180   Time T(){
00181    return _T;
00182   }
00183   
00185   string print(){
00186    stringstream s;
00187    s.precision(3);
00188    s.setf(ios::fixed,ios::floatfield);
00189    s<<"Acceleration\t\t\t"<<_acceleration<<endl;
00190    s<<"Acceleration toggling time\t"<<_T.print()<<endl;
00191    return s.str();
00192   };
00193 };
00194 
00199 class TrapezoidalSpeedParam{
00200  private:
00201   Decimal _acceleration; 
00202   Time _T1;        
00203   Time _T2;        
00204  public:
00206   TrapezoidalSpeedParam(){};
00208   TrapezoidalSpeedParam(Decimal acceleration, Time T1, Time T2){
00209    setAcceleration(acceleration);
00210    setT1(T1);
00211    setT2(T2);
00212   }
00213   
00216   TrapezoidalSpeedParam(const TrapezoidalSpeedParam& p){
00217    _acceleration=p._acceleration;
00218    _T1=p._T1;
00219    _T2=p._T2;
00220   }
00221   
00224   TrapezoidalSpeedParam& operator=(const TrapezoidalSpeedParam& p){
00225    if (this != &p){
00226     _acceleration=p._acceleration;
00227     _T1=p._T1;
00228     _T2=p._T2;
00229    }
00230    return *this;
00231   }
00232 /***************************************************************************************************
00233 ***********************************        SET FUNCTIONS         ***********************************
00234 ***************************************************************************************************/
00236   void setAcceleration (Decimal value){
00237    _acceleration=value;
00238   }
00239   
00241   void setT1 (Time value){
00242    _T1=value;
00243   }
00244   
00246   void setT2 (Time value){
00247    _T2=value;
00248   }
00249 /***************************************************************************************************
00250 ***********************************        GET FUNCTIONS         ***********************************
00251 ***************************************************************************************************/
00253   Decimal acceleration(){
00254    return _acceleration;
00255   }
00256   
00258   Time T1(){
00259    return _T1;
00260   }
00261   
00263   Time T2(){
00264    return _T2;
00265   }
00266   
00268   string print(){
00269    stringstream s;
00270    s.precision(3);
00271    s.setf(ios::fixed,ios::floatfield);
00272    s<<"Acceleration\t\t\t\t"<<_acceleration<<endl;
00273    s<<"Instant of acceleration zero-setting\t"<<_T1.print()<<endl;
00274    s<<"Instant deceleration start\t\t"<<_T2.print()<<endl;
00275    return s.str();
00276   };
00277 };
00278 
00284 class CubicSpeedParam{
00285  private:
00286   Decimal _acceleration; 
00287   Time _T1;        
00288   Time _T2;        
00289  public:
00291   CubicSpeedParam(){};
00293   CubicSpeedParam(Decimal acceleration, Time T1, Time T2){
00294    setAcceleration(acceleration);
00295    setT1(T1);
00296    setT2(T2);
00297   }
00298   
00301   CubicSpeedParam(const CubicSpeedParam& p){
00302    _acceleration=p._acceleration;
00303    _T1=p._T1;
00304    _T2=p._T2;
00305   }
00306   
00309   CubicSpeedParam& operator=(const CubicSpeedParam& p){
00310    if (this != &p){
00311     _acceleration=p._acceleration;
00312     _T1=p._T1;
00313     _T2=p._T2;
00314    }
00315    return *this;
00316   }
00317 /***************************************************************************************************
00318 ***********************************        SET FUNCTIONS         ***********************************
00319 ***************************************************************************************************/
00321   void setAcceleration (Decimal value){
00322    _acceleration=value;
00323   }
00324   
00326   void setT1 (Time value){
00327    _T1=value;
00328   }
00329   
00331   void setT2 (Time value){
00332    _T2=value;
00333   }
00334 /***************************************************************************************************
00335 ***********************************        GET FUNCTIONS         ***********************************
00336 ***************************************************************************************************/
00338   Decimal acceleration(){
00339    return _acceleration;
00340   }
00341   
00343   Time T1(){
00344    return _T1;
00345   }
00346   
00348   Time T2(){
00349    return _T2;
00350   }
00351   
00353   string print(){
00354    stringstream s;
00355    s.precision(3);
00356    s.setf(ios::fixed,ios::floatfield);
00357    s<<"Acceleration\t"<<_acceleration<<endl;
00358    s<<"T1???\t\t"<<_T1.print()<<endl;
00359    s<<"T2???\t\t"<<_T2.print()<<endl;
00360    return s.str();
00361   };
00362 };
00363 
00368 class TrapezoidalAccParam{
00369  private:
00370   Decimal _acceleration; 
00371   Time _T1;        
00372   Time _T2;        
00373  public:
00375   TrapezoidalAccParam(){};
00377   TrapezoidalAccParam(Decimal acceleration, Time T1, Time T2){
00378    setAcceleration(acceleration);
00379    setT1(T1);
00380    setT2(T2);
00381   }
00382   
00385   TrapezoidalAccParam(const TrapezoidalAccParam& p){
00386    _acceleration=p._acceleration;
00387    _T1=p._T1;
00388    _T2=p._T2;
00389   }
00390   
00393   TrapezoidalAccParam& operator=(const TrapezoidalAccParam& p){
00394    if (this != &p){
00395     _acceleration=p._acceleration;
00396     _T1=p._T1;
00397     _T2=p._T2;
00398    }
00399    return *this;
00400   }
00401 /***************************************************************************************************
00402 ***********************************        SET FUNCTIONS         ***********************************
00403 ***************************************************************************************************/
00405   void setAcceleration (Decimal value){
00406    _acceleration=value;
00407   }
00408   
00410   void setT1 (Time value){
00411    _T1=value;
00412   }
00413   
00415   void setT2 (Time value){
00416    _T2=value;
00417   }
00418 /***************************************************************************************************
00419 ***********************************        GET FUNCTIONS         ***********************************
00420 ***************************************************************************************************/
00422   Decimal acceleration(){
00423    return _acceleration;
00424   }
00425   
00427   Time T1(){
00428    return _T1;
00429   }
00430   
00432   Time T2(){
00433    return _T2;
00434   }
00435   
00437   string print(){
00438    stringstream s;
00439    s.precision(3);
00440    s.setf(ios::fixed,ios::floatfield);
00441    s<<"Acceleration\t"<<_acceleration<<endl;
00442    s<<"Instant of acceleration setting to constant\t\t"<<_T1.print()<<endl;
00443    s<<"Instant of acceleration decrement start\t\t"<<_T2.print()<<endl;
00444    return s.str();
00445   };
00446 };
00447 
00452 class TrapezoidalDecParam{
00453  private:
00454   Decimal _acceleration; 
00455   Time _T1;        
00456   Time _T2;        
00457  public:
00459   TrapezoidalDecParam(){};
00461   TrapezoidalDecParam(Decimal acceleration, Time T1, Time T2){
00462    setAcceleration(acceleration);
00463    setT1(T1);
00464    setT2(T2);
00465   }
00466   
00469   TrapezoidalDecParam(const TrapezoidalDecParam& p){
00470    _acceleration=p._acceleration;
00471    _T1=p._T1;
00472    _T2=p._T2;
00473   }
00474   
00477   TrapezoidalDecParam& operator=(const TrapezoidalDecParam& p){
00478    if (this != &p){
00479     _acceleration=p._acceleration;
00480     _T1=p._T1;
00481     _T2=p._T2;
00482    }
00483    return *this;
00484   }
00485 /***************************************************************************************************
00486 ***********************************        SET FUNCTIONS         ***********************************
00487 ***************************************************************************************************/
00489   void setAcceleration (Decimal value){
00490    _acceleration=value;
00491   }
00492   
00494   void setT1 (Time value){
00495    _T1=value;
00496   }
00497   
00499   void setT2 (Time value){
00500    _T2=value;
00501   }
00502 /***************************************************************************************************
00503 ***********************************        GET FUNCTIONS         ***********************************
00504 ***************************************************************************************************/
00506   Decimal acceleration(){
00507    return _acceleration;
00508   }
00509   
00511   Time T1(){
00512    return _T1;
00513   }
00514   
00516   Time T2(){
00517    return _T2;
00518   }
00519   
00521   string print(){
00522    stringstream s;
00523    s.precision(3);
00524    s.setf(ios::fixed,ios::floatfield);
00525    s<<"Acceleration\t"<<_acceleration<<endl;
00526    s<<"Instant of deceleration setting to constant\t\t"<<_T1.print()<<endl;
00527    s<<"Instant of deceleration decrement start\t\t"<<_T2.print()<<endl;
00528    return s.str();
00529   };
00530 };
00531 
00537 //TimeLaw = s(t)
00538 class TimeLaw{
00539  protected:
00540   Decimal _s;  
00541   Decimal _sp; 
00542   Decimal _spp; 
00543   Time _start; 
00544   Time _end;  
00545   TimeLawType _timeLawType;
00546   
00547  public:
00549   TimeLaw(){
00550    _s=0.0;
00551    _sp=0.0;
00552    _spp=0.0;
00553    _start=Time(0,0);
00554    _end=Time((long int)INFINITY,0);
00555    setTimeLawType(STILLNESS);
00556   };
00558   TimeLaw(Time start,Time end){
00559    _s=0.0;
00560    _sp=0.0;
00561    _spp=0.0;
00562    _start=start;
00563    _end=end;
00564    setTimeLawType(STILLNESS);
00565   };
00566   
00569   TimeLaw(const TimeLaw& timeLaw){
00570    _s=timeLaw._s;
00571    _sp=timeLaw._sp;
00572    _spp=timeLaw._spp;
00573    _start=timeLaw._start;
00574    _end=timeLaw._end;
00575    _timeLawType=timeLaw._timeLawType;
00576   }
00577   
00580   TimeLaw& operator=(const TimeLaw& timeLaw){
00581    if (this != &timeLaw){
00582     _s=timeLaw._s;
00583     _sp=timeLaw._sp;
00584     _spp=timeLaw._spp;
00585     _start=timeLaw._start;
00586     _end=timeLaw._end;
00587     _timeLawType=timeLaw._timeLawType;
00588    }
00589    return *this;
00590   }
00593   virtual void inizializeS(Time time)=0;
00594 /***************************************************************************************************
00595 ***********************************        SET FUNCTIONS         ***********************************
00596 ***************************************************************************************************/
00598   void setS(Decimal value){
00599    _s=value;
00600   }
00601   
00603   void setSp(Decimal value){
00604    _sp=value;
00605   }
00606   
00608   void setSpp(Decimal value){
00609    _spp=value;
00610   }
00611   
00612   
00614   void setStart(Time value){
00615    _start=value;
00616   }
00617   
00619   void setEnd(Time value){
00620    _end=value;
00621   }
00622   
00624   void setTimeLawType(TimeLawType value){
00625    _timeLawType=value;
00626   }
00627   
00628 /***************************************************************************************************
00629 ***********************************        GET FUNCTIONS         ***********************************
00630 ***************************************************************************************************/
00632   Decimal s(){
00633    return _s;
00634   }
00635   
00637   Decimal sp(){
00638    return _sp;
00639   }
00640   
00642   Decimal spp(){
00643    return _spp;
00644   }
00645   
00647   Time start(){
00648    return _start;
00649   }
00650   
00652   Time end(){
00653    return _end;
00654   }
00655   
00657   TimeLawType timeLawType(){
00658    return _timeLawType;
00659   }
00660   
00662   string print(){
00663    stringstream s;
00664    s.precision(3);
00665    s.setf(ios::fixed,ios::floatfield);
00666    s<<"Time Law Type\t"<<TimeLawNames[_timeLawType]<<endl;
00667    s<<"Start\t\t"<<_start.print()<<endl;
00668    s<<"End\t\t"<<_end.print()<<endl;
00669    return s.str();
00670   };
00671 };
00672 
00678 class Stillness :public TimeLaw{
00679  public:
00681   Stillness(){
00682    _s=0.0;
00683    _sp=0.0;
00684    _spp=0.0;
00685    setTimeLawType(STILLNESS);
00686   };
00687   
00690   Stillness(const Stillness& stillness):TimeLaw(stillness){
00691    _s=stillness._s;
00692    _sp=stillness._sp;
00693    _spp=stillness._spp;
00694    _start=stillness._start;
00695    _end=stillness._end;
00696   }
00697   
00700   Stillness& operator=(const Stillness& stillness){
00701    if (this != &stillness){
00702     TimeLaw::operator=(stillness);
00703     _s=stillness._s;
00704     _sp=stillness._sp;
00705     _spp=stillness._spp;
00706     _start=stillness._start;
00707     _end=stillness._end;
00708    }
00709    return *this;
00710   }
00711   
00712   void inizializeS(Time time){
00713    _sp=0.0;
00714    _spp=0.0;
00715   };
00716   
00718   string print(){
00719    stringstream s;
00720    s.precision(3);
00721    s.setf(ios::fixed,ios::floatfield);
00722    s<<TimeLaw::print();
00723    return s.str();
00724   }
00725 };
00726 
00727 
00733 class ConstSpeed :public TimeLaw{
00734  private:
00735   ConstSpeedParam _param; 
00737  public:
00739   ConstSpeed(){
00740    _s=0.0;
00741    _sp=0.0;
00742    _spp=0.0;
00743    _start=Time(0,0);
00744    _end=Time((long int)INFINITY,0);
00745    _param.setSpeed(1.0);
00746    setTimeLawType(CONST_SPEED);
00747   };
00749   ConstSpeed(ConstSpeedParam param){
00750    _s=0.0;
00751    _sp=0.0;
00752    _spp=0.0;
00753    _start=Time(0,0);
00754    _end=Time((long int)INFINITY,0);
00755    _param.setSpeed(param.speed());
00756    setTimeLawType(CONST_SPEED);
00757   };
00758   
00761   ConstSpeed(const ConstSpeed& constSpeed):TimeLaw(constSpeed){
00762    _param=constSpeed._param;
00763   }
00764   
00767   ConstSpeed& operator=(const ConstSpeed& constSpeed){
00768    if (this != &constSpeed){
00769     TimeLaw::operator=(constSpeed);
00770     _param=constSpeed._param;
00771    }
00772    return *this;
00773   }
00774   
00775   void inizializeS(Time time);
00776 /***************************************************************************************************
00777 ***********************************        SET FUNCTIONS         ***********************************
00778 ***************************************************************************************************/
00780   void setParam(ConstSpeedParam param){
00781    _param.setSpeed(param.speed());
00782   }
00783 /***************************************************************************************************
00784 ***********************************        GET FUNCTIONS         ***********************************
00785 ***************************************************************************************************/
00787   ConstSpeedParam param(){
00788    return _param;
00789   }
00790   
00792   string print(){
00793    stringstream s;
00794    s.precision(3);
00795    s.setf(ios::fixed,ios::floatfield);
00796    s<<TimeLaw::print();
00797    s<<_param.print()<<endl;
00798    return s.str();
00799   }
00800 };
00801 
00807 class TriangularSpeed :public TimeLaw{
00808  private:
00809   TriangularSpeedParam _param; 
00810  public:
00812   TriangularSpeed(){
00813    _s=0.0;
00814    _sp=0.0;
00815    _spp=0.0;
00816    _start=Time(0,0);
00817    _end=Time((long int)INFINITY,0);
00818    // CHECK: MAYBE IS Time(5,0) instead of (Time)(5,0)
00819    _param.setT((Time)(10,0));
00820    setTimeLawType(TRIANGULAR_SPEED);
00821   };
00823   TriangularSpeed(TriangularSpeedParam param){
00824    _s=0.0;
00825    _sp=0.0;
00826    _spp=0.0;
00827    _start=Time(0,0);
00828    _end=Time((long int)INFINITY,0);
00829    _param.setAcceleration(param.acceleration());
00830    _param.setT(param.T());
00831    setTimeLawType(TRIANGULAR_SPEED);
00832   };
00833   
00836   TriangularSpeed(const TriangularSpeed& triangularSpeed):TimeLaw(triangularSpeed){
00837    _param=triangularSpeed._param;
00838   }
00839   
00842   TriangularSpeed& operator=(const TriangularSpeed& triangularSpeed){
00843    if (this != &triangularSpeed){
00844     TimeLaw::operator=(triangularSpeed);
00845     _param=triangularSpeed._param;
00846    }
00847    return *this;
00848   }
00849   
00850   void inizializeS(Time time);
00851 /***************************************************************************************************
00852 ***********************************        SET FUNCTIONS         ***********************************
00853 ***************************************************************************************************/
00855   void setParam(TriangularSpeedParam param){
00856    _param.setAcceleration(param.acceleration());
00857    _param.setT(param.T());
00858   }
00859 /***************************************************************************************************
00860 ***********************************        GET FUNCTIONS         ***********************************
00861 ***************************************************************************************************/
00863   TriangularSpeedParam param(){
00864    return _param;
00865   }
00866   
00868   string print(){
00869    stringstream s;
00870    s.precision(3);
00871    s.setf(ios::fixed,ios::floatfield);
00872    s<<TimeLaw::print();
00873    s<<_param.print()<<endl;
00874    return s.str();
00875   }
00876 };
00877 
00883 class TrapezoidalSpeed :public TimeLaw{
00884  private:
00885   TrapezoidalSpeedParam _param; 
00886  public:
00888   TrapezoidalSpeed(){
00889    _s=0.0;
00890    _sp=0.0;
00891    _spp=0.0;
00892    _start=Time(0,0);
00893    _end=Time((long int)INFINITY,0);
00894    // CHECK: MAYBE IS Time(5,0) instead of (Time)(5,0)
00895    _param.setT1((Time)(5,0));
00896    _param.setT1((Time)(15,0));
00897    setTimeLawType(TRAPEZOIDAL_SPEED);
00898   };
00900   TrapezoidalSpeed(TrapezoidalSpeedParam param){
00901    _s=0.0;
00902    _sp=0.0;
00903    _spp=0.0;
00904    _start=Time(0,0);
00905    _end=Time((long int)INFINITY,0);
00906    _param.setAcceleration(param.acceleration());
00907    _param.setT1(param.T1());
00908    _param.setT2(param.T2());
00909    setTimeLawType(TRAPEZOIDAL_SPEED);
00910   };
00911   
00914   TrapezoidalSpeed(const TrapezoidalSpeed& trapezoidalSpeed):TimeLaw(trapezoidalSpeed){
00915    _param=trapezoidalSpeed._param;
00916   }
00917   
00920   TrapezoidalSpeed& operator=(const TrapezoidalSpeed& trapezoidalSpeed){
00921    if (this != &trapezoidalSpeed){
00922     TimeLaw::operator=(trapezoidalSpeed);
00923     _param=trapezoidalSpeed._param;
00924    }
00925    return *this;
00926   }
00927   
00928   void inizializeS(Time time);
00929 /***************************************************************************************************
00930 ***********************************        SET FUNCTIONS         ***********************************
00931 ***************************************************************************************************/
00933   void setParam(TrapezoidalSpeedParam param){
00934    _param.setAcceleration(param.acceleration());
00935    _param.setT1(param.T1());
00936    _param.setT2(param.T2());
00937   }
00938 /***************************************************************************************************
00939 ***********************************        GET FUNCTIONS         ***********************************
00940 ***************************************************************************************************/
00942   TrapezoidalSpeedParam param(){
00943    return _param;
00944   }
00945   
00947   string print(){
00948    stringstream s;
00949    s.precision(3);
00950    s.setf(ios::fixed,ios::floatfield);
00951    s<<TimeLaw::print();
00952    s<<_param.print()<<endl;
00953    return s.str();
00954   }
00955 };
00956 
00962 class CubicSpeed :public TimeLaw{
00963  private:
00964   CubicSpeedParam _param; 
00965  public:
00967   CubicSpeed(){
00968    _s=0.0;
00969    _sp=0.0;
00970    _spp=0.0;
00971    _start=Time(0,0);
00972    _end=Time((long int)INFINITY,0);
00973    // CHECK: MAYBE IS Time(5,0) instead of (Time)(5,0)
00974    _param.setT1((Time)(5,0));
00975    _param.setT1((Time)(15,0));
00976    setTimeLawType(CUBIC_SPEED);
00977   };
00979   CubicSpeed(CubicSpeedParam param){
00980    _s=0.0;
00981    _sp=0.0;
00982    _spp=0.0;
00983    _start=Time(0,0);
00984    _end=Time((long int)INFINITY,0);
00985    _param.setAcceleration(param.acceleration());
00986    _param.setT1(param.T1());
00987    _param.setT2(param.T2());
00988    setTimeLawType(CUBIC_SPEED);
00989   };
00990   
00993   CubicSpeed(const CubicSpeed& cubicSpeed):TimeLaw(cubicSpeed){
00994    _param=cubicSpeed._param;
00995   }
00996   
00999   CubicSpeed& operator=(const CubicSpeed& cubicSpeed){
01000    if (this != &cubicSpeed){
01001     TimeLaw::operator=(cubicSpeed);
01002     _param=cubicSpeed._param;
01003    }
01004    return *this;
01005   }
01006   
01007   void inizializeS(Time time);
01008 /***************************************************************************************************
01009 ***********************************        SET FUNCTIONS         ***********************************
01010 ***************************************************************************************************/
01012   void setParam(CubicSpeedParam param){
01013    _param.setAcceleration(param.acceleration());
01014    _param.setT1(param.T1());
01015    _param.setT2(param.T2());
01016   }
01017 /***************************************************************************************************
01018 ***********************************        GET FUNCTIONS         ***********************************
01019 ***************************************************************************************************/
01021   CubicSpeedParam param(){
01022    return _param;
01023   }
01024   
01026   string print(){
01027    stringstream s;
01028    s.precision(3);
01029    s.setf(ios::fixed,ios::floatfield);
01030    s<<TimeLaw::print();
01031    s<<_param.print()<<endl;
01032    return s.str();
01033   }
01034 };
01035 
01041 class TrapezoidalAcc :public TimeLaw{
01042  private:
01043   TrapezoidalAccParam _param; 
01044  public:
01046   TrapezoidalAcc(){};
01048   TrapezoidalAcc(TrapezoidalAccParam param){
01049    _param.setAcceleration(param.acceleration());
01050    _param.setT1(param.T1());
01051    _param.setT2(param.T2());
01052    setTimeLawType(TRAPEZOIDAL_ACC);
01053   };
01054   
01057   TrapezoidalAcc(const TrapezoidalAcc& trapezoidalAcc):TimeLaw(trapezoidalAcc){
01058    _param=trapezoidalAcc._param;
01059   }
01060   
01063   TrapezoidalAcc& operator=(const TrapezoidalAcc& trapezoidalAcc){
01064    if (this != &trapezoidalAcc){
01065     TimeLaw::operator=(trapezoidalAcc);
01066     _param=trapezoidalAcc._param;
01067    }
01068    return *this;
01069   }
01070   
01071   void inizializeS(Time time);
01072 /***************************************************************************************************
01073 ***********************************        SET FUNCTIONS         ***********************************
01074 ***************************************************************************************************/
01076   void setParam(TrapezoidalAccParam param){
01077    _param.setAcceleration(param.acceleration());
01078    _param.setT1(param.T1());
01079    _param.setT2(param.T2());
01080   }
01081 /***************************************************************************************************
01082 ***********************************        GET FUNCTIONS         ***********************************
01083 ***************************************************************************************************/
01085   TrapezoidalAccParam param(){
01086    return _param;
01087   }
01088   
01090   string print(){
01091    stringstream s;
01092    s.precision(3);
01093    s.setf(ios::fixed,ios::floatfield);
01094    s<<TimeLaw::print();
01095    s<<_param.print()<<endl;
01096    return s.str();
01097   }
01098 };
01099 
01105 class TrapezoidalDec :public TimeLaw{
01106  private:
01107   TrapezoidalDecParam _param; 
01108  public:
01110   TrapezoidalDec(){};
01112   TrapezoidalDec(TrapezoidalDecParam param){
01113    _param.setAcceleration(param.acceleration());
01114    _param.setT1(param.T1());
01115    _param.setT2(param.T2());
01116    setTimeLawType(TRAPEZOIDAL_DEC);
01117   };
01118   
01121   TrapezoidalDec(const TrapezoidalDec& trapezoidalDec):TimeLaw(trapezoidalDec){
01122    _param=trapezoidalDec._param;
01123   }
01124   
01127   TrapezoidalDec& operator=(const TrapezoidalDec& trapezoidalDec){
01128    if (this != &trapezoidalDec){
01129     TimeLaw::operator=(trapezoidalDec);
01130     _param=trapezoidalDec._param;
01131    }
01132    return *this;
01133   }
01134   
01135   void inizializeS(Time time);
01136 /***************************************************************************************************
01137 ***********************************        SET FUNCTIONS         ***********************************
01138 ***************************************************************************************************/
01140   void setParam(TrapezoidalDecParam param){
01141    _param.setAcceleration(param.acceleration());
01142    _param.setT1(param.T1());
01143    _param.setT2(param.T2());
01144   }
01145 /***************************************************************************************************
01146 ***********************************        GET FUNCTIONS         ***********************************
01147 ***************************************************************************************************/
01149   TrapezoidalDecParam param(){
01150    return _param;
01151   }
01152   
01154   string print(){
01155    stringstream s;
01156    s.precision(3);
01157    s.setf(ios::fixed,ios::floatfield);
01158    s<<TimeLaw::print();
01159    s<<_param.print()<<endl;
01160    return s.str();
01161   }
01162 };
01163 
01164 }; // end of namespace
01165 #endif

Generated on Mon Feb 20 07:01:07 2017 for MIP by  doxygen 1.5.6