def set_speed(self, speed):
        """Setter for motor's speed as % of max (same as duty cycle).

        :param speed: Speed to set motor to in % of maximum.
        :type speed: float

        """
        speed = int(round(speed))
        if speed > 100:
            self.logger.warning("Invalid speed {}, using 100".format(speed))
            speed = 100
        elif speed < 0:
            self.logger.warning("Invalid speed {}, using 0".format(speed))
            speed = 0

        self.pwm.duty = int(round((speed / 100.) * self.pwm.period))
        self.logger.debug("Updated speed {}".format(self))
dataset/ETHPy150Open IEEERobotics/bot/bot/hardware/motor.py/Motor.set_speed/original