public void Set(double value)
{
//The motor is DECELLERATING if |value| < |power| OR value and power are not both positive or both negative
//Likewise, the motor is ACCELERATING if |value| > |power| AND value and power are both negative or both positive
//If power is zero, the motor is accelerating.
//if the motor is ACCELERATING, use MaxAccel. If the robot is DECELLERATING, use MaxDecel.
bool accel = (Math.Sign(value) == Math.Sign(m_power) && Math.Abs(value) > Math.Abs(m_power)) ||
Math.Abs(m_power) < MaxAccel;
double delta = accel ? MaxAccel : MaxDecel;
if (value > m_power + delta) //If the motor wants to change power faster than it is allowed, change it by the max power change allowed
m_power += delta;
else if (value < m_power - delta)
m_power -= delta;
else //If the motor wants to go to a power within the change limitations, set the power to the value.
m_power = value;
m_controller.Set(m_power);
}