bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
bitrl::sensors::SensorBase Class Referenceabstract

Class for modelling sensors. The interface follows closely the interface exposed by Webots see: https://cyberbotics.com/doc/guide/sensors In this token a Sensor is a Device and has: More...

#include <sensor_base.h>

Inheritance diagram for bitrl::sensors::SensorBase:

Public Member Functions

virtual ~SensorBase ()=default
 Destructor.
 
virtual void init ()=0
 Initialize the sensor. Set the is is_enabled_ flag to true. and performs any other initializations required by the sensor.
 
virtual const std::vector< real_t > & read_values ()=0
 
virtual std::string backend_type_str () const =0
 
virtual std::string sensor_units () const =0
 
bool is_enabled () const noexcept
 Returns true if the sensor is enabled.
 
void enable () noexcept
 Set the is_enabled_ flag to true.
 
void disable () noexcept
 Disable the sensor.
 
const std::vector< real_t > & last_read_values () const noexcept
 
std::string sensor_name () const noexcept
 
void set_sensor_name (const std::string &sensor_name) noexcept
 Set the sensor name.
 
std::string sensor_type () const noexcept
 

Protected Member Functions

 SensorBase (const std::string &sensor_type, const std::string &sensor_name=bitrl::consts::INVALID_STR)
 

Protected Attributes

std::vector< real_tvalues_
 The values last read by the sensor.
 

Detailed Description

Class for modelling sensors. The interface follows closely the interface exposed by Webots see: https://cyberbotics.com/doc/guide/sensors In this token a Sensor is a Device and has:

  • sampling period
  • enabled/disabled
  • Last value
  • Sensor units Implementations can utilize noise and resolution.

Constructor & Destructor Documentation

◆ ~SensorBase()

virtual bitrl::sensors::SensorBase::~SensorBase ( )
virtualdefault

Destructor.

◆ SensorBase()

bitrl::sensors::SensorBase::SensorBase ( const std::string &  sensor_type,
const std::string &  sensor_name = bitrl::consts::INVALID_STR 
)
inlineexplicitprotected
Parameters
sensor_typeThe type of the sensor

Member Function Documentation

◆ backend_type_str()

std::string bitrl::sensors::SensorBase::backend_type_str ( ) const
pure virtual
Returns
An instance of std::string of the backend type. If the implementation does not use a specific backend returns bitrl::consts::INVALID_STR

Implemented in bitrl::sensors::UltrasonicSensor.

◆ disable()

void bitrl::sensors::SensorBase::disable ( )
inlinenoexcept

Disable the sensor.

◆ enable()

void bitrl::sensors::SensorBase::enable ( )
inlinenoexcept

Set the is_enabled_ flag to true.

◆ init()

virtual void bitrl::sensors::SensorBase::init ( )
pure virtual

Initialize the sensor. Set the is is_enabled_ flag to true. and performs any other initializations required by the sensor.

Implemented in bitrl::sensors::UltrasonicSensor.

◆ is_enabled()

bool bitrl::sensors::SensorBase::is_enabled ( ) const
inlinenoexcept

Returns true if the sensor is enabled.

Returns

◆ last_read_values()

const std::vector< real_t > & bitrl::sensors::SensorBase::last_read_values ( ) const
inlinenoexcept
Returns
Read reference to the last values read by the sensor

◆ read_values()

virtual const std::vector< real_t > & bitrl::sensors::SensorBase::read_values ( )
pure virtual
Returns
Reads the sensor values and updates the values held internally

Implemented in bitrl::sensors::UltrasonicSensor.

◆ sensor_name()

std::string bitrl::sensors::SensorBase::sensor_name ( ) const
inlinenoexcept
Returns
An instance of std::string with the name of the sensor

◆ sensor_type()

std::string bitrl::sensors::SensorBase::sensor_type ( ) const
inlinenoexcept
Returns
An instance of std::string with the type of the sensor

◆ sensor_units()

std::string bitrl::sensors::SensorBase::sensor_units ( ) const
pure virtual
Returns
An instance of std::string indicating the units the sensor is using. If units have not been established this returns bitrl::consts::INVALID_STR

Implemented in bitrl::sensors::UltrasonicSensor.

◆ set_sensor_name()

void bitrl::sensors::SensorBase::set_sensor_name ( const std::string &  sensor_name)
inlinenoexcept

Set the sensor name.

Parameters
sensor_nameThe sensor name to set

Member Data Documentation

◆ values_

std::vector<real_t> bitrl::sensors::SensorBase::values_
protected

The values last read by the sensor.


The documentation for this class was generated from the following files: