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

Class for modelling ultrasonic sensors. More...

#include <ultrasonic_sensor.h>

Inheritance diagram for bitsim::sensors::UltrasonicSensor:
Collaboration diagram for bitsim::sensors::UltrasonicSensor:

Public Member Functions

 UltrasonicSensor (std::shared_ptr< bitsim::sensors::backends::RangeSensorBackendBase > backend, const std::string name=bitsim::consts::INVALID_STR)
 Constructor.
virtual void init ()
 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 ()
 Reads the sensor values and updates the values held internally.
virtual std::string backend_type_str () const
virtual std::string sensor_units () const
virtual std::shared_ptr< backends::SensorBackendBase > backend_ptr () const override
std::shared_ptr< backends::RangeSensorBackendBase > range_backend () const noexcept
real_t distance () const
Public Member Functions inherited from bitsim::sensors::SensorBase
virtual ~SensorBase ()=default
 Destructor.
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

Static Public Member Functions

static std::shared_ptr< UltrasonicSensor > create (const std::string &backend_type, const std::string &name)

Static Public Attributes

static const std::string SENSOR_TYPE = "UltrasonicSensor"
 The type of the sensor.

Additional Inherited Members

Protected Member Functions inherited from bitsim::sensors::SensorBase
 SensorBase (const std::string &sensor_type, const std::string &sensor_name=bitsim::consts::INVALID_STR)
Protected Attributes inherited from bitsim::sensors::SensorBase
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 ultrasonic sensors.

Constructor & Destructor Documentation

◆ UltrasonicSensor()

bitsim::sensors::UltrasonicSensor::UltrasonicSensor ( std::shared_ptr< bitsim::sensors::backends::RangeSensorBackendBase > backend,
const std::string name = bitsim::consts::INVALID_STR )
inlineexplicit

Constructor.

Parameters
backendThe backend that measures the range
nameThe name of the sensor

Member Function Documentation

◆ backend_ptr()

virtual std::shared_ptr< backends::SensorBackendBase > bitsim::sensors::UltrasonicSensor::backend_ptr ( ) const
inlineoverridevirtual

Reimplemented from bitsim::sensors::SensorBase.

◆ backend_type_str()

std::string bitsim::sensors::UltrasonicSensor::backend_type_str ( ) const
inlinevirtual
Returns
An instance of std::string of the backend type. If the implementation does not use a specific backend returns bitsim::consts::INVALID_STR

Implements bitsim::sensors::SensorBase.

◆ create()

std::shared_ptr< UltrasonicSensor > bitsim::sensors::UltrasonicSensor::create ( const std::string & backend_type,
const std::string & name )
static
Parameters
backend_type
name
Returns

◆ distance()

real_t bitsim::sensors::UltrasonicSensor::distance ( ) const
inline
Returns
The distance read last [m]

◆ init()

void bitsim::sensors::UltrasonicSensor::init ( )
virtual

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

Implements bitsim::sensors::SensorBase.

◆ range_backend()

std::shared_ptr< backends::RangeSensorBackendBase > bitsim::sensors::UltrasonicSensor::range_backend ( ) const
inlinenoexcept
Returns
The backend, with the range of the sensor

◆ read_values()

const std::vector< real_t > & bitsim::sensors::UltrasonicSensor::read_values ( )
virtual

Reads the sensor values and updates the values held internally.

Returns
An instance of str::vector<real_t>

Implements bitsim::sensors::SensorBase.

◆ sensor_units()

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

Implements bitsim::sensors::SensorBase.

Member Data Documentation

◆ SENSOR_TYPE

const std::string bitsim::sensors::UltrasonicSensor::SENSOR_TYPE = "UltrasonicSensor"
static

The type of the sensor.


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