Show
Ignore:
Timestamp:
08/27/09 15:39:35 (15 years ago)
Author:
smidl
Message:

redesign of ctrl LQ control for arx

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/design/ctrlbase.h

    r565 r586  
    1212 
    1313#include "../base/bdmbase.h" 
     14#include "../estim/kalman.h" 
    1415 
    1516namespace bdm{ 
    1617 
    17 //! Base class of designers of control strategy 
    18 class Designer : public root { 
     18//! Low-level class for design of control strategy 
     19class Designer  { 
     20         
    1921        public: 
    2022                //! Redesign control strategy  
     
    3436class LQG : public Designer { 
    3537        protected: 
    36                 //! dimension of state 
    37                 int dimx; 
    38                 //! dimension of inputs 
    39                 int dimu; 
    40                 //! dimension of output 
    41                 int dimy; 
    42  
    43                 //! matrix A of the linear system 
    44                 mat A; 
    45                 //! matrix B of the linear system 
    46                 mat B; 
    47                 //! matrix C of the linear system 
    48                 mat C; 
     38                //! StateSpace model from which we read data 
     39                shared_ptr<StateSpace<fsqmat> > S; 
    4940                //! required value of the output y at time t (assumed constant) 
    5041                vec y_req; 
     42                //! required value of the output y at time t (assumed constant) 
     43                vec u_req; 
    5144                 
    5245                //! Control horizon, set to maxint for infinite horizons 
     
    6154                mat L; 
    6255                 
    63                 //!@{ \name temporary storage for ricatti 
     56                //!@{ \name temporary storage for ricatti - use initialize 
     57                //! convenience parameters 
     58                int dimx; 
     59                //! convenience parameters 
     60                int dimy; 
     61                //! convenience parameters 
     62                int dimu; 
     63                 
    6464                //!  parameters 
    6565                mat pr; 
     
    8282        public: 
    8383                //! set system parameters from given matrices 
    84                 void set_system_parameters(const mat &A, const mat &B, const mat &C); 
     84                void set_system(shared_ptr<StateSpace<fsqmat> > S0); 
    8585                //! set penalization matrices and control horizon 
    86                 void set_control_parameters(const mat &Qy0, const mat &Qu0, const vec y_req0, int horizon0); 
     86                void set_control_parameters(const mat &Qy0, const mat &Qu0, const vec &y_req0, int horizon0); 
    8787                //! set system parameters from Kalman filter 
    8888//              void set_system_parameters(const Kalman &K); 
    8989                //! refresh temporary storage - inefficient can be improved 
    90                 void prepare_qr(); 
    91                 //! function for future use which is called at each time td; Should call prepare_qr()! 
     90                void initialize(); 
     91                void validate(); 
     92                //! function for future use which is called at each time td; Should call initialize()! 
    9293                virtual void update_state(){}; 
    9394                //! redesign one step of the  
     
    113114        } ; 
    114115 
     116        //! Base class for adaptive controllers  
     117        //! The base class is however non-adaptive, method \c adapt() is empty. 
     118        //! \note advanced Controllers will probably include estimator as their internal attribute (e.g. dual controllers) 
     119        class Controller : public root { 
     120                //! identifier of the system output; 
     121                RV yrv; 
     122                //! identifier of the system input; 
     123                RV urv; 
     124                //! description of data needed for \c ctrlaction , required for automatic connection to DS 
     125                RV drv; 
     126                public: 
     127                        //! function processing new observations and adapting control strategy accordingly 
     128                        virtual void adapt(const vec &data){}; 
     129                        //! returns designed control action 
     130                        virtual vec ctrlaction(const vec &data){return vec(0);} 
     131                         
     132                        void from_setting(const Setting &set){ 
     133                                UI::get(yrv,set,"yrv",UI::optional); 
     134                                UI::get(yrv,set,"urv",UI::optional); 
     135                        } 
     136                        //! access function 
     137                        const RV& _urv() {return urv;} 
     138                        //! access function 
     139                        const RV& _yrv() {return yrv;} 
     140                        //! access function 
     141                        const RV& _drv() {return drv;} 
     142        }; 
     143                         
    115144} // namespace