|
bitsim
Model, simulate, estimate and control robots in C++
|
A real DC motor on a board. The target speed goes to the board, and the angle comes back from its encoder. More...
#include <mqtt_dc_motor_backend.h>


Public Member Functions | |
| MQTT_DCMotorBackend (std::shared_ptr< boards::DCMotorBoardBase > board, uint_t channel, real_t bandwidth=30.0) | |
| OutputType | output_type () const noexcept override |
| void | set_target_speed (real_t speed) override |
| Set the target speed of the output shaft [rad/s]. | |
| void | step (real_t dt) override |
| Advance the backend by dt. A model moves its own shaft. | |
| void | step (real_t dt, const ShaftState &) override |
| Advance the backend by dt, with the shaft moved by a physics engine. Backends with OutputType::ANGLE ignore the shaft. | |
| real_t | angle () const override |
| real_t | speed () const override |
| real_t | encoder_angle () const override |
| bool | is_ready () const override |
| real_t | reported_angle () const noexcept |
| real_t | reported_speed () const noexcept |
| std::shared_ptr< boards::DCMotorBoardBase > | board () const noexcept |
| uint_t | channel () const noexcept |
| Public Member Functions inherited from bitsim::actuators::backends::DCMotorBackendBase | |
| virtual | ~DCMotorBackendBase ()=default |
| virtual real_t | torque () const |
| const std::string & | backend_type_str () const noexcept |
Static Public Attributes | |
| static const std::string | BACKEND_TYPE = "MQTT" |
Additional Inherited Members | |
| Public Types inherited from bitsim::actuators::backends::DCMotorBackendBase | |
| enum class | OutputType { TORQUE , ANGLE } |
| Protected Member Functions inherited from bitsim::actuators::backends::DCMotorBackendBase | |
| DCMotorBackendBase (const std::string &backend_type) | |
A real DC motor on a board. The target speed goes to the board, and the angle comes back from its encoder.
The board reports every few tens of milliseconds, while a simulation steps every millisecond or two. In between, the backend predicts the angle from the last report and the speed. A physics engine that follows the angle differentiates it twice, so every correction of the prediction would show up as a spike of torque. So angle() is a smooth estimate instead: a second-order filter pulled towards the predicted angle and the reported speed.
Angles are counted from the first report, so the shaft starts at zero.
| bitsim::actuators::backends::MQTT_DCMotorBackend::MQTT_DCMotorBackend | ( | std::shared_ptr< boards::DCMotorBoardBase > | board, |
| uint_t | channel, | ||
| real_t | bandwidth = 30.0 ) |
| board | The board the motor is on. Several motors share a board |
| channel | The motor on the board |
| bandwidth | The bandwidth of the estimate [rad/s] |
|
inlineoverridevirtual |
Implements bitsim::actuators::backends::DCMotorBackendBase.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineoverridevirtual |
Reimplemented from bitsim::actuators::backends::DCMotorBackendBase.
|
overridevirtual |
Reimplemented from bitsim::actuators::backends::DCMotorBackendBase.
|
inlineoverridevirtualnoexcept |
Implements bitsim::actuators::backends::DCMotorBackendBase.
|
inlinenoexcept |
|
inlinenoexcept |
|
overridevirtual |
Set the target speed of the output shaft [rad/s].
Implements bitsim::actuators::backends::DCMotorBackendBase.
|
inlineoverridevirtual |
Implements bitsim::actuators::backends::DCMotorBackendBase.
|
overridevirtual |
Advance the backend by dt. A model moves its own shaft.
Implements bitsim::actuators::backends::DCMotorBackendBase.
|
inlineoverridevirtual |
Advance the backend by dt, with the shaft moved by a physics engine. Backends with OutputType::ANGLE ignore the shaft.
Implements bitsim::actuators::backends::DCMotorBackendBase.
|
static |