Update
This commit is contained in:
parent
d1e385a2a1
commit
1d91792c56
35 changed files with 2275 additions and 237 deletions
|
@ -30,6 +30,31 @@ class Motor(object):
|
|||
|
||||
CompLibClient.send(request.SerializeToString(), request.ByteSize())
|
||||
|
||||
@staticmethod
|
||||
def multiple_power(*arguments: tuple[int, float]):
|
||||
"""Set specified motors to percentage power
|
||||
|
||||
:param arguments: tuples of port, percentage
|
||||
:raises: IndexError
|
||||
"""
|
||||
request = CompLib_pb2.MotorsSetPowerRequest()
|
||||
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!")
|
||||
|
||||
if percent < -100 or percent > 100:
|
||||
raise IndexError("Invalid Motor speed specified! Speed is between -100 and 100 percent!")
|
||||
|
||||
inner_request = CompLib_pb2.MotorSetPowerRequest()
|
||||
inner_request.port = port
|
||||
inner_request.power = percent
|
||||
|
||||
request.requests.append(inner_request)
|
||||
|
||||
CompLibClient.send(request.SerializeToString(), request.ByteSize())
|
||||
|
||||
@staticmethod
|
||||
def speed(port: int, speed: float):
|
||||
"""Set specified motor to percentage power
|
||||
|
@ -49,6 +74,29 @@ class Motor(object):
|
|||
|
||||
CompLibClient.send(request.SerializeToString(), request.ByteSize())
|
||||
|
||||
@staticmethod
|
||||
def multiple_speed(*arguments: tuple[int, float]):
|
||||
"""Set specified motor to percentage power
|
||||
|
||||
:param arguments: tuples of port, speed in rpm
|
||||
:raises: IndexError
|
||||
"""
|
||||
|
||||
request = CompLib_pb2.MotorsSetSpeedRequest()
|
||||
request.header.message_type = request.DESCRIPTOR.full_name
|
||||
|
||||
for port, speed in arguments:
|
||||
if port < 0 or port >= MOTOR_COUNT:
|
||||
raise IndexError("Invalid Motor port specified!")
|
||||
|
||||
inner_request = CompLib_pb2.MotorSetSpeedRequest()
|
||||
inner_request.port = port
|
||||
inner_request.speed = speed
|
||||
|
||||
request.requests.append(inner_request)
|
||||
|
||||
CompLibClient.send(request.SerializeToString(), request.ByteSize())
|
||||
|
||||
# @staticmethod
|
||||
# def all_off():
|
||||
# """
|
||||
|
|
Reference in a new issue