bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
ultrasonic_sensor.h
Go to the documentation of this file.
1#ifndef ULTRASONIC_SENSOR_H
2#define ULTRASONIC_SENSOR_H
3
4#include "bitrl/bitrl_types.h"
7
8#include <memory>
9#include <vector>
10
11namespace bitrl
12{
13namespace sensors
14{
20class UltrasonicSensor final: public SensorBase
21{
22public:
23
27 static const std::string SENSOR_TYPE;
28
33 explicit UltrasonicSensor(std::shared_ptr<bitrl::sensors::backends::RangeSensorBackendBase> backend,
34 const std::string name = bitrl::consts::INVALID_STR);
35
40 virtual void init();
41
46 virtual const std::vector<real_t>& read_values();
47
52 virtual std::string backend_type_str()const;
53
58 virtual std::string sensor_units()const;
59
60private:
64 std::shared_ptr<bitrl::sensors::backends::RangeSensorBackendBase> backend_;
65
66};
67
68inline UltrasonicSensor::UltrasonicSensor(std::shared_ptr<bitrl::sensors::backends::RangeSensorBackendBase> backend,
69 const std::string name)
70 :
71SensorBase(UltrasonicSensor::SENSOR_TYPE, name),
72backend_(backend)
73{}
74
75inline
76std::string UltrasonicSensor::backend_type_str()const{return backend_ -> backend_type_str();}
77
78inline
79std::string UltrasonicSensor::sensor_units()const{return backend_ -> sensor_units();}
80
81
82}
83}
84
85#endif //ULTRASONIC_SENSOR_H
Class for modelling sensors. The interface follows closely the interface exposed by Webots see: https...
Definition sensor_base.h:28
Class for modelling ultrasonic sensors.
Definition ultrasonic_sensor.h:21
UltrasonicSensor(std::shared_ptr< bitrl::sensors::backends::RangeSensorBackendBase > backend, const std::string name=bitrl::consts::INVALID_STR)
Constructor.
Definition ultrasonic_sensor.h:68
virtual std::string backend_type_str() const
Definition ultrasonic_sensor.h:76
virtual const std::vector< real_t > & read_values()
Reads the sensor values and updates the values held internally.
Definition ultrasonic_sensor.cpp:24
virtual void init()
Initialize the sensor. Set the is is_enabled_ flag to true. and performs any other initializations re...
Definition ultrasonic_sensor.cpp:17
static const std::string SENSOR_TYPE
The type of the sensor.
Definition ultrasonic_sensor.h:27
virtual std::string sensor_units() const
Definition ultrasonic_sensor.h:79
const std::string INVALID_STR
Invalid string.
Definition bitrl_consts.h:26
Definition bitrl_consts.h:14