bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
real_dc_motors::DCMotor Class Reference

A DC motor with an encoder, run in speed control. The application sets the target speed of the output shaft and reads back its angle and speed. The backend decides what the motor is: More...

#include <dc_motor.h>

Public Types

using OutputType = backends::DCMotorBackendBase::OutputType

Public Member Functions

 DCMotor (std::shared_ptr< backends::DCMotorBackendBase > backend, const std::string &name=consts::INVALID_STR)
void set_speed (real_t speed)
 Set the target speed of the output shaft [rad/s]. It is clamped to the maximum speed.
real_t target_speed () const noexcept
void set_max_speed (real_t max_speed)
 Limit the target speed to [-max_speed, max_speed].
real_t max_speed () const noexcept
void step (real_t dt)
 Advance the motor by dt. A model moves its own shaft.
void step (real_t dt, const ShaftState &shaft)
 Advance the motor by dt, with the shaft moved by a physics engine.
real_t angle () const
real_t speed () const
real_t encoder_angle () const
real_t torque () const
OutputType output_type () const noexcept
bool is_ready () const
const std::string & name () const noexcept
const std::string & backend_type_str () const noexcept
std::shared_ptr< backends::DCMotorBackendBase > backend_ptr () const noexcept

Static Public Member Functions

static std::shared_ptr< DCMotor > create_simulated (const backends::DCMotorParameters &parameters=backends::DCMotorParameters(), const std::string &name=consts::INVALID_STR)
 A motor with a SIM_DCMotorBackend.

Detailed Description

A DC motor with an encoder, run in speed control. The application sets the target speed of the output shaft and reads back its angle and speed. The backend decides what the motor is:

Call step() once per simulation step.

Member Typedef Documentation

◆ OutputType

using bitsim::actuators::DCMotor::OutputType = backends::DCMotorBackendBase::OutputType

Constructor & Destructor Documentation

◆ DCMotor()

bitsim::actuators::DCMotor::DCMotor ( std::shared_ptr< backends::DCMotorBackendBase > backend,
const std::string & name = consts::INVALID_STR )
explicit

Member Function Documentation

◆ angle()

Returns
The angle of the output shaft [rad]

◆ backend_ptr()

std::shared_ptr< backends::DCMotorBackendBase > bitsim::actuators::DCMotor::backend_ptr ( ) const
inlinenoexcept

◆ backend_type_str()

const std::string & bitsim::actuators::DCMotor::backend_type_str ( ) const
inlinenoexcept

◆ create_simulated()

std::shared_ptr< DCMotor > bitsim::actuators::DCMotor::create_simulated ( const backends::DCMotorParameters & parameters = backends::DCMotorParameters(),
const std::string & name = consts::INVALID_STR )
static

A motor with a SIM_DCMotorBackend.

◆ encoder_angle()

Returns
The angle of the output shaft as its encoder measures it [rad]. See backends::DCMotorBackendBase::encoder_angle

◆ is_ready()

bool bitsim::actuators::DCMotor::is_ready ( ) const
inline

◆ max_speed()

◆ name()

const std::string & bitsim::actuators::DCMotor::name ( ) const
inlinenoexcept

◆ output_type()

Returns
How the motor couples to a physics engine

◆ set_max_speed()

Limit the target speed to [-max_speed, max_speed].

◆ set_speed()

Set the target speed of the output shaft [rad/s]. It is clamped to the maximum speed.

◆ speed()

Returns
The speed of the output shaft [rad/s]

◆ step() [1/2]

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

◆ step() [2/2]

void bitsim::actuators::DCMotor::step ( real_t dt,
const ShaftState & shaft )
inline

Advance the motor by dt, with the shaft moved by a physics engine.

◆ target_speed()

Returns
The target speed of the output shaft [rad/s]

◆ torque()

Returns
The torque the motor puts on the output shaft [N m], if the backend knows it

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