bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::actuators::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

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()

real_t bitsim::actuators::DCMotor::angle ( ) const
inline
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()

real_t bitsim::actuators::DCMotor::encoder_angle ( ) const
inline
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()

real_t bitsim::actuators::DCMotor::max_speed ( ) const
inlinenoexcept

◆ name()

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

◆ output_type()

OutputType bitsim::actuators::DCMotor::output_type ( ) const
inlinenoexcept
Returns
How the motor couples to a physics engine

◆ set_max_speed()

void bitsim::actuators::DCMotor::set_max_speed ( real_t max_speed)

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

◆ set_speed()

void bitsim::actuators::DCMotor::set_speed ( real_t speed)

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

◆ speed()

real_t bitsim::actuators::DCMotor::speed ( ) const
inline
Returns
The speed of the output shaft [rad/s]

◆ step() [1/2]

void bitsim::actuators::DCMotor::step ( real_t dt)
inline

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()

real_t bitsim::actuators::DCMotor::target_speed ( ) const
inlinenoexcept
Returns
The target speed of the output shaft [rad/s]

◆ torque()

real_t bitsim::actuators::DCMotor::torque ( ) const
inline
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: