JMotor
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
JMotorControllerBasic Class Reference

A motor controller object that uses a JMotorCompensator to set velocity of a motor. More...

#include <JMotorControllerBasic.h>

Inheritance diagram for JMotorControllerBasic:
Inheritance graph
[legend]
Collaboration diagram for JMotorControllerBasic:
Collaboration graph
[legend]

Public Member Functions

 JMotorControllerBasic (JMotorDriver &_driver, JMotorCompensator &_compensator, float _velLimit=INFINITY, float _accelLimit=INFINITY)
 constructor
 
void setAccelLimit (float _accelLimit)
 set maximum rate that motor speed can be changed at
 
void setVelLimit (float _velLimit)
 set maximum motor speed
 
void setVel (float vel, bool _run=true)
 set velocity for controller
 
void setVelTarget (float vel, bool _run=true)
 set target velocity for controller (acceleration limited)
 
float getVelTarget ()
 get target velocity for controller
 
float getVel ()
 get current velocity of motor
 
float getDriverSetVal ()
 returns the value the motor driver is being set to
 
void run ()
 update driver
 
bool setEnable (bool _enable)
 change whether motor controller is enabled
 
bool isDriverInRange ()
 true if motor driver is being set to within its range, false if driver is at a maximum
 
bool enable ()
 enable motor controller
 
bool disable ()
 disable motor controller
 
float getDriverMinRange ()
 if getDriverSetVal goes below this, isDriverInRange will go false
 
float getDriverMaxRange ()
 if getDriverSetVal exceeds this, isDriverInRange will go false
 
bool getEnable ()
 is the controller enabled
 
float getMaxVel ()
 How fast of a motor speed setting would get adjusted to full motor power.
 
float getMinVel ()
 slowest speed motor can go
 
void setMaxDriverRangeAmount (float _driverRangeAmount)
 set what fraction of driverRange can be used
 
float getVelLimit ()
 returns value of velLimit
 
float getAccelLimit ()
 returns value of accelLimit
 

Protected Attributes

float velocity
 
float setVal
 
float velocityTarget
 
float accelLimit
 
float velLimit
 
unsigned long lastRunMicros
 
JMotorDriverdriver
 
bool driverInRange
 
JMotorCompensatorcompensator
 

Detailed Description

A motor controller object that uses a JMotorCompensator to set velocity of a motor.

Note
Open loop, and no position based commands

Constructor & Destructor Documentation

◆ JMotorControllerBasic()

JMotorControllerBasic::JMotorControllerBasic ( JMotorDriver _driver,
JMotorCompensator _compensator,
float  _velLimit = INFINITY,
float  _accelLimit = INFINITY 
)
inline

constructor

Parameters
_driver(JMotorDriver)
_compensator(JMotorCompensator)
_velLimitmax velocity (default: INFINITY)
_accelLimitmax acceleration allowed for approaching velocityTarget, set to INFINITY for unlimited (default: INFINITY)

Member Function Documentation

◆ disable()

bool JMotorControllerBasic::disable ( )
inlinevirtual

disable motor controller

Return values
(bool)true if state changed

Implements JMotorControllerBase.

◆ enable()

bool JMotorControllerBasic::enable ( )
inlinevirtual

enable motor controller

Return values
(bool)true if state changed

Implements JMotorControllerBase.

◆ getAccelLimit()

float JMotorControllerBasic::getAccelLimit ( )
inlinevirtual

returns value of accelLimit

Return values
(float)

Implements JMotorControllerBase.

◆ getDriverMaxRange()

float JMotorControllerBasic::getDriverMaxRange ( )
inlinevirtual

if getDriverSetVal exceeds this, isDriverInRange will go false

Return values
(float)

Implements JMotorControllerBase.

◆ getDriverMinRange()

float JMotorControllerBasic::getDriverMinRange ( )
inlinevirtual

if getDriverSetVal goes below this, isDriverInRange will go false

Return values
(float)

Implements JMotorControllerBase.

◆ getDriverSetVal()

float JMotorControllerBasic::getDriverSetVal ( )
inlinevirtual

returns the value the motor driver is being set to

Return values
(float)

Implements JMotorControllerBase.

◆ getEnable()

bool JMotorControllerBasic::getEnable ( )
inlinevirtual

is the controller enabled

Return values
(bool)

Implements JMotorControllerBase.

◆ getMaxVel()

float JMotorControllerBasic::getMaxVel ( )
inlinevirtual

How fast of a motor speed setting would get adjusted to full motor power.

Note
may change as battery voltage changes
Return values
(float)

Implements JMotorControllerBase.

◆ getMinVel()

float JMotorControllerBasic::getMinVel ( )
inlinevirtual

slowest speed motor can go

Implements JMotorControllerBase.

◆ getVel()

float JMotorControllerBasic::getVel ( )
inlinevirtual

get current velocity of motor

Return values
(float)

Implements JMotorControllerBase.

◆ getVelLimit()

float JMotorControllerBasic::getVelLimit ( )
inlinevirtual

returns value of velLimit

Return values
(float)

Implements JMotorControllerBase.

◆ getVelTarget()

float JMotorControllerBasic::getVelTarget ( )
inlinevirtual

get target velocity for controller

Return values
(float)current velocity target

Implements JMotorControllerBase.

◆ isDriverInRange()

bool JMotorControllerBasic::isDriverInRange ( )
inlinevirtual

true if motor driver is being set to within its range, false if driver is at a maximum

Return values
(bool)

Implements JMotorControllerBase.

◆ run()

void JMotorControllerBasic::run ( )
inlinevirtual

update driver

Note
call this function as frequently as possible

Implements JMotorControllerBase.

Reimplemented in JMotorControllerOpen.

◆ setAccelLimit()

void JMotorControllerBasic::setAccelLimit ( float  _accelLimit)
inlinevirtual

set maximum rate that motor speed can be changed at

Note
set to INFINITY to disable acceleration limiting
Parameters
_accelLimit(float)

Implements JMotorControllerBase.

Reimplemented in JMotorControllerOpen.

◆ setEnable()

bool JMotorControllerBasic::setEnable ( bool  _enable)
inlinevirtual

change whether motor controller is enabled

Parameters
_enable(bool)
Note
velocity related variables are reset to zero on disable. you can set velocity then enable
Return values
(bool)true if state changed

Implements JMotorControllerBase.

Reimplemented in JMotorControllerOpen.

◆ setMaxDriverRangeAmount()

void JMotorControllerBasic::setMaxDriverRangeAmount ( float  _driverRangeAmount)
inlinevirtual

set what fraction of driverRange can be used

Parameters
_driverRangeAmount(float)

Implements JMotorControllerBase.

◆ setVel()

void JMotorControllerBasic::setVel ( float  vel,
bool  _run = true 
)
inlinevirtual

set velocity for controller

Note
this function can be called repeatedly, or just once if run() is called frequently
Parameters
vel(float)
_run(bool) default:true, true = call run() in this function, false = you'll call run() yourself

Implements JMotorControllerBase.

Reimplemented in JMotorControllerOpen.

◆ setVelLimit()

void JMotorControllerBasic::setVelLimit ( float  _velLimit)
inlinevirtual

set maximum motor speed

Note
set to INFINITY to disable velocity limiting
Parameters
_velLimit(float)

Implements JMotorControllerBase.

Reimplemented in JMotorControllerOpen.

◆ setVelTarget()

void JMotorControllerBasic::setVelTarget ( float  vel,
bool  _run = true 
)
inlinevirtual

set target velocity for controller (acceleration limited)

Note
this function can be called repeatedly, or just once if run() is called frequently
Parameters
vel(float) target velocity
_run(bool) default:true, true = call run() in this function, false = you'll call run() yourself

Implements JMotorControllerBase.

Reimplemented in JMotorControllerOpen.

Member Data Documentation

◆ accelLimit

float JMotorControllerBasic::accelLimit
protected

◆ compensator

JMotorCompensator& JMotorControllerBasic::compensator
protected

◆ driver

JMotorDriver& JMotorControllerBasic::driver
protected

◆ driverInRange

bool JMotorControllerBasic::driverInRange
protected

◆ lastRunMicros

unsigned long JMotorControllerBasic::lastRunMicros
protected

◆ setVal

float JMotorControllerBasic::setVal
protected

◆ velLimit

float JMotorControllerBasic::velLimit
protected

◆ velocity

float JMotorControllerBasic::velocity
protected

◆ velocityTarget

float JMotorControllerBasic::velocityTarget
protected

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