diff --git a/Motor.cpp b/Motor.cpp index 8151321..ea6b55d 100644 --- a/Motor.cpp +++ b/Motor.cpp @@ -18,7 +18,7 @@ void Motor::SetSpeed(float targetSpeed) { bool Motor::Drive(float distance) { if (!this->driving) { this->startTime = time(NULL); - this->targetDistance = abs(distance); + this->targetDistance = distance >= 0 ? distance : -distance; this->driving = true; } double duration = difftime(time(NULL), this->startTime);