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

Simulated infrared reflectance elements on a Chrono body. More...

#include <chrono_infrared_backend.h>

Inheritance diagram for bitsim::sensors::backends::CHRONO_InfraredBackend:
Collaboration diagram for bitsim::sensors::backends::CHRONO_InfraredBackend:

Public Types

using Floor = std::function<real_t(real_t x, real_t y)>
 The reflectance of the floor at a point of the world, in [0, 1].
Public Types inherited from bitsim::sensors::backends::InfraredBackendBase
using Position = std::array<real_t, 3>
 The position of an element on the robot's body [m].

Public Member Functions

 CHRONO_InfraredBackend ()
 Constructor. Attach a body with set_chrono_body() and a floor with set_floor() before reading.
 CHRONO_InfraredBackend (std::shared_ptr< chrono::ChBody > body, Floor floor)
void set_floor (Floor floor)
 Set the floor the elements look at.
bool has_floor () const noexcept
std::vector< real_t > read_values () override
 Read the floor under each element.
Public Member Functions inherited from bitsim::sensors::backends::InfraredBackendBase
const std::vector< Position > & elements () const noexcept
void set_elements (const std::vector< Position > &elements)
 Set the positions of the elements on the body. One value is read per element.
uint_t n_elements () const noexcept
std::string sensor_units () const override
virtual void load (const nlohmann::json &j)
 Read the settings of the sensor from its section of a robot or sensor file:
void load_from_json (const std::string &filename) override
 Read the settings from a JSON file, see load().
void add_visual_shape (const std::unordered_map< std::string, std::any > &shape_properties) override
 Draw each element as a small box on the body. The properties are x_length, y_length, z_length (float_t) and chrono::ChColor.
Public Member Functions inherited from bitsim::sensors::backends::SensorBackendBase
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.
uint_t n_read_values () const noexcept
std::string backend_type_str () const noexcept
 Return a string that specifies the type of the backend.
void set_chrono_body (std::shared_ptr< chrono::ChBody > body)
 Set the pointer to the body that this sensor is attached.

Static Public Attributes

static const std::string BACKEND_TYPE = "SIMULATION"

Additional Inherited Members

Static Public Member Functions inherited from bitsim::sensors::backends::InfraredBackendBase
static std::shared_ptr< InfraredBackendBase > create (const std::string &backend_type)
 Create a backend by the name a robot file gives it.
Protected Member Functions inherited from bitsim::sensors::backends::InfraredBackendBase
 InfraredBackendBase (const std::string &backend_type)
Protected Member Functions inherited from bitsim::sensors::backends::SensorBackendBase
 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 inherited from bitsim::sensors::backends::SensorBackendBase
std::shared_ptr< chrono::ChBody > body_ {nullptr}
 The body on which the sensor sits.

Detailed Description

Simulated infrared reflectance elements on a Chrono body.

The floor is a function that gives its reflectance at each point (x, y) of the world, from 0 for black to 1 for white; for a floor that is an image, see sensors::FloorImage::reflectance. Each element reads the floor straight below it, where the body carries it now.

Member Typedef Documentation

◆ Floor

The reflectance of the floor at a point of the world, in [0, 1].

Constructor & Destructor Documentation

◆ CHRONO_InfraredBackend() [1/2]

bitsim::sensors::backends::CHRONO_InfraredBackend::CHRONO_InfraredBackend ( )

Constructor. Attach a body with set_chrono_body() and a floor with set_floor() before reading.

◆ CHRONO_InfraredBackend() [2/2]

bitsim::sensors::backends::CHRONO_InfraredBackend::CHRONO_InfraredBackend ( std::shared_ptr< chrono::ChBody > body,
Floor floor )

Member Function Documentation

◆ has_floor()

bool bitsim::sensors::backends::CHRONO_InfraredBackend::has_floor ( ) const
inlinenoexcept

◆ read_values()

std::vector< real_t > bitsim::sensors::backends::CHRONO_InfraredBackend::read_values ( )
overridevirtual

Read the floor under each element.

Returns
One value per element, in [0, 1]
Exceptions
std::logic_errorIf there is no body or no floor

Implements bitsim::sensors::backends::SensorBackendBase.

◆ set_floor()

void bitsim::sensors::backends::CHRONO_InfraredBackend::set_floor ( Floor floor)
inline

Set the floor the elements look at.

Member Data Documentation

◆ BACKEND_TYPE

const std::string bitsim::sensors::backends::CHRONO_InfraredBackend::BACKEND_TYPE = "SIMULATION"
static

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