update documentation
This commit is contained in:
parent
6245d1308a
commit
e1a17808f7
24 changed files with 1749 additions and 1014 deletions
|
@ -5,15 +5,15 @@ MOTOR_COUNT = 4
|
|||
|
||||
|
||||
class Motor(object):
|
||||
"""Class used to control the motors
|
||||
"""Klasse zum Ansteuern der Motoren
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def power(port: int, percent: float):
|
||||
"""Set specified motor to percentage power
|
||||
"""Motor auf eine prozentuale Leistung der Höchstgeschwindigkeit einstellen
|
||||
|
||||
:param port: Port, which the motor is connected to. 0-3
|
||||
:param percent: Percentage of max speed. between -100 and 100
|
||||
:param port: Port, an welchen der Motor angestecht wird. 0-3
|
||||
:param percent: Prozentsatz der Höchstgeschwindigkeit. zwischen -100 und 100
|
||||
:raises: IndexError
|
||||
"""
|
||||
|
||||
|
@ -21,9 +21,10 @@ class Motor(object):
|
|||
raise IndexError("Invalid Motor port specified!")
|
||||
|
||||
if percent < -100 or percent > 100:
|
||||
raise IndexError("Invalid Motor speed specified! Speed is between -100 and 100 percent!")
|
||||
raise IndexError(
|
||||
"Invalid Motor speed specified! Speed is between -100 and 100 percent!")
|
||||
|
||||
request = CompLib_pb2.MotorsSetPowerRequest()
|
||||
request = CompLib_pb2.MotorSetPowerRequest()
|
||||
request.header.message_type = request.DESCRIPTOR.full_name
|
||||
request.port = port
|
||||
request.power = percent
|
||||
|
@ -32,9 +33,9 @@ class Motor(object):
|
|||
|
||||
@staticmethod
|
||||
def multiple_power(*arguments: tuple[int, float]):
|
||||
"""Set specified motors to percentage power
|
||||
"""Mehrere Motoren auf eine prozentuale Leistung der Höchstgeschwindigkeit einstellen
|
||||
|
||||
:param arguments: tuples of port, percentage
|
||||
:param arguments: tuple von port, percentage
|
||||
:raises: IndexError
|
||||
"""
|
||||
request = CompLib_pb2.MotorsSetPowerRequest()
|
||||
|
@ -45,7 +46,8 @@ class Motor(object):
|
|||
raise IndexError("Invalid Motor port specified!")
|
||||
|
||||
if percent < -100 or percent > 100:
|
||||
raise IndexError("Invalid Motor speed specified! Speed is between -100 and 100 percent!")
|
||||
raise IndexError(
|
||||
"Invalid Motor speed specified! Speed is between -100 and 100 percent!")
|
||||
|
||||
inner_request = CompLib_pb2.MotorSetPowerRequest()
|
||||
inner_request.port = port
|
||||
|
@ -57,17 +59,17 @@ class Motor(object):
|
|||
|
||||
@staticmethod
|
||||
def speed(port: int, speed: float):
|
||||
"""Set specified motor to percentage power
|
||||
"""Geschwindigkeit des Motors einstellen
|
||||
|
||||
:param port: Port, which the motor is connected to. 0-3
|
||||
:param speed: Speed at which a motor should turn in RPM
|
||||
:param port: Port, an welchen der Motor angestecht wird. 0-3
|
||||
:param speed: Drehzahl, mit der sich ein Motor dreht, in Radianten pro Sekunde (rad/s)
|
||||
:raises: IndexError
|
||||
"""
|
||||
|
||||
if port < 0 or port >= MOTOR_COUNT:
|
||||
raise IndexError("Invalid Motor port specified!")
|
||||
|
||||
request = CompLib_pb2.MotorsSetSpeedRequest()
|
||||
request = CompLib_pb2.MotorSetSpeedRequest()
|
||||
request.header.message_type = request.DESCRIPTOR.full_name
|
||||
request.port = port
|
||||
request.speed = speed
|
||||
|
@ -76,9 +78,9 @@ class Motor(object):
|
|||
|
||||
@staticmethod
|
||||
def multiple_speed(*arguments: tuple[int, float]):
|
||||
"""Set specified motor to percentage power
|
||||
"""Geschwindigkeit mehrerer Motoren einstellen
|
||||
|
||||
:param arguments: tuples of port, speed in rpm
|
||||
:param arguments: tuple von port, Geschwindigkeit in Radianten pro Sekunde (rad/s)
|
||||
:raises: IndexError
|
||||
"""
|
||||
|
||||
|
@ -97,21 +99,44 @@ class Motor(object):
|
|||
|
||||
CompLibClient.send(request.SerializeToString(), request.ByteSize())
|
||||
|
||||
# @staticmethod
|
||||
# def all_off():
|
||||
# """
|
||||
# Turns of all motors
|
||||
# """
|
||||
# Logging.get_logger().debug(f"Motor.all_off")
|
||||
#
|
||||
# for i in range(1, MOTOR_COUNT + 1):
|
||||
# Motor.active_break(i)
|
||||
@staticmethod
|
||||
def pulse_width(port: int, percent: float):
|
||||
"""Setzen den Pulsbreite eines Motors in Prozent der Periode
|
||||
|
||||
# @staticmethod
|
||||
# def active_break(port: int):
|
||||
# """
|
||||
# Actively break with a specific motor
|
||||
#
|
||||
# :param port: Port, which the motor is connected to. 1-4
|
||||
# """
|
||||
# Motor.pwm(port, 0, MotorMode.BREAK)
|
||||
:param port: Port, an welchen der Motor angestecht wird. 0-3
|
||||
:param percent: Prozent der Periode zwischen -100 und 100
|
||||
:raises: IndexError
|
||||
"""
|
||||
|
||||
if port < 0 or port >= MOTOR_COUNT:
|
||||
raise IndexError("Invalid Motor port specified!")
|
||||
|
||||
request = CompLib_pb2.MotorSetPulseWidthRequest()
|
||||
request.header.message_type = request.DESCRIPTOR.full_name
|
||||
request.port = port
|
||||
request.percent = percent
|
||||
|
||||
CompLibClient.send(request.SerializeToString(), request.ByteSize())
|
||||
|
||||
@staticmethod
|
||||
def multiple_pulse_width(*arguments: tuple[int, float]):
|
||||
"""Setzen den Pulsbreite mehreer Motoren in Prozent der Periode
|
||||
|
||||
:param arguments: tuple von port, prozent
|
||||
:raises: IndexError
|
||||
"""
|
||||
|
||||
request = CompLib_pb2.MotorsSetPulseWidthRequest()
|
||||
request.header.message_type = request.DESCRIPTOR.full_name
|
||||
|
||||
for port, percent in arguments:
|
||||
if port < 0 or port >= MOTOR_COUNT:
|
||||
raise IndexError("Invalid Motor port specified!")
|
||||
|
||||
inner_request = CompLib_pb2.MotorSetPulseWidthRequest()
|
||||
inner_request.port = port
|
||||
inner_request.percent = percent
|
||||
|
||||
request.requests.append(inner_request)
|
||||
|
||||
CompLibClient.send(request.SerializeToString(), request.ByteSize())
|
||||
|
|
Reference in a new issue