bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::sensors::SensorBase Class Referenceabstract

Class for modelling sensors. A sensor is a device and has: More...

#include <sensor_base.h>

Inheritance diagram for bitsim::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
virtual std::shared_ptr< backends::SensorBackendBase > backend_ptr () const

Protected Member Functions

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

Protected Attributes

std::vector< real_t > values_
 The values last read by the sensor.
std::shared_ptr< backends::SensorBackendBase > backend_ptr_
 Pointer to backend tha actually handles the sensor.

Detailed Description

Class for modelling sensors. 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 bitsim::sensors::SensorBase::~SensorBase ( )
virtualdefault

Destructor.

◆ SensorBase()

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

Member Function Documentation

◆ backend_ptr()

◆ backend_type_str()

◆ disable()

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

Disable the sensor.

◆ enable()

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

Set the is_enabled_ flag to true.

◆ init()

◆ is_enabled()

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

Returns true if the sensor is enabled.

Returns

◆ last_read_values()

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

◆ read_values()

◆ sensor_name()

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

◆ sensor_type()

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

◆ sensor_units()

◆ set_sensor_name()

void bitsim::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

◆ backend_ptr_

std::shared_ptr<backends::SensorBackendBase> bitsim::sensors::SensorBase::backend_ptr_
protected

Pointer to backend tha actually handles the sensor.

◆ values_

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

The values last read by the sensor.


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