diff --git a/src/shared/actuators/Servo/Servo.cpp b/src/shared/actuators/Servo/Servo.cpp index ceffefd2963bda1cb9984ea73974b692d62df2ba..e08ca3cb83a0dd1ea6672e7f281e603775230ea2 100644 --- a/src/shared/actuators/Servo/Servo.cpp +++ b/src/shared/actuators/Servo/Servo.cpp @@ -61,6 +61,11 @@ void Servo::disable() {} void Servo::setPosition(float position) { + if (position < 0) + position = 0; + else if (position > 1) + position = 1; + float pulse = minPulse + (maxPulse - minPulse) * position; float dutyCycle = pulse * frequency / 1000000.0f;