<commit_before># Controller for Servos in the Robotic Arm of the MANSEDS Lunar Rover

# Import dependencies
import RPi.GPIO as GPIO


# Set GPIO pin configuration
GPIO.setmode(GPIO.BOARD)


# Declare servo pins
servo_pins = []
GPIO.setup(servo_pins, GPIO.OUT)


# Define servo instance
def servo_instance(servo_number):
    servo_1 = GPIO.PWM(servo_pins[servo_number], 50)


# Define degree converter
servo_duty_cycles = [[], [], [], [], []]


def degree_converter(servo_number, degree, max_degree):
    duty_cycle_limits = servo_duty_cycles[servo_number]
    duty_cycle_range = duty_cycle_limits[2] - duty_cycle_limits[1]
    if max_degree == 180:
        desired_duty_cycle = degree * duty_cycle_range / 180 + duty_cycle_limits[1]
    elif max_degree ==360:
        desired_duty_cycle = degree * duty_cycle_range / 180 + duty_cycle_limits[1]
    else:
        raise ValueError('Maximum degree not equal to 180 or 360')
    return desired_duty_cycle


# Define servo controller
def servo_controller(servo_number, degree):
    servo_instance(servo_number)
    dc = degree_converter(servo_number,degree)
    servo_instance.start(dc)


<commit_msg>Servo controller fixes.<commit_after>
# Controller for Servos in the Robotic Arm of the MANSEDS Lunar Rover

# Import dependencies
import RPi.GPIO as GPIO
import time

# Set GPIO pin configuration
GPIO.setmode(GPIO.BOARD)


# Declare servo pins
servo_pins = [12]
GPIO.setup(servo_pins, GPIO.OUT)


# Define servo instance
def servo_instance(servo_number):
    servo_1 = GPIO.PWM(12, 50)#servo_pins[servo_number], 50)
    return servo_1


# Define degree converter
servo_duty_cycles = [[2,12], [], [], [], []]


def degree_converter(servo_number, degree, max_degree):
    duty_cycle_limits = servo_duty_cycles[servo_number]
    duty_cycle_range = 10#duty_cycle_limits[2] - duty_cycle_limits[1]
    if max_degree == 180:
        desired_duty_cycle = degree * duty_cycle_range / 180 + 2#duty_cycle_limits[1]
    elif max_degree ==360:
        desired_duty_cycle = degree * duty_cycle_range / 360 + 2#duty_cycle_limits[1]
    else:
        raise ValueError('Maximum degree not equal to 180 or 360')
    return desired_duty_cycle


# Define servo controller
def servo_controller(servo_number, degree):
    dc = degree_converter(servo_number,degree, 180)
    servo_instance(servo_number).start(dc)


while True:
    for i in range(0,180):
        #time.sleep(1)
        servo_controller(1, i)
{'fraction_non_alphanumeric': 0.09087171052631579, 'fraction_numerical': 0.030016447368421052, 'mean_word_length': 4.406666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '466511', 'n_tokens_mistral': 905, 'n_tokens_neox': 800, 'n_words': 196}