|
bitsim
Model, simulate, estimate and control robots in C++
|
An array of infrared reflectance elements that looks at the floor, to tell its colour: light paper or a dark line. More...
#include <infrared_sensor.h>


Public Member Functions | |
| InfraredSensor (std::shared_ptr< backends::InfraredBackendBase > backend, const std::string &name=consts::INVALID_STR) | |
| void | init () override |
| Enable the sensor, with every element reading white until the first read. | |
| const std::vector< real_t > & | read_values () override |
| Read the backend, if the sensor is enabled. | |
| std::string | backend_type_str () const override |
| std::string | sensor_units () const override |
| std::shared_ptr< backends::SensorBackendBase > | backend_ptr () const override |
| std::shared_ptr< backends::InfraredBackendBase > | infrared_backend () const noexcept |
| uint_t | n_elements () const noexcept |
| std::optional< std::array< real_t, 2 > > | line_position () const |
| std::string | pattern () const |
| real_t | threshold () const noexcept |
| Reflectances below this are dark. | |
| void | set_threshold (real_t threshold) |
| bool | is_dark (uint_t i) 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< InfraredSensor > | create (const std::string &backend_type, const std::string &name) |
| A sensor with a new backend of the given type, see backends::InfraredBackendBase::create. | |
Static Public Attributes | |
| static const std::string | SENSOR_TYPE = "InfraredSensor" |
| 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. | |
An array of infrared reflectance elements that looks at the floor, to tell its colour: light paper or a dark line.
read_values() gives the reflectance under each element, from 0 for black to 1 for white. An element whose reflectance is below threshold() is over something dark; see is_dark(). Where the values come from is up to the backend: backends::CHRONO_InfraredBackend simulates the elements, and backends::MQTT_InfraredBackend reads real ones on a board.
|
explicit |
|
inlineoverridevirtual |
Reimplemented from bitsim::sensors::SensorBase.
|
inlineoverridevirtual |
Implements bitsim::sensors::SensorBase.
|
static |
A sensor with a new backend of the given type, see backends::InfraredBackendBase::create.
|
inlinenoexcept |
|
overridevirtual |
Enable the sensor, with every element reading white until the first read.
Implements bitsim::sensors::SensorBase.
| bool bitsim::sensors::InfraredSensor::is_dark | ( | uint_t | i | ) | const |
| std::optional< std::array< real_t, 2 > > bitsim::sensors::InfraredSensor::line_position | ( | ) | const |
|
inlinenoexcept |
| std::string bitsim::sensors::InfraredSensor::pattern | ( | ) | const |
|
overridevirtual |
Read the backend, if the sensor is enabled.
Implements bitsim::sensors::SensorBase.
|
inlineoverridevirtual |
Implements bitsim::sensors::SensorBase.
| void bitsim::sensors::InfraredSensor::set_threshold | ( | real_t | threshold | ) |
|
inlinenoexcept |
Reflectances below this are dark.
|
static |
The type of the sensor.