Class rb::Motor
Public Types
Type | Name |
---|---|
typedef std::function< void(Motor &)> | callback_t |
Public Functions
Type | Name |
---|---|
void | brake (uint16_t brakingPower) Start braking. |
void | drive (int32_t positionRelative, int16_t speedTicksPerSecond, callback_t callback=nullptr) Drive motor to set position (according relative value). |
void | driveToValue (int32_t positionAbsolute, int16_t speedTicksPerSecond, callback_t callback=nullptr) Drive motor to set position (according absolute value). |
MotorId | id () const |
int32_t | position () const |
void | power (int16_t value) Set motor power. |
void | pwmMaxPercent (int8_t percent) Limit the maximum PWM value. If you call pwmMaxPercent(70) and then power(100), the motors will spin at 70% of maximum speed. This scales both the power and speed set through Motor . |
int8_t | pwmMaxPercent () const Get current maximum PWM percent value. |
void | requestInfo (callback_t cb) |
void | setConfig (const MotorConfig & cfg) Set configuration, see MotorConfig & STM32 firmware. |
void | setCurrentPosition (int32_t pos=0) Set the encoder tick counter to some value. |
void | speed (int16_t ticksPerSecond) Set motor speed. |
Public Types Documentation
typedef callback_t
typedef std::function<void(Motor&)> rb::Motor::callback_t;
Public Functions Documentation
function brake
Start braking.
void rb::Motor::brake (
uint16_t brakingPower
)
Parameters:
brakingPower
braking power in <0, 32767>
function drive
void rb::Motor::drive (
int32_t positionRelative,
int16_t speedTicksPerSecond,
callback_t callback=nullptr
)
function driveToValue
void rb::Motor::driveToValue (
int32_t positionAbsolute,
int16_t speedTicksPerSecond,
callback_t callback=nullptr
)
function id
inline MotorId rb::Motor::id () const
function position
inline int32_t rb::Motor::position () const
function power
Set motor power.
void rb::Motor::power (
int16_t value
)
Parameters:
power
of the motor <-32768; 32767>
function pwmMaxPercent [1/2]
Limit the maximum PWM value. If you call pwmMaxPercent(70) and then power(100), the motors will spin at 70% of maximum speed. This scales both the power and speed set through Motor .
void rb::Motor::pwmMaxPercent (
int8_t percent
)
Parameters:
pct
of the max value <0 - 100>
function pwmMaxPercent [2/2]
inline int8_t rb::Motor::pwmMaxPercent () const
function requestInfo
void rb::Motor::requestInfo (
callback_t cb
)
function setConfig
void rb::Motor::setConfig (
const MotorConfig & cfg
)
function setCurrentPosition
void rb::Motor::setCurrentPosition (
int32_t pos=0
)
function speed
Set motor speed.
void rb::Motor::speed (
int16_t ticksPerSecond
)
Parameters:
ticksPerSecond
speed of the motor <-32768; 32767>
The documentation for this class was generated from the following file demo-projets/esp/RBCXMotor.h