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

basic drivetrain controller, supports smoothed movements on each axis More...

#include <JDrivetrainControllerBasic.h>

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

Public Member Functions

 JDrivetrainControllerBasic (JDrivetrain &_drivetrain, JTwoDTransform _velLimit, JTwoDTransform _accelLimit, JTwoDTransform _distError, bool _velNotPosDelta=true)
 
void run ()
 run as frequently as possible
 
void moveVel (JTwoDTransform _vel, bool _run=false)
 make drivetrain approach set velocity following acceleration limits
 
boolean isDrivetrainAtTarget ()
 are all the drivetrain distance Derivs_Limiters at their position targets?
 
void moveDist (JTwoDTransform _dist, bool _run=false)
 make each axis of the drivetrain go to target position, following accel and vel limits
 
void moveDistY (float _y, bool _run=false)
 
void moveDistTheta (float _theta, bool _run=false)
 
void moveDistX (float _x, bool _run=false)
 
void moveDistInc (JTwoDTransform _d, bool _run=false)
 
void moveDistYInc (float _y, bool _run=false)
 
void moveDistThetaInc (float _theta, bool _run=false)
 
void moveDistXInc (float _x, bool _run=false)
 
bool isVelZero ()
 
bool getDistMode ()
 true if going to distance target, false if velocity based
 
bool getIsControlled ()
 true=velocity and acceleration is limited, false=writing directly to drivetrain
 
JTwoDTransform getDistTarget ()
 
void setVelLimit (JTwoDTransform _velLim)
 
void setAccelLimit (JTwoDTransform _accelLim)
 
JTwoDTransform getVelLimit ()
 
JTwoDTransform getAccelLimit ()
 
void setVelLimitY (float l)
 
void setVelLimitX (float l)
 
void setVelLimitTheta (float l)
 
void setAccelLimitY (float l)
 
void setAccelLimitX (float l)
 
void setAccelLimitTheta (float l)
 
void setVelNotPosDelta (bool _velNotPosDelta)
 true = uses setVel() when setting drivetrain velocity, false = uses setPosDelta() when setting drivetrain velocity
 
void setVel (JTwoDTransform _vel, bool _run=false)
 sets drivetrain velocity immediately
 
void setDistSetpoint (JTwoDTransform _dist, bool _run=false)
 
void setDistDelta (JTwoDTransform _dist, bool _run=false)
 
void resetDist ()
 
JTwoDTransform getVel (bool _run=false)
 
JTwoDTransform getDist (bool _run=false)
 
JTwoDTransform getDistSetpoint ()
 returns what distances are being set as the setpoints for each axis of the drivetrain
 
JTwoDTransform getMaxVel ()
 returns the approximate maximum velocity of the drivetrain, if the drivetrain is told to move at max velocity, it should set the motors to full power.
 
float getMotorVel (unsigned char i)
 
void setMotorVel (float vel, unsigned char i, bool _run=false)
 
void setMotorDistSetpoint (float distSetpoint, unsigned char i, bool _run=false)
 
void setMotorDistDelta (float distDelta, unsigned char i, bool _run=false)
 
unsigned char getNumberMotors ()
 
bool setEnable (bool _enable)
 enables or disables movement
 
bool enable ()
 enables movement
 
bool disable ()
 disables movement
 
bool getEnable ()
 gets the current state (enabled or disabled)
 

Public Attributes

JDrivetraindrivetrain
 
Derivs_Limiter XLimiter
 
Derivs_Limiter YLimiter
 
Derivs_Limiter ThetaLimiter
 
JTwoDTransform distError
 

Protected Attributes

bool controlled
 
bool distMode
 
unsigned long lastCalcMillis
 
JTwoDTransform velTarget
 
bool velNotPosDelta
 

Detailed Description

basic drivetrain controller, supports smoothed movements on each axis

Note
each axis is separate, this drivetrain controller doesn't combine movements over time to actually calculate its position

Constructor & Destructor Documentation

◆ JDrivetrainControllerBasic()

JDrivetrainControllerBasic::JDrivetrainControllerBasic ( JDrivetrain _drivetrain,
JTwoDTransform  _velLimit,
JTwoDTransform  _accelLimit,
JTwoDTransform  _distError,
bool  _velNotPosDelta = true 
)
inline

Member Function Documentation

◆ disable()

bool JDrivetrainControllerBasic::disable ( )
inlinevirtual

disables movement

Return values
didthe state change

Implements JDrivetrainBasic.

◆ enable()

bool JDrivetrainControllerBasic::enable ( )
inlinevirtual

enables movement

Return values
didthe state change

Implements JDrivetrainBasic.

◆ getAccelLimit()

JTwoDTransform JDrivetrainControllerBasic::getAccelLimit ( )
inline

◆ getDist()

JTwoDTransform JDrivetrainControllerBasic::getDist ( bool  _run = false)
inlinevirtual

Reimplemented from JDrivetrain.

◆ getDistMode()

bool JDrivetrainControllerBasic::getDistMode ( )
inline

true if going to distance target, false if velocity based

Return values
bool

◆ getDistSetpoint()

JTwoDTransform JDrivetrainControllerBasic::getDistSetpoint ( )
inline

returns what distances are being set as the setpoints for each axis of the drivetrain

Note
only works in controlled dist mode
Return values
(JTwoDTransform)

◆ getDistTarget()

JTwoDTransform JDrivetrainControllerBasic::getDistTarget ( )
inline

◆ getEnable()

bool JDrivetrainControllerBasic::getEnable ( )
inlinevirtual

gets the current state (enabled or disabled)

Return values
(bool)true=enabled false=movement disabled

Implements JDrivetrainBasic.

◆ getIsControlled()

bool JDrivetrainControllerBasic::getIsControlled ( )
inline

true=velocity and acceleration is limited, false=writing directly to drivetrain

Return values
(bool)

◆ getMaxVel()

JTwoDTransform JDrivetrainControllerBasic::getMaxVel ( )
inlinevirtual

returns the approximate maximum velocity of the drivetrain, if the drivetrain is told to move at max velocity, it should set the motors to full power.

Note
depends on how well calibrated the motor compensators are
Return values
(JTwoDTransform)maximum velocity (in whatever units your drivetrain and motors are set up for)

Implements JDrivetrainBasic.

◆ getMotorVel()

float JDrivetrainControllerBasic::getMotorVel ( unsigned char  i)
inlinevirtual

Reimplemented from JDrivetrain.

◆ getNumberMotors()

unsigned char JDrivetrainControllerBasic::getNumberMotors ( )
inlinevirtual

Reimplemented from JDrivetrain.

◆ getVel()

JTwoDTransform JDrivetrainControllerBasic::getVel ( bool  _run = false)
inlinevirtual

Reimplemented from JDrivetrain.

◆ getVelLimit()

JTwoDTransform JDrivetrainControllerBasic::getVelLimit ( )
inline

◆ isDrivetrainAtTarget()

boolean JDrivetrainControllerBasic::isDrivetrainAtTarget ( )
inline

are all the drivetrain distance Derivs_Limiters at their position targets?

Note
doesn't check whether in position control mode
Return values
boolean

◆ isVelZero()

bool JDrivetrainControllerBasic::isVelZero ( )
inline

◆ moveDist()

void JDrivetrainControllerBasic::moveDist ( JTwoDTransform  _dist,
bool  _run = false 
)
inline

make each axis of the drivetrain go to target position, following accel and vel limits

Note
each axis is controlled separately, you are not setting absolute position, just target distance for each axis
Parameters
_dist(JTwoDTransform) target distance
_run(bool) default=false, true=run gets called within this function, false=call run yourself outside this function

◆ moveDistInc()

void JDrivetrainControllerBasic::moveDistInc ( JTwoDTransform  _d,
bool  _run = false 
)
inline

◆ moveDistTheta()

void JDrivetrainControllerBasic::moveDistTheta ( float  _theta,
bool  _run = false 
)
inline

◆ moveDistThetaInc()

void JDrivetrainControllerBasic::moveDistThetaInc ( float  _theta,
bool  _run = false 
)
inline

◆ moveDistX()

void JDrivetrainControllerBasic::moveDistX ( float  _x,
bool  _run = false 
)
inline

◆ moveDistXInc()

void JDrivetrainControllerBasic::moveDistXInc ( float  _x,
bool  _run = false 
)
inline

◆ moveDistY()

void JDrivetrainControllerBasic::moveDistY ( float  _y,
bool  _run = false 
)
inline

◆ moveDistYInc()

void JDrivetrainControllerBasic::moveDistYInc ( float  _y,
bool  _run = false 
)
inline

◆ moveVel()

void JDrivetrainControllerBasic::moveVel ( JTwoDTransform  _vel,
bool  _run = false 
)
inline

make drivetrain approach set velocity following acceleration limits

Parameters
_vel(JTwoDTransform) target velocity
_run(bool) default=false, true=run gets called within this function, false=call run yourself outside this function

◆ resetDist()

void JDrivetrainControllerBasic::resetDist ( )
inlinevirtual

Reimplemented from JDrivetrain.

◆ run()

void JDrivetrainControllerBasic::run ( )
inlinevirtual

run as frequently as possible

Implements JDrivetrainBasic.

◆ setAccelLimit()

void JDrivetrainControllerBasic::setAccelLimit ( JTwoDTransform  _accelLim)
inline

◆ setAccelLimitTheta()

void JDrivetrainControllerBasic::setAccelLimitTheta ( float  l)
inline

◆ setAccelLimitX()

void JDrivetrainControllerBasic::setAccelLimitX ( float  l)
inline

◆ setAccelLimitY()

void JDrivetrainControllerBasic::setAccelLimitY ( float  l)
inline

◆ setDistDelta()

void JDrivetrainControllerBasic::setDistDelta ( JTwoDTransform  _dist,
bool  _run = false 
)
inlinevirtual

Reimplemented from JDrivetrain.

◆ setDistSetpoint()

void JDrivetrainControllerBasic::setDistSetpoint ( JTwoDTransform  _dist,
bool  _run = false 
)
inlinevirtual

Reimplemented from JDrivetrain.

◆ setEnable()

bool JDrivetrainControllerBasic::setEnable ( bool  _enable)
inlinevirtual

enables or disables movement

Parameters
_enable(bool) true=enabled false=movement disabled
Return values
didthe state change

Implements JDrivetrainBasic.

◆ setMotorDistDelta()

void JDrivetrainControllerBasic::setMotorDistDelta ( float  distDelta,
unsigned char  i,
bool  _run = false 
)
inlinevirtual

Reimplemented from JDrivetrain.

◆ setMotorDistSetpoint()

void JDrivetrainControllerBasic::setMotorDistSetpoint ( float  distSetpoint,
unsigned char  i,
bool  _run = false 
)
inlinevirtual

Reimplemented from JDrivetrain.

◆ setMotorVel()

void JDrivetrainControllerBasic::setMotorVel ( float  vel,
unsigned char  i,
bool  _run = false 
)
inlinevirtual

Reimplemented from JDrivetrain.

◆ setVel()

void JDrivetrainControllerBasic::setVel ( JTwoDTransform  _vel,
bool  _run = false 
)
inlinevirtual

sets drivetrain velocity immediately

Parameters
_velJTwoDTransform of velocity wanted for drivetrain
_run(bool) default=false, true=run gets called within this function, false=call run yourself outside this function
Return values
None

Implements JDrivetrainBasic.

◆ setVelLimit()

void JDrivetrainControllerBasic::setVelLimit ( JTwoDTransform  _velLim)
inline

◆ setVelLimitTheta()

void JDrivetrainControllerBasic::setVelLimitTheta ( float  l)
inline

◆ setVelLimitX()

void JDrivetrainControllerBasic::setVelLimitX ( float  l)
inline

◆ setVelLimitY()

void JDrivetrainControllerBasic::setVelLimitY ( float  l)
inline

◆ setVelNotPosDelta()

void JDrivetrainControllerBasic::setVelNotPosDelta ( bool  _velNotPosDelta)
inline

true = uses setVel() when setting drivetrain velocity, false = uses setPosDelta() when setting drivetrain velocity

Parameters
_velNotPosDelta(bool)

Member Data Documentation

◆ controlled

bool JDrivetrainControllerBasic::controlled
protected

◆ distError

JTwoDTransform JDrivetrainControllerBasic::distError

◆ distMode

bool JDrivetrainControllerBasic::distMode
protected

◆ drivetrain

JDrivetrain& JDrivetrainControllerBasic::drivetrain

◆ lastCalcMillis

unsigned long JDrivetrainControllerBasic::lastCalcMillis
protected

◆ ThetaLimiter

Derivs_Limiter JDrivetrainControllerBasic::ThetaLimiter

◆ velNotPosDelta

bool JDrivetrainControllerBasic::velNotPosDelta
protected

◆ velTarget

JTwoDTransform JDrivetrainControllerBasic::velTarget
protected

◆ XLimiter

Derivs_Limiter JDrivetrainControllerBasic::XLimiter

◆ YLimiter

Derivs_Limiter JDrivetrainControllerBasic::YLimiter

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