SCL  1.0
Standard Control Library : Control, dynamics, physics, and simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
CSensorBase.hpp
1 /* This file is part of scl, a control and simulation library
2 for robots and biomechanical models.
3 
4 scl is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8 
9 Alternatively, you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of
12 the License, or (at your option) any later version.
13 
14 scl is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU Lesser General Public
20 License and a copy of the GNU General Public License along with
21 scl. If not, see <http://www.gnu.org/licenses/>.
22  */
23 /*
24  * \file CSensorBase.hpp
25  *
26  * Created on: Aug 24, 2012
27  *
28  * Author: Samir Menon <smenon@stanford.edu>
29  */
30 
31 #ifndef CSENSORBASE_HPP_
32 #define CSENSORBASE_HPP_
33 
34 #include <scl/data_structs/SObject.hpp>
35 
36 #include <Eigen/Eigen>
37 
38 namespace scl
39 {
46  class SSensorBase : public SObject
47  {
48  public:
58 
69 
80 
91 
98 
99  SSensorBase() : SObject("SSensorBase"),
104  flag_apply_noise_(true)
105  {}
106  };
107 
118  {
119  public:
120  /* *****************************************************************
121  * Sensing Model
122  * ***************************************************************** */
126  virtual sBool setSensors(const Eigen::VectorXd& arg_sensory_input)=0;
127 
129  virtual sBool applySensorModel()=0;
130 
133  virtual sBool getSensorOutput(Eigen::VectorXd& ret_sensor_output)=0;
134 
136  virtual sBool sense(const Eigen::VectorXd& arg_sensory_input,
137  Eigen::VectorXd& ret_sensor_output)
138  {
139  bool flag=true;
140  flag = flag && setSensors(arg_sensory_input);
141  flag = flag && applySensorModel();
142  flag = flag && getSensorOutput(ret_sensor_output);
143  return flag;
144  }
145 
146  /* *****************************************************************
147  * Initialization
148  * ***************************************************************** */
150  virtual sBool init(SSensorBase* arg_state)=0;
151 
153  virtual sBool hasBeenInit()
154  {
155  if(S_NULL == state_) { return false; }
156  return state_->has_been_init_;
157  }
158 
160  CSensorBase() : state_(S_NULL) {}
161 
163  virtual ~CSensorBase() {}
164 
165  protected:
168  };
169 
170 } /* namespace scl */
171 #endif /* CSENSORBASE_HPP_ */
virtual sBool hasBeenInit()
Definition: CSensorBase.hpp:153
Definition: CSensorBase.hpp:117
SSensorBase * state_
Definition: CSensorBase.hpp:167
sBool flag_apply_temporal_jitter_
Definition: CSensorBase.hpp:68
virtual sBool init(SSensorBase *arg_state)=0
virtual sBool setSensors(const Eigen::VectorXd &arg_sensory_input)=0
virtual sBool sense(const Eigen::VectorXd &arg_sensory_input, Eigen::VectorXd &ret_sensor_output)
Definition: CSensorBase.hpp:136
virtual sBool getSensorOutput(Eigen::VectorXd &ret_sensor_output)=0
virtual ~CSensorBase()
Definition: CSensorBase.hpp:163
sBool flag_apply_temporal_limits_
Definition: CSensorBase.hpp:57
bool sBool
Definition: DataTypes.hpp:54
Definition: CSensorBase.hpp:46
sBool has_been_init_
Definition: SObject.hpp:72
sBool flag_apply_noise_
Definition: CSensorBase.hpp:97
virtual sBool applySensorModel()=0
sBool flag_apply_temporal_delay_
Definition: CSensorBase.hpp:79
CSensorBase()
Definition: CSensorBase.hpp:160
sBool flag_apply_spatial_limits_
Definition: CSensorBase.hpp:90
Definition: SObject.hpp:43