Add MetricsLogging
This commit is contained in:
parent
60f252c37a
commit
3fe3139961
6 changed files with 168 additions and 61 deletions
|
@ -1,36 +1,36 @@
|
|||
from compLib.PCA9685 import PCA9685
|
||||
# from compLib.PCA9685 import PCA9685
|
||||
|
||||
SERVO_COUNT = 10
|
||||
# SERVO_COUNT = 10
|
||||
|
||||
pwm = PCA9685(0x40, debug=True)
|
||||
pwm.setPWMFreq(50)
|
||||
# pwm = PCA9685(0x40, debug=True)
|
||||
# pwm.setPWMFreq(50)
|
||||
|
||||
MIN_ANGLE = -90.0
|
||||
MAX_ANGLE = 90.0
|
||||
# MIN_ANGLE = -90.0
|
||||
# MAX_ANGLE = 90.0
|
||||
|
||||
|
||||
class Servo:
|
||||
"""Control the servo ports on the robot
|
||||
"""
|
||||
# class Servo:
|
||||
# """Control the servo ports on the robot
|
||||
# """
|
||||
|
||||
@staticmethod
|
||||
def set_position(channel: int, angle: int, offset: float =90):
|
||||
"""Set position of servo connected to port
|
||||
# @staticmethod
|
||||
# def set_position(channel: int, angle: int, offset: float =90):
|
||||
# """Set position of servo connected to port
|
||||
|
||||
:param channel: channel between 0 and 7
|
||||
:param angle: Angle of servo
|
||||
"""
|
||||
if channel < 0 or channel >= SERVO_COUNT:
|
||||
raise IndexError("Invalid Servo channel specified!")
|
||||
# :param channel: channel between 0 and 7
|
||||
# :param angle: Angle of servo
|
||||
# """
|
||||
# if channel < 0 or channel >= SERVO_COUNT:
|
||||
# raise IndexError("Invalid Servo channel specified!")
|
||||
|
||||
angle = max(min(angle, MAX_ANGLE), MIN_ANGLE)
|
||||
# angle = max(min(angle, MAX_ANGLE), MIN_ANGLE)
|
||||
|
||||
pwm.setServoPulse(channel + 8, 500+int((angle+offset)/0.09))
|
||||
# pwm.setServoPulse(channel + 8, 500+int((angle+offset)/0.09))
|
||||
|
||||
@staticmethod
|
||||
def setup_position():
|
||||
"""Set position of servos to the position used during the setup process
|
||||
"""
|
||||
# @staticmethod
|
||||
# def setup_position():
|
||||
# """Set position of servos to the position used during the setup process
|
||||
# """
|
||||
|
||||
Servo.set_position(0, 0)
|
||||
Servo.set_position(1, 0)
|
||||
# Servo.set_position(0, 0)
|
||||
# Servo.set_position(1, 0)
|
||||
|
|
Reference in a new issue