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

A model of a DC gear motor, its encoder and its speed controller. More...

#include <sim_dc_motor_backend.h>

Inheritance diagram for bitsim::actuators::backends::SIM_DCMotorBackend:
Collaboration diagram for bitsim::actuators::backends::SIM_DCMotorBackend:

Public Member Functions

 SIM_DCMotorBackend (const DCMotorParameters &parameters=DCMotorParameters())
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 &shaft) 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 torque () const override
void set_load_torque (real_t torque) noexcept
 The load on the output shaft when the motor moves its own rotor [N m]. It opposes positive rotation.
real_t encoder_angle () const override
real_t measured_speed () const noexcept
real_t current () const noexcept
real_t voltage () const noexcept
real_t target_speed () const noexcept
const DCMotorParameters & parameters () const noexcept
Public Member Functions inherited from bitsim::actuators::backends::DCMotorBackendBase
virtual ~DCMotorBackendBase ()=default
virtual bool is_ready () const
const std::string & backend_type_str () const noexcept

Static Public Attributes

static const std::string BACKEND_TYPE = "SIMULATION"

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)

Detailed Description

A model of a DC gear motor, its encoder and its speed controller.

The electrical part is \( L \, di/dt = V - R i - K_e \omega_r \), with the rotor speed \( \omega_r = N \omega \). The motor puts the torque \( N K_e i \) on the output shaft. The controller runs every control_period: it measures the speed from the encoder counts, filters it, and sets the duty cycle of the voltage with a PI controller and a back-EMF feedforward, as a board would.

step(dt) moves the rotor with its own inertia and an optional load torque. step(dt, shaft) takes the shaft from a physics engine instead, which then applies torque() to it.

Constructor & Destructor Documentation

◆ SIM_DCMotorBackend()

bitsim::actuators::backends::SIM_DCMotorBackend::SIM_DCMotorBackend ( const DCMotorParameters & parameters = DCMotorParameters())
explicit

Member Function Documentation

◆ angle()

real_t bitsim::actuators::backends::SIM_DCMotorBackend::angle ( ) const
inlineoverridevirtual
Returns
The angle of the output shaft [rad]

Implements bitsim::actuators::backends::DCMotorBackendBase.

◆ current()

real_t bitsim::actuators::backends::SIM_DCMotorBackend::current ( ) const
inlinenoexcept

◆ encoder_angle()

real_t bitsim::actuators::backends::SIM_DCMotorBackend::encoder_angle ( ) const
overridevirtual
Returns
The angle as the encoder measures it [rad]

Reimplemented from bitsim::actuators::backends::DCMotorBackendBase.

◆ measured_speed()

real_t bitsim::actuators::backends::SIM_DCMotorBackend::measured_speed ( ) const
inlinenoexcept
Returns
The speed as the controller measures it [rad/s]

◆ output_type()

OutputType bitsim::actuators::backends::SIM_DCMotorBackend::output_type ( ) const
inlineoverridevirtualnoexcept
Returns
How the backend couples to a physics engine

Implements bitsim::actuators::backends::DCMotorBackendBase.

◆ parameters()

const DCMotorParameters & bitsim::actuators::backends::SIM_DCMotorBackend::parameters ( ) const
inlinenoexcept

◆ set_load_torque()

void bitsim::actuators::backends::SIM_DCMotorBackend::set_load_torque ( real_t torque)
inlinenoexcept

The load on the output shaft when the motor moves its own rotor [N m]. It opposes positive rotation.

◆ set_target_speed()

void bitsim::actuators::backends::SIM_DCMotorBackend::set_target_speed ( real_t speed)
inlineoverridevirtual

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

Implements bitsim::actuators::backends::DCMotorBackendBase.

◆ speed()

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

Implements bitsim::actuators::backends::DCMotorBackendBase.

◆ step() [1/2]

void bitsim::actuators::backends::SIM_DCMotorBackend::step ( real_t dt)
overridevirtual

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

Implements bitsim::actuators::backends::DCMotorBackendBase.

◆ step() [2/2]

void bitsim::actuators::backends::SIM_DCMotorBackend::step ( real_t dt,
const ShaftState & shaft )
overridevirtual

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.

◆ target_speed()

real_t bitsim::actuators::backends::SIM_DCMotorBackend::target_speed ( ) const
inlinenoexcept

◆ torque()

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

Reimplemented from bitsim::actuators::backends::DCMotorBackendBase.

◆ voltage()

real_t bitsim::actuators::backends::SIM_DCMotorBackend::voltage ( ) const
inlinenoexcept

Member Data Documentation

◆ BACKEND_TYPE

const std::string bitsim::actuators::backends::SIM_DCMotorBackend::BACKEND_TYPE = "SIMULATION"
static

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