|
bitsim
Model, simulate, estimate and control robots in C++
|
A real IMU on a board that publishes its readings over MQTT, as an IMUMessage: More...
#include <mqtt_imu_backend.h>


Public Member Functions | |
| MQTT_IMUBackend () | |
| A backend that subscribes on its own, see connect(). Give it a topic with set_channel_config() or load(). | |
| MQTT_IMUBackend (const MQTT_SensorChannel::Config &config) | |
| MQTT_IMUBackend (network::MqttSubscriber &subscriber) | |
| A backend that reads a subscriber the application connected. The subscriber must outlive the backend. | |
| void | load (const nlohmann::json &j) override |
| Read the settings, see IMUBackendBase::load(). Also reads broker, topic and timeout [s], all optional. | |
| void | set_channel_config (const MQTT_SensorChannel::Config &config) |
| void | connect () |
| Connect to the broker, unless the subscriber already is. | |
| std::vector< real_t > | read_values () override |
| Take the readings that have arrived. | |
| bool | receive (const std::string &text) |
| Take one message, as read_values() does for each message that arrives. Use it to feed the backend without a broker. | |
| bool | is_alive () const |
| const MQTT_SensorChannel & | channel () const noexcept |
| const IMUMessage & | last_value_read () const noexcept |
| Public Member Functions inherited from bitsim::sensors::backends::IMUBackendBase | |
| const Position & | position () const noexcept |
| void | set_position (const Position &position) noexcept |
| std::string | sensor_units () const override |
| 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 the IMU 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 = "MQTT" |
Additional Inherited Members | |
| Public Types inherited from bitsim::sensors::backends::IMUBackendBase | |
| using | Position = std::array<real_t, 3> |
| Static Public Member Functions inherited from bitsim::sensors::backends::IMUBackendBase | |
| static std::shared_ptr< IMUBackendBase > | 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::IMUBackendBase | |
| IMUBackendBase (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. | |
A real IMU on a board that publishes its readings over MQTT, as an IMUMessage:
read_values() never waits for the board. It takes every message that has arrived and reports the latest. Until the first reading arrives it reports zeros, so check is_alive() before trusting a reading.
| bitsim::sensors::backends::MQTT_IMUBackend::MQTT_IMUBackend | ( | ) |
A backend that subscribes on its own, see connect(). Give it a topic with set_channel_config() or load().
|
explicit |
|
explicit |
A backend that reads a subscriber the application connected. The subscriber must outlive the backend.
|
inlinenoexcept |
|
inline |
Connect to the broker, unless the subscriber already is.
|
inline |
|
inlinenoexcept |
|
overridevirtual |
Read the settings, see IMUBackendBase::load(). Also reads broker, topic and timeout [s], all optional.
Reimplemented from bitsim::sensors::backends::IMUBackendBase.
|
overridevirtual |
Take the readings that have arrived.
| std::logic_error | If the backend is not connected |
Implements bitsim::sensors::backends::SensorBackendBase.
| bool bitsim::sensors::backends::MQTT_IMUBackend::receive | ( | const std::string & | text | ) |
Take one message, as read_values() does for each message that arrives. Use it to feed the backend without a broker.
|
inline |
|
static |