Command: Exception in thread Thread-3 (execute_file):
Traceback (most recent call last):
File "/usr/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/usr/lib/python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "/home/quintindunn/stringartrobot/robot/robot/string_bot.py", line 53, in execute_file
instruction.execute()
File "/home/quintindunn/stringartrobot/robot/robot/instructions.py", line 126, in execute
rotate_arm_to(degrees=self.degrees)
File "/home/quintindunn/stringartrobot/robot/robot/hardware_api/rotate_servo.py", line 33, in rotate_arm_to
servo.value = degrees
^^^^^^^^^^^
File "/home/quintindunn/.local/lib/python3.12/site-packages/gpiozero/devices.py", line 454, in __setattr__
return super().__setattr__(name, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/quintindunn/.local/lib/python3.12/site-packages/gpiozero/devices.py", line 130, in __setattr__
return super().__setattr__(name, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/quintindunn/.local/lib/python3.12/site-packages/gpiozero/output_devices.py", line 1622, in value
raise OutputDeviceBadValue(
gpiozero.exc.OutputDeviceBadValue: Servo value must be between -1 and 1, or None
Working servo code, needs to adapt program to use this method:
def set_servo_angle(angle):
# Clamp the angle between -90 and 90 degrees
angle = max(-90, min(90, angle))
# Convert angle (-90 to 90) to value (-1 to 1)
value = angle / 90
servo.value = value
Working servo code, needs to adapt program to use this method: