1#ifndef BITSIM_ACTUATORS_DC_MOTOR_H
2#define BITSIM_ACTUATORS_DC_MOTOR_H
39 static std::shared_ptr<DCMotor>
43 explicit DCMotor(std::shared_ptr<backends::DCMotorBackendBase> backend,
100 bool is_ready()
const {
return backend_->is_ready(); }
102 const std::string &
name() const noexcept {
return name_; }
103 const std::string &
backend_type_str() const noexcept {
return backend_->backend_type_str(); }
104 std::shared_ptr<backends::DCMotorBackendBase>
backend_ptr() const noexcept {
return backend_; }
107 std::shared_ptr<backends::DCMotorBackendBase> backend_;
109 real_t target_speed_{0.0};
110 real_t max_speed_{std::numeric_limits<real_t>::max()};
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
real_t max_speed() const noexcept
Definition dc_motor.h:61
void step(real_t dt)
Advance the motor by dt. A model moves its own shaft.
Definition dc_motor.h:66
bool is_ready() const
Definition dc_motor.h:100
static std::shared_ptr< DCMotor > create_simulated(const backends::DCMotorParameters ¶meters=backends::DCMotorParameters(), const std::string &name=consts::INVALID_STR)
A motor with a SIM_DCMotorBackend.
Definition dc_motor.cpp:11
real_t torque() const
Definition dc_motor.h:93
void set_speed(real_t speed)
Set the target speed of the output shaft [rad/s]. It is clamped to the maximum speed.
Definition dc_motor.cpp:27
backends::DCMotorBackendBase::OutputType OutputType
Definition dc_motor.h:34
const std::string & backend_type_str() const noexcept
Definition dc_motor.h:103
real_t encoder_angle() const
Definition dc_motor.h:87
const std::string & name() const noexcept
Definition dc_motor.h:102
OutputType output_type() const noexcept
Definition dc_motor.h:98
real_t target_speed() const noexcept
Definition dc_motor.h:55
real_t angle() const
Definition dc_motor.h:76
std::shared_ptr< backends::DCMotorBackendBase > backend_ptr() const noexcept
Definition dc_motor.h:104
void set_max_speed(real_t max_speed)
Limit the target speed to [-max_speed, max_speed].
Definition dc_motor.cpp:33
void step(real_t dt, const ShaftState &shaft)
Advance the motor by dt, with the shaft moved by a physics engine.
Definition dc_motor.h:71
DCMotor(std::shared_ptr< backends::DCMotorBackendBase > backend, const std::string &name=consts::INVALID_STR)
Definition dc_motor.cpp:18
real_t speed() const
Definition dc_motor.h:81
OutputType
Definition dc_motor_backend_base.h:41
Definition dc_motor_backend_base.h:11
const std::string INVALID_STR
Invalid string.
Definition bitsim_consts.h:21
Definition dc_motor_backend_base.h:9
double real_t
real_t
Definition bitsim_types.h:20
The state of the output shaft of a motor, as a simulator sees it.
Definition dc_motor_backend_base.h:17
The constants of a brushed DC gear motor with an encoder, and of the speed controller that runs it....
Definition sim_dc_motor_backend.h:21