<s> import os <EOL> SERVOD_PATH = '<STR_LIT>' <EOL> class ServoActuator ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , pin = <NUM_LIT:0> , range = ( <NUM_LIT> , <NUM_LIT> ) , servod_path = SERVOD_PATH ) : <EOL> self . pin = pin <EOL> self . range = range <EOL> self . servod_path = servod_path <EOL> if not self . _servoblaster_started ( ) : <EOL> self . start ( ) <EOL> def set ( self , pulse_width ) : <EOL> """<STR_LIT>""" <EOL> os . system ( '<STR_LIT>' . format ( self . pin , <EOL> pulse_width ) ) <EOL> def set_normalized ( self , val ) : <EOL> min , max = self . range <EOL> scale = max - min <EOL> speed = min + int ( val * scale ) <EOL> self . set ( speed ) <EOL> def start ( self ) : <EOL> os . system ( '<STR_LIT>' . format ( self . servod_path ) ) <EOL> def stop ( self ) : <EOL> servod_name = os . path . split ( self . servod_path ) [ <NUM_LIT:1> ] <EOL> os . system ( '<STR_LIT>' . format ( servod_name ) ) <EOL> def _servoblaster_started ( self ) : <EOL> servod_name = os . path . split ( self . servod_path ) [ <NUM_LIT:1> ] <EOL> return servod_name in os . popen ( '<STR_LIT>' ) . read ( ) </s>
