EvoMotorPair#
-
class EvoMotorPair#
A class to control a pair of EvoMotors synchronously.
Initialisation & Setup
-
EvoMotorPair::EvoMotorPair(EvoMotor *m1, EvoMotor *m2, EvoIMU *imu = nullptr)#
Constructor to initialize a motor pair.
-
void EvoMotorPair::setStartSpeed(int startSpeed)#
Sets the start speed for the motors.
- Parameters:
startSpeed – The minimum speed value.
-
void EvoMotorPair::setEndSpeed(int endSpeed)#
Sets the end speed for the motors.
- Parameters:
endSpeed – The minimum speed value.
-
void EvoMotorPair::setAcceleration(int accel)#
Sets the acceleration parameters.
- Parameters:
accel – The acceleration factor.
-
int EvoMotorPair::getAcceleration()#
Gets the current acceleration parameters.
- Returns:
The acceleration factor.
-
void EvoMotorPair::setDeceleration(int decel)#
Sets the deceleration parameters.
- Parameters:
decel – The deceleration factor.
-
int EvoMotorPair::getDeceleration()#
Gets the current deceleration parameters.
- Returns:
The deceleration factor.
-
void EvoMotorPair::setSyncPID(int kp, int ki, int kd)#
Sets the proportional-integral-derivative (PID) control parameters for the motor pairing.
- Parameters:
kp – The proportional gain.
ki – The integral gain.
kd – The derivative gain.
-
void EvoMotorPair::setGyroPID(float kp, float ki, float kd)#
Sets the proportional-integral-derivative (PID) control parameters for the gyro.
- Parameters:
kp – The proportional gain.
ki – The integral gain.
kd – The derivative gain.
-
void EvoMotorPair::setStopBehavior(MotorStop stopBehavior)#
Sets the stopping behavior for the motors.
- Parameters:
stopBehavior – The stopping behavior (HOLD, BRAKE, or COAST).
Control Functions
-
void EvoMotorPair::move(int leftSpeed, int rightSpeed)#
Moves the motors at the specified speeds.
- Parameters:
leftSpeed – Speed for the left motor.
rightSpeed – Speed for the right motor.
-
void EvoMotorPair::moveDegrees(int leftSpeed, int rightSpeed, int degrees, MotorStop stopBehaviour = MotorStop::HOLD)#
Moves the motors a specified number of degrees.
- Parameters:
leftSpeed – Speed for the left motor.
rightSpeed – Speed for the right motor.
degrees – The number of degrees to move.
stopBehaviour – The stopping behavior after movement (HOLD, BRAKE, or COAST) Default is hold.
-
void EvoMotorPair::moveTime(int leftSpeed, int rightSpeed, int timems, int slowdowntime = 200, MotorStop stopBehaviour = MotorStop::HOLD)#
Moves the motors for a specified duration.
- Parameters:
leftSpeed – Speed for the left motor.
rightSpeed – Speed for the right motor.
timems – Duration in milliseconds.
slowdowntime – Duration where the motors start to slow down.
stopBehaviour – The stopping behavior after movement (HOLD, BRAKE, or COAST) Default is hold.
-
void EvoMotorPair::StraightDegreesIMU(int motorSpeed, int degrees, int heading = -1, MotorStop stopBehaviour = MotorStop::HOLD)#
Moves the motors following a Condition with the IMU.
- Parameters:
motorSpeed – Speed for the motors.
degrees – The number of degrees to move.
heading – The target heading angle. If -1, the current heading is maintained.
stopBehaviour – The stopping behavior after movement (HOLD, BRAKE, or COAST) Default is hold.
-
void EvoMotorPair::spotTurnGyro(int motorSpeed, float heading, bool reset = true, MotorStop stopBehaviour = MotorStop::HOLD)#
Performs a spot turn to a specific heading using the IMU.
- Parameters:
motorSpeed – The speed of the turn.
heading – The target heading angle.
reset – Settign true will reset the IMU heading.
stopBehaviour – The stopping behavior after movement (HOLD, BRAKE, or COAST).
-
void EvoMotorPair::stop()#
Stops both motors based on the stop behavior.
-
void EvoMotorPair::brake()#
Applies braking to both motors.
-
void EvoMotorPair::coast()#
Coasts both motors to a stop.
-
void EvoMotorPair::hold()#
Holds the current position of both motors.
-
void EvoMotorPair::resetAngle()#
Resets both motor angles to zero.