1 /* Siconos is a program dedicated to modeling, simulation and control 2 * of non smooth dynamical systems. 3 * 4 * Copyright 2021 INRIA. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 /*! \file SlidingReducedOrderObserver.hpp 20 \brief Discrete-time Sliding Observer 21 */ 22 23 #ifndef SlidingReducedOrderObserver_H 24 #define SlidingReducedOrderObserver_H 25 26 #include "Observer.hpp" 27 #include "SiconosAlgebraTypeDef.hpp" 28 29 class SlidingReducedOrderObserver : public Observer 30 { 31 private: 32 /** serialization hooks */ 33 ACCEPT_SERIALIZATION(SlidingReducedOrderObserver); 34 35 /** default constructor */ SlidingReducedOrderObserver()36 SlidingReducedOrderObserver() {}; 37 38 protected: 39 40 /** the vector defining the measurements (\f$ y = Cx \f$) */ 41 SP::SimpleMatrix _C; 42 43 /** matrix multiplying the innovation term */ 44 SP::SimpleMatrix _L; 45 46 double _theta; 47 48 // clumsy hack to do nothing the first time this Observer is called 49 bool _pass; 50 51 public: 52 53 /** Constructor with the standard interface 54 * \param sensor the SP::ControlSensor that feed us with measurements 55 * \param xHat0 the initial guess for the state 56 */ SlidingReducedOrderObserver(SP::ControlSensor sensor,const SiconosVector & xHat0)57 SlidingReducedOrderObserver(SP::ControlSensor sensor, const SiconosVector& xHat0): 58 Observer(SLIDING_REDUCED_ORDER, sensor, xHat0), _pass(false) {} 59 60 /** Constructor with all the data 61 * \param sensor the sensor that feeds the Observer 62 * \param xHat0 the initial guess for the state 63 * \param C observation matrix 64 * \param L gain matrix 65 */ SlidingReducedOrderObserver(SP::ControlSensor sensor,const SiconosVector & xHat0,SP::SimpleMatrix C,SP::SimpleMatrix L)66 SlidingReducedOrderObserver(SP::ControlSensor sensor, const SiconosVector& xHat0, SP::SimpleMatrix C, SP::SimpleMatrix L): 67 Observer(SLIDING_REDUCED_ORDER, sensor, xHat0), _C(C), _L(L), _pass(false) {} 68 69 /** Update the estimate at each event 70 */ 71 virtual void process(); 72 73 /** Initialization 74 * \param nsds current nonsmooth dynamical system 75 * \param s current simulation setup 76 */ 77 virtual void initialize(const NonSmoothDynamicalSystem& nsds, const Simulation& s); 78 79 /** Set the L matrix 80 * \param L the new L matrix 81 */ setLPtr(SP::SimpleMatrix L)82 inline void setLPtr(SP::SimpleMatrix L) 83 { 84 _L = L; 85 }; 86 87 /** Set the C matrix 88 * \param C the new C matrix 89 */ setCPtr(SP::SimpleMatrix C)90 inline void setCPtr(SP::SimpleMatrix C) 91 { 92 _C = C; 93 }; 94 95 }; 96 #endif 97