RBCX
Library for the RB3204-RBCX board with the ESP32 by RoboticsBrno.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
rb::Motor Class Reference

#include <RBCXMotor.h>

Public Types

typedef std::function< void(Motor &)> callback_t
 

Public Member Functions

MotorId id () const
 
int32_t position () const
 
void requestInfo (callback_t cb)
 
void power (int16_t value)
 Set motor power. More...
 
void speed (int16_t ticksPerSecond)
 Set motor speed. More...
 
void brake (uint16_t brakingPower)
 Start braking. More...
 
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. More...
 
int8_t pwmMaxPercent () const
 Get current maximum PWM percent value. More...
 
void driveToValue (int32_t positionAbsolute, int16_t speedTicksPerSecond, callback_t callback=nullptr)
 Drive motor to set position (according absolute value). More...
 
void drive (int32_t positionRelative, int16_t speedTicksPerSecond, callback_t callback=nullptr)
 Drive motor to set position (according relative value). More...
 
void setCurrentPosition (int32_t pos=0)
 Set the encoder tick counter to some value. More...
 
void setConfig (const MotorConfig &cfg)
 Set configuration, see MotorConfig & STM32 firmware. More...
 

Friends

class Manager
 
class MotorChangeBuilder
 

Member Typedef Documentation

◆ callback_t

typedef std::function<void(Motor&)> rb::Motor::callback_t

Member Function Documentation

◆ brake()

void rb::Motor::brake ( uint16_t  brakingPower)

Start braking.

Parameters
brakingPowerbraking power in <0, 32767>

◆ drive()

void rb::Motor::drive ( int32_t  positionRelative,
int16_t  speedTicksPerSecond,
callback_t  callback = nullptr 
)

Drive motor to set position (according relative value).

Parameters
positionRelativerelative position of the motor in encoder ticks
speedTicksPerSecondspeed of the motor in encoder ticks <-32768; 32767>
callbackis a function which will be called when the motor reach the position
Returns
MotorChangeBuilder
Note
If you call drive(100, 100) and then drive(100, 100), the motor will drive to 200 ticks. If you call drive(100, 100) and then drive(-100, 100), the motor will drive to 0 ticks.

◆ driveToValue()

void rb::Motor::driveToValue ( int32_t  positionAbsolute,
int16_t  speedTicksPerSecond,
callback_t  callback = nullptr 
)

Drive motor to set position (according absolute value).

Parameters
positionAbsoluteabsolute position of the motor in encoder ticks
speedTicksPerSecondspeed of the motor in encoder ticks <-32768; 32767>
callbackis a function which will be called when the motor reach the position
Returns
MotorChangeBuilder

◆ id()

MotorId rb::Motor::id ( ) const
inline

◆ position()

int32_t rb::Motor::position ( ) const
inline

◆ power()

void rb::Motor::power ( int16_t  value)

Set motor power.

Parameters
powerof the motor <-32768; 32767>

◆ pwmMaxPercent() [1/2]

int8_t rb::Motor::pwmMaxPercent ( ) const
inline

Get current maximum PWM percent value.

Returns
current maximum PWM percent value

◆ pwmMaxPercent() [2/2]

void rb::Motor::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.

Parameters
pctof the max value <0 - 100>

◆ requestInfo()

void rb::Motor::requestInfo ( callback_t  cb)

◆ setConfig()

void rb::Motor::setConfig ( const MotorConfig &  cfg)

Set configuration, see MotorConfig & STM32 firmware.

Parameters
cfgnew configuration

◆ setCurrentPosition()

void rb::Motor::setCurrentPosition ( int32_t  pos = 0)

Set the encoder tick counter to some value.

Parameters
posnew position of the motor in encoder ticks

◆ speed()

void rb::Motor::speed ( int16_t  ticksPerSecond)

Set motor speed.

Parameters
ticksPerSecondspeed of the motor <-32768; 32767>

Friends And Related Function Documentation

◆ Manager

friend class Manager
friend

◆ MotorChangeBuilder

friend class MotorChangeBuilder
friend

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