|
bitsim
Model, simulate, estimate and control robots in C++
|
Base class for arrays of infrared reflectance sensors, such as the TCRT5000 modules that line following robots use. More...
#include <infrared_backend_base.h>


Public Types | |
| using | Position = std::array<real_t, 3> |
| The position of an element on the robot's body [m]. | |
Public Member Functions | |
| 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. | |
| virtual std::vector< real_t > | read_values ()=0 |
| Read the sensor value. | |
| 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 Member Functions | |
| 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 | |
| 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. | |
Additional Inherited Members | |
| Protected Attributes inherited from bitsim::sensors::backends::SensorBackendBase | |
| std::shared_ptr< chrono::ChBody > | body_ {nullptr} |
| The body on which the sensor sits. | |
Base class for arrays of infrared reflectance sensors, such as the TCRT5000 modules that line following robots use.
Each element shines infrared light at the floor just below it and measures how much comes back. White paper reflects most of it and a black line very little, so the elements tell the colour of the floor under them. A backend reads one value per element: the reflectance, from 0 for black to 1 for white.
| using bitsim::sensors::backends::InfraredBackendBase::Position = std::array<real_t, 3> |
The position of an element on the robot's body [m].
|
inlineexplicitprotected |
|
overridevirtual |
Draw each element as a small box on the body. The properties are x_length, y_length, z_length (float_t) and chrono::ChColor.
Implements bitsim::sensors::backends::SensorBackendBase.
|
static |
Create a backend by the name a robot file gives it.
| backend_type | SIMULATION (or CHRONO) for elements simulated with Chrono, MQTT for real elements on a board |
| std::runtime_error | If the type is unknown, or bitsim was built without what the backend needs |
|
inlinenoexcept |
|
virtual |
Read the settings of the sensor from its section of a robot or sensor file:
Backends read their own keys as well
Reimplemented in bitsim::sensors::backends::MQTT_InfraredBackend.
|
overridevirtual |
Read the settings from a JSON file, see load().
Implements bitsim::sensors::backends::SensorBackendBase.
|
inlinenoexcept |
|
inlineoverridevirtual |
Reimplemented from bitsim::sensors::backends::SensorBackendBase.
| void bitsim::sensors::backends::InfraredBackendBase::set_elements | ( | const std::vector< Position > & | elements | ) |
Set the positions of the elements on the body. One value is read per element.