diff --git a/openlch/__init__.py b/openlch/__init__.py index 65c83e4..2758a20 100644 --- a/openlch/__init__.py +++ b/openlch/__init__.py @@ -1,3 +1,3 @@ -__version__ = "0.1.0" +__version__ = "0.2.0" from .grpc import Servo \ No newline at end of file diff --git a/openlch/grpc.py b/openlch/grpc.py index 2f8abde..28dc433 100644 --- a/openlch/grpc.py +++ b/openlch/grpc.py @@ -35,7 +35,9 @@ def get_servo_info(self, servo_id): 'current': info.current, 'voltage': round(info.voltage, 2), 'speed': info.speed, - 'current_position': info.current_position + 'current_position': info.current_position, + 'min_position': info.min_position, + 'max_position': info.max_position } else: raise Exception(f"Error: {response.error.message} (Code: {response.error.code})") diff --git a/openlch/hal_pb_pb2.py b/openlch/hal_pb_pb2.py index 15229ae..7db7da3 100644 --- a/openlch/hal_pb_pb2.py +++ b/openlch/hal_pb_pb2.py @@ -24,35 +24,35 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0chal_pb.proto\x12\x06hal_pb\"\x07\n\x05\x45mpty\"-\n\rJointPosition\x12\n\n\x02id\x18\x01 \x01(\x05\x12\x10\n\x08position\x18\x02 \x01(\x02\":\n\x0eJointPositions\x12(\n\tpositions\x18\x01 \x03(\x0b\x32\x15.hal_pb.JointPosition\"1\n\x0fWifiCredentials\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12\x10\n\x08password\x18\x02 \x01(\t\"\x15\n\x07ServoId\x12\n\n\x02id\x18\x01 \x01(\x05\"w\n\tServoInfo\x12\n\n\x02id\x18\x01 \x01(\x05\x12\x13\n\x0btemperature\x18\x02 \x01(\x02\x12\x0f\n\x07\x63urrent\x18\x03 \x01(\x02\x12\x0f\n\x07voltage\x18\x04 \x01(\x02\x12\r\n\x05speed\x18\x05 \x01(\x02\x12\x18\n\x10\x63urrent_position\x18\x06 \x01(\x02\"d\n\x11ServoInfoResponse\x12!\n\x04info\x18\x01 \x01(\x0b\x32\x11.hal_pb.ServoInfoH\x00\x12\"\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.hal_pb.ErrorInfoH\x00\x42\x08\n\x06result\"S\n\x10\x43hangeIdResponse\x12\x11\n\x07success\x18\x01 \x01(\x08H\x00\x12\"\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.hal_pb.ErrorInfoH\x00\x42\x08\n\x06result\"*\n\tErrorInfo\x12\x0f\n\x07message\x18\x01 \x01(\t\x12\x0c\n\x04\x63ode\x18\x02 \x01(\x05\"\x17\n\x08ServoIds\x12\x0b\n\x03ids\x18\x01 \x03(\x05\"*\n\x08IdChange\x12\x0e\n\x06old_id\x18\x01 \x01(\x05\x12\x0e\n\x06new_id\x18\x02 \x01(\x05\x32\xd0\x02\n\x0cServoControl\x12\x35\n\x0cGetPositions\x12\r.hal_pb.Empty\x1a\x16.hal_pb.JointPositions\x12\x35\n\x0cSetPositions\x12\x16.hal_pb.JointPositions\x1a\r.hal_pb.Empty\x12\x35\n\x0bSetWifiInfo\x12\x17.hal_pb.WifiCredentials\x1a\r.hal_pb.Empty\x12:\n\x0cGetServoInfo\x12\x0f.hal_pb.ServoId\x1a\x19.hal_pb.ServoInfoResponse\x12\'\n\x04Scan\x12\r.hal_pb.Empty\x1a\x10.hal_pb.ServoIds\x12\x36\n\x08\x43hangeId\x12\x10.hal_pb.IdChange\x1a\x18.hal_pb.ChangeIdResponseb\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0chal_pb.proto\x12\x06hal_pb\"\x07\n\x05\x45mpty\"-\n\rJointPosition\x12\n\n\x02id\x18\x01 \x01(\x05\x12\x10\n\x08position\x18\x02 \x01(\x02\":\n\x0eJointPositions\x12(\n\tpositions\x18\x01 \x03(\x0b\x32\x15.hal_pb.JointPosition\"1\n\x0fWifiCredentials\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12\x10\n\x08password\x18\x02 \x01(\t\"\x15\n\x07ServoId\x12\n\n\x02id\x18\x01 \x01(\x05\"\xa3\x01\n\tServoInfo\x12\n\n\x02id\x18\x01 \x01(\x05\x12\x13\n\x0btemperature\x18\x02 \x01(\x02\x12\x0f\n\x07\x63urrent\x18\x03 \x01(\x02\x12\x0f\n\x07voltage\x18\x04 \x01(\x02\x12\r\n\x05speed\x18\x05 \x01(\x02\x12\x18\n\x10\x63urrent_position\x18\x06 \x01(\x02\x12\x14\n\x0cmin_position\x18\x07 \x01(\x02\x12\x14\n\x0cmax_position\x18\x08 \x01(\x02\"d\n\x11ServoInfoResponse\x12!\n\x04info\x18\x01 \x01(\x0b\x32\x11.hal_pb.ServoInfoH\x00\x12\"\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.hal_pb.ErrorInfoH\x00\x42\x08\n\x06result\"S\n\x10\x43hangeIdResponse\x12\x11\n\x07success\x18\x01 \x01(\x08H\x00\x12\"\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.hal_pb.ErrorInfoH\x00\x42\x08\n\x06result\"*\n\tErrorInfo\x12\x0f\n\x07message\x18\x01 \x01(\t\x12\x0c\n\x04\x63ode\x18\x02 \x01(\x05\"\x17\n\x08ServoIds\x12\x0b\n\x03ids\x18\x01 \x03(\x05\"*\n\x08IdChange\x12\x0e\n\x06old_id\x18\x01 \x01(\x05\x12\x0e\n\x06new_id\x18\x02 \x01(\x05\x32\xd0\x02\n\x0cServoControl\x12\x35\n\x0cGetPositions\x12\r.hal_pb.Empty\x1a\x16.hal_pb.JointPositions\x12\x35\n\x0cSetPositions\x12\x16.hal_pb.JointPositions\x1a\r.hal_pb.Empty\x12\x35\n\x0bSetWifiInfo\x12\x17.hal_pb.WifiCredentials\x1a\r.hal_pb.Empty\x12:\n\x0cGetServoInfo\x12\x0f.hal_pb.ServoId\x1a\x19.hal_pb.ServoInfoResponse\x12\'\n\x04Scan\x12\r.hal_pb.Empty\x1a\x10.hal_pb.ServoIds\x12\x36\n\x08\x43hangeId\x12\x10.hal_pb.IdChange\x1a\x18.hal_pb.ChangeIdResponseb\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'hal_pb_pb2', _globals) if not _descriptor._USE_C_DESCRIPTORS: - DESCRIPTOR._loaded_options = None - _globals['_EMPTY']._serialized_start=24 - _globals['_EMPTY']._serialized_end=31 - _globals['_JOINTPOSITION']._serialized_start=33 - _globals['_JOINTPOSITION']._serialized_end=78 - _globals['_JOINTPOSITIONS']._serialized_start=80 - _globals['_JOINTPOSITIONS']._serialized_end=138 - _globals['_WIFICREDENTIALS']._serialized_start=140 - _globals['_WIFICREDENTIALS']._serialized_end=189 - _globals['_SERVOID']._serialized_start=191 - _globals['_SERVOID']._serialized_end=212 - _globals['_SERVOINFO']._serialized_start=214 - _globals['_SERVOINFO']._serialized_end=333 - _globals['_SERVOINFORESPONSE']._serialized_start=335 - _globals['_SERVOINFORESPONSE']._serialized_end=435 - _globals['_CHANGEIDRESPONSE']._serialized_start=437 - _globals['_CHANGEIDRESPONSE']._serialized_end=520 - _globals['_ERRORINFO']._serialized_start=522 - _globals['_ERRORINFO']._serialized_end=564 - _globals['_SERVOIDS']._serialized_start=566 - _globals['_SERVOIDS']._serialized_end=589 - _globals['_IDCHANGE']._serialized_start=591 - _globals['_IDCHANGE']._serialized_end=633 - _globals['_SERVOCONTROL']._serialized_start=636 - _globals['_SERVOCONTROL']._serialized_end=972 + DESCRIPTOR._loaded_options = None + _globals['_EMPTY']._serialized_start=24 + _globals['_EMPTY']._serialized_end=31 + _globals['_JOINTPOSITION']._serialized_start=33 + _globals['_JOINTPOSITION']._serialized_end=78 + _globals['_JOINTPOSITIONS']._serialized_start=80 + _globals['_JOINTPOSITIONS']._serialized_end=138 + _globals['_WIFICREDENTIALS']._serialized_start=140 + _globals['_WIFICREDENTIALS']._serialized_end=189 + _globals['_SERVOID']._serialized_start=191 + _globals['_SERVOID']._serialized_end=212 + _globals['_SERVOINFO']._serialized_start=215 + _globals['_SERVOINFO']._serialized_end=378 + _globals['_SERVOINFORESPONSE']._serialized_start=380 + _globals['_SERVOINFORESPONSE']._serialized_end=480 + _globals['_CHANGEIDRESPONSE']._serialized_start=482 + _globals['_CHANGEIDRESPONSE']._serialized_end=565 + _globals['_ERRORINFO']._serialized_start=567 + _globals['_ERRORINFO']._serialized_end=609 + _globals['_SERVOIDS']._serialized_start=611 + _globals['_SERVOIDS']._serialized_end=634 + _globals['_IDCHANGE']._serialized_start=636 + _globals['_IDCHANGE']._serialized_end=678 + _globals['_SERVOCONTROL']._serialized_start=681 + _globals['_SERVOCONTROL']._serialized_end=1017 # @@protoc_insertion_point(module_scope) diff --git a/openlch/hal_pb_pb2_grpc.py b/openlch/hal_pb_pb2_grpc.py index 9d5a277..90140a7 100644 --- a/openlch/hal_pb_pb2_grpc.py +++ b/openlch/hal_pb_pb2_grpc.py @@ -35,35 +35,35 @@ def __init__(self, channel): channel: A grpc.Channel. """ self.GetPositions = channel.unary_unary( - '/hal_pb.ServoControl/GetPositions', - request_serializer=hal__pb__pb2.Empty.SerializeToString, - response_deserializer=hal__pb__pb2.JointPositions.FromString, - _registered_method=True) + '/hal_pb.ServoControl/GetPositions', + request_serializer=hal__pb__pb2.Empty.SerializeToString, + response_deserializer=hal__pb__pb2.JointPositions.FromString, + _registered_method=True) self.SetPositions = channel.unary_unary( - '/hal_pb.ServoControl/SetPositions', - request_serializer=hal__pb__pb2.JointPositions.SerializeToString, - response_deserializer=hal__pb__pb2.Empty.FromString, - _registered_method=True) + '/hal_pb.ServoControl/SetPositions', + request_serializer=hal__pb__pb2.JointPositions.SerializeToString, + response_deserializer=hal__pb__pb2.Empty.FromString, + _registered_method=True) self.SetWifiInfo = channel.unary_unary( - '/hal_pb.ServoControl/SetWifiInfo', - request_serializer=hal__pb__pb2.WifiCredentials.SerializeToString, - response_deserializer=hal__pb__pb2.Empty.FromString, - _registered_method=True) + '/hal_pb.ServoControl/SetWifiInfo', + request_serializer=hal__pb__pb2.WifiCredentials.SerializeToString, + response_deserializer=hal__pb__pb2.Empty.FromString, + _registered_method=True) self.GetServoInfo = channel.unary_unary( - '/hal_pb.ServoControl/GetServoInfo', - request_serializer=hal__pb__pb2.ServoId.SerializeToString, - response_deserializer=hal__pb__pb2.ServoInfoResponse.FromString, - _registered_method=True) + '/hal_pb.ServoControl/GetServoInfo', + request_serializer=hal__pb__pb2.ServoId.SerializeToString, + response_deserializer=hal__pb__pb2.ServoInfoResponse.FromString, + _registered_method=True) self.Scan = channel.unary_unary( - '/hal_pb.ServoControl/Scan', - request_serializer=hal__pb__pb2.Empty.SerializeToString, - response_deserializer=hal__pb__pb2.ServoIds.FromString, - _registered_method=True) + '/hal_pb.ServoControl/Scan', + request_serializer=hal__pb__pb2.Empty.SerializeToString, + response_deserializer=hal__pb__pb2.ServoIds.FromString, + _registered_method=True) self.ChangeId = channel.unary_unary( - '/hal_pb.ServoControl/ChangeId', - request_serializer=hal__pb__pb2.IdChange.SerializeToString, - response_deserializer=hal__pb__pb2.ChangeIdResponse.FromString, - _registered_method=True) + '/hal_pb.ServoControl/ChangeId', + request_serializer=hal__pb__pb2.IdChange.SerializeToString, + response_deserializer=hal__pb__pb2.ChangeIdResponse.FromString, + _registered_method=True) class ServoControlServicer(object): @@ -108,58 +108,58 @@ def ChangeId(self, request, context): def add_ServoControlServicer_to_server(servicer, server): rpc_method_handlers = { - 'GetPositions': grpc.unary_unary_rpc_method_handler( - servicer.GetPositions, - request_deserializer=hal__pb__pb2.Empty.FromString, - response_serializer=hal__pb__pb2.JointPositions.SerializeToString, - ), - 'SetPositions': grpc.unary_unary_rpc_method_handler( - servicer.SetPositions, - request_deserializer=hal__pb__pb2.JointPositions.FromString, - response_serializer=hal__pb__pb2.Empty.SerializeToString, - ), - 'SetWifiInfo': grpc.unary_unary_rpc_method_handler( - servicer.SetWifiInfo, - request_deserializer=hal__pb__pb2.WifiCredentials.FromString, - response_serializer=hal__pb__pb2.Empty.SerializeToString, - ), - 'GetServoInfo': grpc.unary_unary_rpc_method_handler( - servicer.GetServoInfo, - request_deserializer=hal__pb__pb2.ServoId.FromString, - response_serializer=hal__pb__pb2.ServoInfoResponse.SerializeToString, - ), - 'Scan': grpc.unary_unary_rpc_method_handler( - servicer.Scan, - request_deserializer=hal__pb__pb2.Empty.FromString, - response_serializer=hal__pb__pb2.ServoIds.SerializeToString, - ), - 'ChangeId': grpc.unary_unary_rpc_method_handler( - servicer.ChangeId, - request_deserializer=hal__pb__pb2.IdChange.FromString, - response_serializer=hal__pb__pb2.ChangeIdResponse.SerializeToString, - ), + 'GetPositions': grpc.unary_unary_rpc_method_handler( + servicer.GetPositions, + request_deserializer=hal__pb__pb2.Empty.FromString, + response_serializer=hal__pb__pb2.JointPositions.SerializeToString, + ), + 'SetPositions': grpc.unary_unary_rpc_method_handler( + servicer.SetPositions, + request_deserializer=hal__pb__pb2.JointPositions.FromString, + response_serializer=hal__pb__pb2.Empty.SerializeToString, + ), + 'SetWifiInfo': grpc.unary_unary_rpc_method_handler( + servicer.SetWifiInfo, + request_deserializer=hal__pb__pb2.WifiCredentials.FromString, + response_serializer=hal__pb__pb2.Empty.SerializeToString, + ), + 'GetServoInfo': grpc.unary_unary_rpc_method_handler( + servicer.GetServoInfo, + request_deserializer=hal__pb__pb2.ServoId.FromString, + response_serializer=hal__pb__pb2.ServoInfoResponse.SerializeToString, + ), + 'Scan': grpc.unary_unary_rpc_method_handler( + servicer.Scan, + request_deserializer=hal__pb__pb2.Empty.FromString, + response_serializer=hal__pb__pb2.ServoIds.SerializeToString, + ), + 'ChangeId': grpc.unary_unary_rpc_method_handler( + servicer.ChangeId, + request_deserializer=hal__pb__pb2.IdChange.FromString, + response_serializer=hal__pb__pb2.ChangeIdResponse.SerializeToString, + ), } generic_handler = grpc.method_handlers_generic_handler( - 'hal_pb.ServoControl', rpc_method_handlers) + 'hal_pb.ServoControl', rpc_method_handlers) server.add_generic_rpc_handlers((generic_handler,)) server.add_registered_method_handlers('hal_pb.ServoControl', rpc_method_handlers) -# This class is part of an EXPERIMENTAL API. + # This class is part of an EXPERIMENTAL API. class ServoControl(object): """Missing associated documentation comment in .proto file.""" @staticmethod def GetPositions(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): return grpc.experimental.unary_unary( request, target, @@ -178,15 +178,15 @@ def GetPositions(request, @staticmethod def SetPositions(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): return grpc.experimental.unary_unary( request, target, @@ -205,15 +205,15 @@ def SetPositions(request, @staticmethod def SetWifiInfo(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): return grpc.experimental.unary_unary( request, target, @@ -232,15 +232,15 @@ def SetWifiInfo(request, @staticmethod def GetServoInfo(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): return grpc.experimental.unary_unary( request, target, @@ -259,15 +259,15 @@ def GetServoInfo(request, @staticmethod def Scan(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): return grpc.experimental.unary_unary( request, target, @@ -286,15 +286,15 @@ def Scan(request, @staticmethod def ChangeId(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): return grpc.experimental.unary_unary( request, target, diff --git a/openlch/requirements.txt b/openlch/requirements.txt index 3db3b1e..39934f5 100644 --- a/openlch/requirements.txt +++ b/openlch/requirements.txt @@ -4,6 +4,7 @@ websockets pydantic grpcio +protobuf # For the CLI. click