Motor.hpp is the base abstract class for all motors - ie these methods apply to all sorts of Motors be they servos, dc motors etc.
Constants:
MOTOR::MAX_SPEED represents full speed ahead
MOTOR::MIN_SPEED represents full speed backwards
The middle point between these two values (which is normally 0) represents STOP.
int SetSpeed(int speed);
This will set the new speed for the motor. This value will be clamped to be between MIN_SPEED and MAX_SPEED. The newly clamped speed will be returned to the caller. If the motor hardware incorporates a brake then setting a speed of 0 will apply the brake.
int SetSpeed(int speed, bool forwards);
A convenience method for setting a positive speed and a direction. Is the same as:
if(forwards){
SetSpeed(speed);
}else{
SetSpeed(-speed);
}
int GetSpeed();
Get the current speed of the motor. This will be between MIN_SPEED and MAX_SPEED. NB this is the current value from the last SetSpeed and does not reflect the actual physical motor speed.
void Disconnect();
Depending on the abilities of the motor driver this will attempt to put the motor into 'coasting' mode by disconnecting it from the power. If the robot is on a hill then this may cause the robot to start rolling backwards. If this is not intended then use SetSpeed(0) to apply a brake.
void Reconnect();
Reconnect the motor to the supply following a disconnect
bool IsConnected();
Is the motor currently connected?