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

Base class for modelling sensors with different implementations. More...

#include <sensor_backend_base.h>

Inheritance diagram for bitsim::sensors::backends::SensorBackendBase:

Public Member Functions

virtual ~SensorBackendBase ()=default
 Destructor.
real_t sampling_period () const noexcept
 Returns the sampling period of the sensor.
void set_sampling_period (real_t period)
 Set the sampling period of the backend.
virtual std::vector< real_t > read_values ()=0
 Read the sensor value.
virtual std::string sensor_units () const
virtual void load_from_json (const std::string &filename)=0
 Load robot and simulation parameters from a JSON file.
uint_t n_read_values () const noexcept
std::string backend_type_str () const noexcept
 Return a string that specifies the type of the backend.
virtual void add_visual_shape (const std::unordered_map< std::string, std::any > &shape_properties)=0
 Add a visual shape for the sensor in order to be visualized with Irrlicht. Concrete classes may choose not to implement this. In this case the sensor will not be visible.
void set_chrono_body (std::shared_ptr< chrono::ChBody > body)
 Set the pointer to the body that this sensor is attached.

Protected Member Functions

 SensorBackendBase (const std::string &backend_type)
 Constructor.
void set_n_read_values (uint_t n) noexcept
 Set how many values the implementation returns.

Protected Attributes

std::shared_ptr< chrono::ChBody > body_ {nullptr}
 The body on which the sensor sits.

Detailed Description

Base class for modelling sensors with different implementations.

Constructor & Destructor Documentation

◆ ~SensorBackendBase()

virtual bitsim::sensors::backends::SensorBackendBase::~SensorBackendBase ( )
virtualdefault

Destructor.

◆ SensorBackendBase()

bitsim::sensors::backends::SensorBackendBase::SensorBackendBase ( const std::string & backend_type)
inlineprotected

Constructor.

Parameters
backend_type

Member Function Documentation

◆ add_visual_shape()

virtual void bitsim::sensors::backends::SensorBackendBase::add_visual_shape ( const std::unordered_map< std::string, std::any > & shape_properties)
pure virtual

Add a visual shape for the sensor in order to be visualized with Irrlicht. Concrete classes may choose not to implement this. In this case the sensor will not be visible.

Implemented in bitsim::sensors::backends::IMUBackendBase, bitsim::sensors::backends::InfraredBackendBase, and bitsim::sensors::backends::RangeSensorBackendBase.

◆ backend_type_str()

std::string bitsim::sensors::backends::SensorBackendBase::backend_type_str ( ) const
inlinenoexcept

Return a string that specifies the type of the backend.

Returns

◆ load_from_json()

virtual void bitsim::sensors::backends::SensorBackendBase::load_from_json ( const std::string & filename)
pure virtual

Load robot and simulation parameters from a JSON file.

This function initializes the robot and its associated Chrono simulation objects based on the contents of the provided JSON configuration file.

Typical parameters may include:

  • Physical dimensions
  • Mass and inertia properties
  • Wheel configuration
  • Simulation settings
Parameters
filenamePath to the JSON configuration file.
Exceptions
std::runtime_errorIf the file cannot be read or parsed.

Implemented in bitsim::sensors::backends::IMUBackendBase, bitsim::sensors::backends::InfraredBackendBase, and bitsim::sensors::backends::RangeSensorBackendBase.

◆ n_read_values()

uint_t bitsim::sensors::backends::SensorBackendBase::n_read_values ( ) const
inlinenoexcept
Returns
The number of values the implementation returns

◆ read_values()

◆ sampling_period()

real_t bitsim::sensors::backends::SensorBackendBase::sampling_period ( ) const
inlinenoexcept

Returns the sampling period of the sensor.

Returns

◆ sensor_units()

virtual std::string bitsim::sensors::backends::SensorBackendBase::sensor_units ( ) const
inlinevirtual
Returns
An instance of std::string representing the units the sensor readings are assumed in

Reimplemented in bitsim::sensors::backends::IMUBackendBase, bitsim::sensors::backends::InfraredBackendBase, and bitsim::sensors::backends::RangeSensorBackendBase.

◆ set_chrono_body()

void bitsim::sensors::backends::SensorBackendBase::set_chrono_body ( std::shared_ptr< chrono::ChBody > body)
inline

Set the pointer to the body that this sensor is attached.

Parameters
body

◆ set_n_read_values()

void bitsim::sensors::backends::SensorBackendBase::set_n_read_values ( uint_t n)
inlineprotectednoexcept

Set how many values the implementation returns.

◆ set_sampling_period()

void bitsim::sensors::backends::SensorBackendBase::set_sampling_period ( real_t period)
inline

Set the sampling period of the backend.

Parameters
period

Member Data Documentation

◆ body_

std::shared_ptr<chrono::ChBody> bitsim::sensors::backends::SensorBackendBase::body_ {nullptr}
protected

The body on which the sensor sits.


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