1#ifndef J_DRIVETRAIN_CONTROLLER_BASIC_H
2#define J_DRIVETRAIN_CONTROLLER_BASIC_H
29 ,
XLimiter(Derivs_Limiter(_velLimit.x, _accelLimit.x))
30 ,
YLimiter(Derivs_Limiter(_velLimit.y, _accelLimit.y))
31 ,
ThetaLimiter(Derivs_Limiter(_velLimit.theta, _accelLimit.theta))
34 YLimiter.setPreventGoingWrongWay(
false);
35 XLimiter.setPreventGoingWrongWay(
false);
37 YLimiter.setPreventGoingTooFast(
true);
39 XLimiter.setPreventGoingTooFast(
true);
208 targ.
theta += _theta;
222 return (vel.
x == 0 && vel.
y == 0 && vel.
theta == 0);
virtual bool getEnable()=0
gets the current state (enabled or disabled)
virtual void setVel(JTwoDTransform _vel, bool _run=false)=0
sets a velocity for the drivetrain to move at
virtual void run()=0
call this in loop. it calls any encoder or motor update functions
virtual bool setEnable(bool _enable)=0
enables or disables movement
virtual JTwoDTransform getMaxVel()=0
returns the approximate maximum velocity of the drivetrain, if the drivetrain is told to move at max ...
basic drivetrain controller, supports smoothed movements on each axis
Definition JDrivetrainControllerBasic.h:11
bool setEnable(bool _enable)
enables or disables movement
Definition JDrivetrainControllerBasic.h:398
bool getIsControlled()
true=velocity and acceleration is limited, false=writing directly to drivetrain
Definition JDrivetrainControllerBasic.h:238
JTwoDTransform getAccelLimit()
Definition JDrivetrainControllerBasic.h:270
JTwoDTransform distError
Definition JDrivetrainControllerBasic.h:26
void setMotorVel(float vel, unsigned char i, bool _run=false)
Definition JDrivetrainControllerBasic.h:381
void moveDistYInc(float _y, bool _run=false)
Definition JDrivetrainControllerBasic.h:198
JTwoDTransform getDistTarget()
Definition JDrivetrainControllerBasic.h:243
float getMotorVel(unsigned char i)
Definition JDrivetrainControllerBasic.h:377
void moveDistX(float _x, bool _run=false)
Definition JDrivetrainControllerBasic.h:184
void run()
run as frequently as possible
Definition JDrivetrainControllerBasic.h:49
void setAccelLimitTheta(float l)
Definition JDrivetrainControllerBasic.h:295
void setDistDelta(JTwoDTransform _dist, bool _run=false)
Definition JDrivetrainControllerBasic.h:330
void moveDistThetaInc(float _theta, bool _run=false)
Definition JDrivetrainControllerBasic.h:205
bool disable()
disables movement
Definition JDrivetrainControllerBasic.h:420
bool getEnable()
gets the current state (enabled or disabled)
Definition JDrivetrainControllerBasic.h:424
boolean isDrivetrainAtTarget()
are all the drivetrain distance Derivs_Limiters at their position targets?
Definition JDrivetrainControllerBasic.h:133
bool isVelZero()
Definition JDrivetrainControllerBasic.h:219
JTwoDTransform getVel(bool _run=false)
Definition JDrivetrainControllerBasic.h:352
Derivs_Limiter XLimiter
Definition JDrivetrainControllerBasic.h:23
void setVelLimit(JTwoDTransform _velLim)
Definition JDrivetrainControllerBasic.h:252
void moveVel(JTwoDTransform _vel, bool _run=false)
make drivetrain approach set velocity following acceleration limits
Definition JDrivetrainControllerBasic.h:110
JTwoDTransform getMaxVel()
returns the approximate maximum velocity of the drivetrain, if the drivetrain is told to move at max ...
Definition JDrivetrainControllerBasic.h:373
JDrivetrain & drivetrain
Definition JDrivetrainControllerBasic.h:22
bool distMode
Definition JDrivetrainControllerBasic.h:14
JTwoDTransform getVelLimit()
Definition JDrivetrainControllerBasic.h:265
JTwoDTransform getDistSetpoint()
returns what distances are being set as the setpoints for each axis of the drivetrain
Definition JDrivetrainControllerBasic.h:369
bool velNotPosDelta
Definition JDrivetrainControllerBasic.h:19
void setVelLimitY(float l)
Definition JDrivetrainControllerBasic.h:275
void setAccelLimit(JTwoDTransform _accelLim)
Definition JDrivetrainControllerBasic.h:258
void moveDistTheta(float _theta, bool _run=false)
Definition JDrivetrainControllerBasic.h:177
void setVel(JTwoDTransform _vel, bool _run=false)
sets drivetrain velocity immediately
Definition JDrivetrainControllerBasic.h:316
void setAccelLimitX(float l)
Definition JDrivetrainControllerBasic.h:291
JTwoDTransform getDist(bool _run=false)
Definition JDrivetrainControllerBasic.h:358
Derivs_Limiter ThetaLimiter
Definition JDrivetrainControllerBasic.h:25
unsigned char getNumberMotors()
Definition JDrivetrainControllerBasic.h:393
Derivs_Limiter YLimiter
Definition JDrivetrainControllerBasic.h:24
unsigned long lastCalcMillis
Definition JDrivetrainControllerBasic.h:15
void setMotorDistDelta(float distDelta, unsigned char i, bool _run=false)
Definition JDrivetrainControllerBasic.h:389
JDrivetrainControllerBasic(JDrivetrain &_drivetrain, JTwoDTransform _velLimit, JTwoDTransform _accelLimit, JTwoDTransform _distError, bool _velNotPosDelta=true)
Definition JDrivetrainControllerBasic.h:27
bool getDistMode()
true if going to distance target, false if velocity based
Definition JDrivetrainControllerBasic.h:229
JTwoDTransform velTarget
Definition JDrivetrainControllerBasic.h:17
void setVelLimitX(float l)
Definition JDrivetrainControllerBasic.h:279
void setAccelLimitY(float l)
Definition JDrivetrainControllerBasic.h:287
void setVelNotPosDelta(bool _velNotPosDelta)
true = uses setVel() when setting drivetrain velocity, false = uses setPosDelta() when setting drivet...
Definition JDrivetrainControllerBasic.h:304
bool controlled
Definition JDrivetrainControllerBasic.h:13
bool enable()
enables movement
Definition JDrivetrainControllerBasic.h:416
void setMotorDistSetpoint(float distSetpoint, unsigned char i, bool _run=false)
Definition JDrivetrainControllerBasic.h:385
void moveDistY(float _y, bool _run=false)
Definition JDrivetrainControllerBasic.h:170
void resetDist()
Definition JDrivetrainControllerBasic.h:337
void setVelLimitTheta(float l)
Definition JDrivetrainControllerBasic.h:283
void moveDistXInc(float _x, bool _run=false)
Definition JDrivetrainControllerBasic.h:212
void setDistSetpoint(JTwoDTransform _dist, bool _run=false)
Definition JDrivetrainControllerBasic.h:323
void moveDist(JTwoDTransform _dist, bool _run=false)
make each axis of the drivetrain go to target position, following accel and vel limits
Definition JDrivetrainControllerBasic.h:144
void moveDistInc(JTwoDTransform _d, bool _run=false)
Definition JDrivetrainControllerBasic.h:191
defines interface for controlling any ground-based drivetrain
Definition JDrivetrain.h:10
virtual void setMotorDistDelta(float distDelta, unsigned char i, bool _run=false)
virtual JTwoDTransform getVel(bool _run=false)
virtual JTwoDTransform getDist(bool _run=false)
virtual unsigned char getNumberMotors()
virtual void setMotorVel(float vel, unsigned char i, bool _run=false)
virtual void setDistDelta(JTwoDTransform _dist, bool _run=false)
virtual float getMotorVel(unsigned char i)
virtual void setMotorDistSetpoint(float distSetpoint, unsigned char i, bool _run=false)
virtual void setDistSetpoint(JTwoDTransform _dist, bool _run=false)