8 #ifndef LIBRARIES_RBE1001LIB_SRC_MOTOR_H_ 9 #define LIBRARIES_RBE1001LIB_SRC_MOTOR_H_ 13 #define MAX_POSSIBLE_MOTORS 4 14 #define ENCODER_CPR 12.0f 15 #define GEAR_BOX_RATIO 120.0f 16 #define QUADRATUE_MULTIPLYER 1.0f 17 #define TICKS_TO_DEGREES ((QUADRATUE_MULTIPLYER / (ENCODER_CPR * GEAR_BOX_RATIO / 360.0)) * -1) 18 #define I_TERM_SIZE 120.0f 217 Motor(
int pwmPin,
int dirPin,
int encAPin,
int encBPin);
318 void setSpeed(
float newDegreesPerSecond);
325 void setSpeed(
float newDegreesPerSecond,
long miliseconds);
333 void moveTo(
float newTargetInDegrees,
float speedDegPerSec);
343 void moveFor(
float deltaTargetInDegrees,
float speedDegPerSec);
359 float startMoveFor(
float deltaTargetInDegrees,
float speedDegPerSec);
414 long miliseconds,
float Control_0 = 0.5,
float Control_1 = 1.0)
418 BEZIER_P0 = Control_0;
419 BEZIER_P1 = Control_1;
434 long miliseconds,
float trapazoidalTime)
438 if (trapazoidalTime * 2 > miliseconds)
444 TRAPEZOIDAL_time = trapazoidalTime;
450 void setGains(
float p,
float i,
float d);
void setEffortLocal(float effort)
void setSetpoint(float newTargetInDegrees)
float startMoveFor(float deltaTargetInDegrees, float speedDegPerSec)
void setEffortPercent(float percent)
Motor(int pwmPin, int dirPin, int encAPin, int encBPin)
A PID Motor class using FreeRTOS threads, ESP32Encoder and ESP32PWM.
void setSetpointWithTime(float newTargetInDegrees, long miliseconds, interpolateMode mode)
void setSetpointWithLinearInterpolation(float newTargetInDegrees, long miliseconds)
void setSpeed(float newDegreesPerSecond)
void attach()
Attach the motors hardware.
void setGains(float p, float i, float d)
void setEffort(float effort)
int interruptCountForVelocity
#define MAX_POSSIBLE_MOTORS
float getCurrentDegrees()
float BEZIER_P0
BEZIER Control Point 0.
float milisecondPosIncrementForVelocity
void moveTo(float newTargetInDegrees, float speedDegPerSec)
float TRAPEZOIDAL_time
the amount of time to ramp up and ramp down the speed
A PID Motor class using FreeRTOS threads, ESP32Encoder and ESP32PWM.
static Motor * list[MAX_POSSIBLE_MOTORS]
float BEZIER_P1
BEZIER Control Point 1.
bool isMotorDoneWithMove()
Check to see if the motor is done with a move.
static bool timersAllocated
void setSetpointWithTrapezoidalInterpolation(float newTargetInDegrees, long miliseconds, float trapazoidalTime)
static void allocateTimer(int PWMgenerationTimer)
void setSetpointWithBezierInterpolation(float newTargetInDegrees, long miliseconds, float Control_0=0.5, float Control_1=1.0)
float getDegreesPerSecond()
void moveFor(float deltaTargetInDegrees, float speedDegPerSec)
void setSetpointWithSinusoidalInterpolation(float newTargetInDegrees, long miliseconds)
void blockUntilMoveIsDone()
wait for the motor to arrive at a setpoint
float getInterpolationUnitIncrement()