bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::actuators::backends::DCMotorBackendBase Class Referenceabstract

Base class for the implementations of a DC motor. A backend takes a target speed for the output shaft and does whatever it takes to reach it: a model of the motor, or a real motor on a board. More...

#include <dc_motor_backend_base.h>

Inheritance diagram for bitsim::actuators::backends::DCMotorBackendBase:

Public Types

enum class  OutputType { TORQUE , ANGLE }

Public Member Functions

virtual ~DCMotorBackendBase ()=default
virtual OutputType output_type () const noexcept=0
virtual void set_target_speed (real_t speed)=0
 Set the target speed of the output shaft [rad/s].
virtual void step (real_t dt)=0
 Advance the backend by dt. A model moves its own shaft.
virtual void step (real_t dt, const ShaftState &shaft)=0
 Advance the backend by dt, with the shaft moved by a physics engine. Backends with OutputType::ANGLE ignore the shaft.
virtual real_t angle () const =0
virtual real_t speed () const =0
virtual real_t encoder_angle () const
virtual real_t torque () const
virtual bool is_ready () const
const std::string & backend_type_str () const noexcept

Protected Member Functions

 DCMotorBackendBase (const std::string &backend_type)

Detailed Description

Base class for the implementations of a DC motor. A backend takes a target speed for the output shaft and does whatever it takes to reach it: a model of the motor, or a real motor on a board.

The two kinds couple to a physics engine differently. A model computes the torque the motor produces, so the engine moves the shaft (OutputType::TORQUE). A real motor has already moved, so the engine has to follow its angle (OutputType::ANGLE).

Member Enumeration Documentation

◆ OutputType

Enumerator
TORQUE 
ANGLE 

Constructor & Destructor Documentation

◆ ~DCMotorBackendBase()

virtual bitsim::actuators::backends::DCMotorBackendBase::~DCMotorBackendBase ( )
virtualdefault

◆ DCMotorBackendBase()

bitsim::actuators::backends::DCMotorBackendBase::DCMotorBackendBase ( const std::string & backend_type)
inlineexplicitprotected

Member Function Documentation

◆ angle()

virtual real_t bitsim::actuators::backends::DCMotorBackendBase::angle ( ) const
pure virtual
Returns
The angle of the output shaft [rad]

Implemented in bitsim::actuators::backends::MQTT_DCMotorBackend, and bitsim::actuators::backends::SIM_DCMotorBackend.

◆ backend_type_str()

const std::string & bitsim::actuators::backends::DCMotorBackendBase::backend_type_str ( ) const
inlinenoexcept
Returns
The type of the backend

◆ encoder_angle()

virtual real_t bitsim::actuators::backends::DCMotorBackendBase::encoder_angle ( ) const
inlinevirtual
Returns
The angle of the output shaft as its encoder measures it [rad]: in whole counts, as a board would know it. Odometry uses this. Backends without an encoder return angle()

Reimplemented in bitsim::actuators::backends::MQTT_DCMotorBackend, and bitsim::actuators::backends::SIM_DCMotorBackend.

◆ is_ready()

virtual bool bitsim::actuators::backends::DCMotorBackendBase::is_ready ( ) const
inlinevirtual
Returns
False while the backend cannot be used, for example before a board has reported

Reimplemented in bitsim::actuators::backends::MQTT_DCMotorBackend.

◆ output_type()

virtual OutputType bitsim::actuators::backends::DCMotorBackendBase::output_type ( ) const
pure virtualnoexcept
Returns
How the backend couples to a physics engine

Implemented in bitsim::actuators::backends::MQTT_DCMotorBackend, and bitsim::actuators::backends::SIM_DCMotorBackend.

◆ set_target_speed()

virtual void bitsim::actuators::backends::DCMotorBackendBase::set_target_speed ( real_t speed)
pure virtual

Set the target speed of the output shaft [rad/s].

Implemented in bitsim::actuators::backends::MQTT_DCMotorBackend, and bitsim::actuators::backends::SIM_DCMotorBackend.

◆ speed()

virtual real_t bitsim::actuators::backends::DCMotorBackendBase::speed ( ) const
pure virtual
Returns
The speed of the output shaft [rad/s]

Implemented in bitsim::actuators::backends::MQTT_DCMotorBackend, and bitsim::actuators::backends::SIM_DCMotorBackend.

◆ step() [1/2]

virtual void bitsim::actuators::backends::DCMotorBackendBase::step ( real_t dt)
pure virtual

Advance the backend by dt. A model moves its own shaft.

Implemented in bitsim::actuators::backends::MQTT_DCMotorBackend, and bitsim::actuators::backends::SIM_DCMotorBackend.

◆ step() [2/2]

virtual void bitsim::actuators::backends::DCMotorBackendBase::step ( real_t dt,
const ShaftState & shaft )
pure virtual

Advance the backend by dt, with the shaft moved by a physics engine. Backends with OutputType::ANGLE ignore the shaft.

Implemented in bitsim::actuators::backends::MQTT_DCMotorBackend, and bitsim::actuators::backends::SIM_DCMotorBackend.

◆ torque()

virtual real_t bitsim::actuators::backends::DCMotorBackendBase::torque ( ) const
inlinevirtual
Returns
The torque on the output shaft [N m]. Zero for backends that cannot know it

Reimplemented in bitsim::actuators::backends::SIM_DCMotorBackend.


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