bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
sensor_backend_base.h
Go to the documentation of this file.
1#ifndef SENSOR_BACKEND_BASE_H
2#define SENSOR_BACKEND_BASE_H
3
4#include "bitrl/bitrl_types.h"
6#include <string>
7#include <vector>
8
9
10namespace bitrl
11{
12namespace sensors::backends
13{
14
22{
23public:
27 virtual ~SensorBackendBase()=default;
28
33 real_t sampling_period()const noexcept {return sampling_period_;}
34
39 void set_sampling_period(real_t period){sampling_period_ = period;}
40
45 virtual std::vector<real_t> read_values()=0;
46
51 virtual std::string sensor_units()const{return bitrl::consts::INVALID_STR;}
52
70 virtual void load_from_json(const std::string& filename)=0;
71
75 uint_t n_read_values()const noexcept{return n_read_values_;}
76
81 std::string backend_type_str()const noexcept{return backend_type_;}
82
83protected:
88 SensorBackendBase(const std::string& backend_type);
89
90private:
91
95 const std::string backend_type_;
96
97
101 real_t sampling_period_{0.0};
102
106 uint_t n_read_values_{1};
107
108
109};
110
111inline
112SensorBackendBase::SensorBackendBase(const std::string& backend_type)
113 :
114backend_type_(backend_type)
115{}
116
117}
118}
119
120#endif //SENSOR_BACKEND_BASE_H
Base class for modelling sensors with different implementations.
Definition sensor_backend_base.h:22
void set_sampling_period(real_t period)
Set the sampling period of the backend.
Definition sensor_backend_base.h:39
virtual ~SensorBackendBase()=default
Destructor.
uint_t n_read_values() const noexcept
Definition sensor_backend_base.h:75
virtual std::vector< real_t > read_values()=0
Read the sensor value.
SensorBackendBase(const std::string &backend_type)
Constructor.
Definition sensor_backend_base.h:112
std::string backend_type_str() const noexcept
Definition sensor_backend_base.h:81
virtual void load_from_json(const std::string &filename)=0
Load robot and simulation parameters from a JSON file.
real_t sampling_period() const noexcept
Returns the sampling period of the sensor.
Definition sensor_backend_base.h:33
virtual std::string sensor_units() const
Definition sensor_backend_base.h:51
const std::string INVALID_STR
Invalid string.
Definition bitrl_consts.h:26
Definition bitrl_consts.h:14
double real_t
real_t
Definition bitrl_types.h:23
std::size_t uint_t
uint_t
Definition bitrl_types.h:43