From 3380daefdf98a78a6566fa104489ed346ea3f9b0 Mon Sep 17 00:00:00 2001 From: budzianowski Date: Wed, 22 Jan 2025 19:58:32 -0800 Subject: [PATCH 1/5] update services --- kos-py/pykos/client.py | 18 +- kos-py/pykos/services/speech.py | 83 +++++++ kos-stub/src/lib.rs | 12 +- kos-stub/src/speech.rs | 43 ++++ kos/build.rs | 1 + kos/proto/kos/speech.proto | 37 +++ kos/src/daemon.rs | 1 + kos/src/grpc_interface.rs | 4 + kos/src/hal.rs | 9 +- kos/src/lib.rs | 11 +- kos/src/services/mod.rs | 2 + kos/src/services/speech.rs | 43 ++++ kos_core/kos/actuator_pb2.py | 62 +++++ kos_core/kos/actuator_pb2_grpc.py | 235 +++++++++++++++++++ kos_core/kos/common_pb2.py | 43 ++++ kos_core/kos/common_pb2_grpc.py | 24 ++ kos_core/kos/imu_pb2.py | 55 +++++ kos_core/kos/imu_pb2_grpc.py | 280 +++++++++++++++++++++++ kos_core/kos/inference_pb2.py | 47 ++++ kos_core/kos/inference_pb2_grpc.py | 145 ++++++++++++ kos_core/kos/process_manager_pb2.py | 45 ++++ kos_core/kos/process_manager_pb2_grpc.py | 146 ++++++++++++ kos_core/kos/system_pb2.py | 61 +++++ kos_core/kos/system_pb2_grpc.py | 280 +++++++++++++++++++++++ test.py | 10 + 25 files changed, 1693 insertions(+), 4 deletions(-) create mode 100644 kos-py/pykos/services/speech.py create mode 100644 kos-stub/src/speech.rs create mode 100644 kos/proto/kos/speech.proto create mode 100644 kos/src/services/speech.rs create mode 100644 kos_core/kos/actuator_pb2.py create mode 100644 kos_core/kos/actuator_pb2_grpc.py create mode 100644 kos_core/kos/common_pb2.py create mode 100644 kos_core/kos/common_pb2_grpc.py create mode 100644 kos_core/kos/imu_pb2.py create mode 100644 kos_core/kos/imu_pb2_grpc.py create mode 100644 kos_core/kos/inference_pb2.py create mode 100644 kos_core/kos/inference_pb2_grpc.py create mode 100644 kos_core/kos/process_manager_pb2.py create mode 100644 kos_core/kos/process_manager_pb2_grpc.py create mode 100644 kos_core/kos/system_pb2.py create mode 100644 kos_core/kos/system_pb2_grpc.py create mode 100644 test.py diff --git a/kos-py/pykos/client.py b/kos-py/pykos/client.py index 2c0a8f4..5bd0500 100644 --- a/kos-py/pykos/client.py +++ b/kos-py/pykos/client.py @@ -12,6 +12,7 @@ from pykos.services.process_manager import ProcessManagerServiceClient from pykos.services.sim import SimServiceClient from pykos.services.sound import SoundServiceClient +from pykos.services.speech import SpeechServiceClient class KOS: @@ -23,6 +24,13 @@ class KOS: Attributes: imu (IMUServiceClient): Client for the IMU service. + actuator (ActuatorServiceClient): Client for the actuator service. + led_matrix (LEDMatrixServiceClient): Client for the LED matrix service. + sound (SoundServiceClient): Client for the sound service. + process_manager (ProcessManagerServiceClient): Client for the process manager service. + inference (InferenceServiceClient): Client for the inference service. + sim (SimServiceClient): Client for the simulation service. + speech (SpeechServiceClient): Client for the speech service. """ def __init__(self, ip: str = "localhost", port: int = 50051) -> None: @@ -36,6 +44,7 @@ def __init__(self, ip: str = "localhost", port: int = 50051) -> None: self._process_manager: ProcessManagerServiceClient | None = None self._inference: InferenceServiceClient | None = None self._sim: SimServiceClient | None = None + self._speech: SpeechServiceClient | None = None @property def imu(self) -> IMUServiceClient: @@ -79,14 +88,21 @@ def sim(self) -> SimServiceClient: raise RuntimeError("Sim client not initialized! Must call __aenter__() first.") return self._sim + @property + def speech(self) -> SpeechServiceClient: + if self._speech is None: + raise RuntimeError("Speech client not initialized! Must call __aenter__() first.") + return self._speech + async def connect(self) -> None: """Connect to the gRPC server and initialize service clients.""" self._channel = grpc.aio.insecure_channel(f"{self.ip}:{self.port}") + self._process_manager = ProcessManagerServiceClient(self._channel) self._imu = IMUServiceClient(self._channel) self._actuator = ActuatorServiceClient(self._channel) self._led_matrix = LEDMatrixServiceClient(self._channel) self._sound = SoundServiceClient(self._channel) - self._process_manager = ProcessManagerServiceClient(self._channel) + self._speech = SpeechServiceClient(self._channel) self._inference = InferenceServiceClient(self._channel) self._sim = SimServiceClient(self._channel) diff --git a/kos-py/pykos/services/speech.py b/kos-py/pykos/services/speech.py new file mode 100644 index 0000000..4265a0f --- /dev/null +++ b/kos-py/pykos/services/speech.py @@ -0,0 +1,83 @@ +"""Speech service client.""" + +from typing import TypedDict, Unpack + +import grpc +import grpc.aio + +from kos_protos import speech_pb2, speech_pb2_grpc + + +class AudioConfig(TypedDict): + """Audio configuration parameters. + + Args: + sample_rate: Sample rate in Hz (e.g., 44100) + bit_depth: Bit depth (e.g., 16) + channels: Number of channels (1 for mono, 2 for stereo) + """ + sample_rate: int + bit_depth: int + channels: int + + +class SpeechServiceClient: + """Client for the SpeechService. + + This service provides text-to-speech synthesis and speech-to-text transcription. + """ + + def __init__(self, channel: grpc.aio.Channel) -> None: + """Initialize the speech service client. + + Args: + channel: gRPC channel to use for communication. + """ + self.stub = speech_pb2_grpc.SpeechServiceStub(channel) + + async def synthesize(self, text: str, **kwargs: Unpack[AudioConfig]) -> str: + """Synthesize speech from text. + + Args: + text: Text to synthesize + **kwargs: Audio configuration parameters + sample_rate: Sample rate in Hz (e.g., 44100) + bit_depth: Bit depth (e.g., 16) + channels: Number of channels (1 for mono, 2 for stereo) + + Returns: + Audio data as a string. + + Raises: + RuntimeError: If synthesis fails. + """ + request = speech_pb2.SynthesizeRequest( + text=text, + config=speech_pb2.AudioConfig(**kwargs) if kwargs else None, + ) + + response = await self.stub.Synthesize(request) + if response.HasField("error"): + raise RuntimeError(f"Synthesis error: {response.error}") + return response.audio_data + + async def transcribe(self, audio_data: str) -> str: + """Transcribe speech to text. + + Args: + audio_data: Audio data to transcribe + + Returns: + Transcribed text. + + Raises: + RuntimeError: If transcription fails. + """ + request = speech_pb2.TranscribeRequest( + audio_data=audio_data, + ) + + response = await self.stub.Transcribe(request) + if response.HasField("error"): + raise RuntimeError(f"Transcription error: {response.error}") + return response.text \ No newline at end of file diff --git a/kos-stub/src/lib.rs b/kos-stub/src/lib.rs index 8cba942..8874a04 100644 --- a/kos-stub/src/lib.rs +++ b/kos-stub/src/lib.rs @@ -1,15 +1,21 @@ mod actuator; mod imu; mod process_manager; +mod speech; use crate::actuator::StubActuator; use crate::imu::StubIMU; use crate::process_manager::StubProcessManager; +use crate::speech::StubSpeech; use async_trait::async_trait; use kos::hal::Operation; use kos::kos_proto::actuator::actuator_service_server::ActuatorServiceServer; use kos::kos_proto::imu::imu_service_server::ImuServiceServer; use kos::kos_proto::process_manager::process_manager_service_server::ProcessManagerServiceServer; -use kos::services::{ActuatorServiceImpl, IMUServiceImpl, ProcessManagerServiceImpl}; +use kos::kos_proto::speech::speech_service_server::SpeechServiceServer; +use kos::services::{ + ActuatorServiceImpl, IMUServiceImpl, ProcessManagerServiceImpl, SpeechServiceImpl, +}; + use kos::{services::OperationsServiceImpl, Platform, ServiceEnum}; use std::future::Future; use std::pin::Pin; @@ -52,6 +58,7 @@ impl Platform for StubPlatform { let actuator = StubActuator::new(operations_service.clone()); let imu = StubIMU::new(operations_service.clone()); let process_manager = StubProcessManager::new(); + let speech = StubSpeech::new(); Ok(vec![ ServiceEnum::Actuator(ActuatorServiceServer::new(ActuatorServiceImpl::new( @@ -61,6 +68,9 @@ impl Platform for StubPlatform { ProcessManagerServiceImpl::new(Arc::new(process_manager)), )), ServiceEnum::Imu(ImuServiceServer::new(IMUServiceImpl::new(Arc::new(imu)))), + ServiceEnum::Speech(SpeechServiceServer::new(SpeechServiceImpl::new(Arc::new( + speech, + )))), ]) }) } diff --git a/kos-stub/src/speech.rs b/kos-stub/src/speech.rs new file mode 100644 index 0000000..54701d1 --- /dev/null +++ b/kos-stub/src/speech.rs @@ -0,0 +1,43 @@ +use async_trait::async_trait; +use kos::hal::Speech; +use std::process::Command; +use uuid::Uuid; +use kos::kos_proto::speech::SynthesizeResponse; + + +pub struct StubSpeech {} + +impl Default for StubSpeech { + fn default() -> Self { + Self::new() + } +} + +impl StubSpeech { + pub fn new() -> Self { + StubSpeech {} + } +} + +#[async_trait] +impl Speech for StubSpeech { + async fn synthesize(&self, text: String) -> Result { + // Generate a unique filename for the wav output + let output_file = format!("/tmp/speech_{}.wav", Uuid::new_v4()); + + // Create espeak command + Command::new("espeak") + .args([ + "-w", + &output_file, + "-v", + "en", + &text, + ]); + + Ok(SynthesizeResponse { + output_file: output_file, + error: None, + }) + } +} diff --git a/kos/build.rs b/kos/build.rs index cc4a475..b3e1b74 100644 --- a/kos/build.rs +++ b/kos/build.rs @@ -19,6 +19,7 @@ fn main() { "kos/system.proto", "kos/led_matrix.proto", "kos/sound.proto", + "kos/speech.proto", "google/longrunning/operations.proto", ]; diff --git a/kos/proto/kos/speech.proto b/kos/proto/kos/speech.proto new file mode 100644 index 0000000..3d5aa17 --- /dev/null +++ b/kos/proto/kos/speech.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +package kos.speech; + +import "google/protobuf/empty.proto"; +import "kos/common.proto"; + +option go_package = "kos/speech;speech"; +option java_package = "com.kos.speech"; +option csharp_namespace = "KOS.Speech"; + +// The SpeechService provides methods to transcribe or synthesize speech +service SpeechService { + // Transcribes speech to text + rpc Transcribe(TranscribeRequest) returns (TranscribeResponse); + + // Synthesizes speech from text + rpc Synthesize(SynthesizeRequest) returns (SynthesizeResponse); +} + +message TranscribeRequest { + string audio_data = 1; +} + +message TranscribeResponse { + string text = 1; + kos.common.Error error = 2; +} + +message SynthesizeRequest { + string text = 1; +} + +message SynthesizeResponse { + string output_file = 1; + kos.common.Error error = 2; +} diff --git a/kos/src/daemon.rs b/kos/src/daemon.rs index a69ba83..34bafa6 100644 --- a/kos/src/daemon.rs +++ b/kos/src/daemon.rs @@ -40,6 +40,7 @@ fn add_service_to_router( ServiceEnum::Inference(svc) => router.add_service(svc), ServiceEnum::LEDMatrix(svc) => router.add_service(svc), ServiceEnum::Sound(svc) => router.add_service(svc), + ServiceEnum::Speech(svc) => router.add_service(svc), } } diff --git a/kos/src/grpc_interface.rs b/kos/src/grpc_interface.rs index 8c21486..b7ec1a4 100644 --- a/kos/src/grpc_interface.rs +++ b/kos/src/grpc_interface.rs @@ -30,6 +30,10 @@ pub mod kos { pub mod sound { tonic::include_proto!("kos/kos.sound"); } + + pub mod speech { + tonic::include_proto!("kos/kos.speech"); + } } pub mod google { diff --git a/kos/src/hal.rs b/kos/src/hal.rs index 77f9e1e..acaf4bb 100644 --- a/kos/src/hal.rs +++ b/kos/src/hal.rs @@ -3,7 +3,7 @@ pub use crate::grpc_interface::kos; pub use crate::grpc_interface::kos::common::ActionResponse; pub use crate::kos_proto::{ actuator::*, common::ActionResult, imu::*, inference::*, led_matrix::*, process_manager::*, - sound::*, + sound::*, speech::*, }; use async_trait::async_trait; use bytes::Bytes; @@ -107,6 +107,13 @@ pub trait Sound: Send + Sync { async fn stop_recording(&self) -> Result; } +// TODO action response pfb30 +#[async_trait] +pub trait Speech: Send + Sync { + // async fn start_kclip(&self, action: String) -> Result; + async fn synthesize(&self, text: String) -> Result; +} + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum CalibrationStatus { Calibrating, diff --git a/kos/src/lib.rs b/kos/src/lib.rs index b4da246..55ed7d7 100644 --- a/kos/src/lib.rs +++ b/kos/src/lib.rs @@ -10,6 +10,7 @@ pub mod services; pub mod telemetry; pub mod telemetry_types; + pub use grpc_interface::google as google_proto; pub use grpc_interface::kos as kos_proto; @@ -20,10 +21,11 @@ use hal::inference_service_server::InferenceServiceServer; use hal::led_matrix_service_server::LedMatrixServiceServer; use hal::process_manager_service_server::ProcessManagerServiceServer; use hal::sound_service_server::SoundServiceServer; +use hal::speech_service_server::SpeechServiceServer; use services::OperationsServiceImpl; use services::{ ActuatorServiceImpl, IMUServiceImpl, InferenceServiceImpl, LEDMatrixServiceImpl, - ProcessManagerServiceImpl, SoundServiceImpl, + ProcessManagerServiceImpl, SoundServiceImpl, SpeechServiceImpl, }; use std::fmt::Debug; use std::future::Future; @@ -66,6 +68,12 @@ impl Debug for SoundServiceImpl { } } +impl Debug for SpeechServiceImpl { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "SpeechServiceImpl") + } +} + #[derive(Debug)] pub enum ServiceEnum { Actuator(ActuatorServiceServer), @@ -74,6 +82,7 @@ pub enum ServiceEnum { Inference(InferenceServiceServer), LEDMatrix(LedMatrixServiceServer), Sound(SoundServiceServer), + Speech(SpeechServiceServer), } #[async_trait] diff --git a/kos/src/services/mod.rs b/kos/src/services/mod.rs index 075c804..d5af47b 100644 --- a/kos/src/services/mod.rs +++ b/kos/src/services/mod.rs @@ -6,6 +6,7 @@ mod led_matrix; mod operations; mod process_manager; mod sound; +mod speech; pub use actuator::*; pub use imu::*; @@ -15,3 +16,4 @@ pub use led_matrix::*; pub use operations::*; pub use process_manager::*; pub use sound::*; +pub use speech::*; \ No newline at end of file diff --git a/kos/src/services/speech.rs b/kos/src/services/speech.rs new file mode 100644 index 0000000..374697a --- /dev/null +++ b/kos/src/services/speech.rs @@ -0,0 +1,43 @@ +use crate::hal::Speech; +use crate::kos_proto::speech::speech_service_server::SpeechService; +use crate::kos_proto::speech::*; +use std::sync::Arc; +use tonic::{Request, Response, Status}; +use tracing::trace; + +pub struct SpeechServiceImpl { + speech: Arc, +} + +impl SpeechServiceImpl { + pub fn new(speech: Arc) -> Self { + Self { speech } + } +} + +#[tonic::async_trait] +impl SpeechService for SpeechServiceImpl { + async fn synthesize( + &self, + request: Request, + ) -> Result, Status> { + let req = request.into_inner(); + trace!("Synthesizing text: {}", req.text); + + + Ok(Response::new( + self + .speech + .synthesize(req.text) + .await + .map_err(|e| Status::internal(format!("Failed to synthesize text, {:?}", e)))?, + )) + } + + async fn transcribe( + &self, + request: Request, + ) -> Result, Status> { + Err(Status::unimplemented("Transcribe not implemented")) + } +} \ No newline at end of file diff --git a/kos_core/kos/actuator_pb2.py b/kos_core/kos/actuator_pb2.py new file mode 100644 index 0000000..82716a0 --- /dev/null +++ b/kos_core/kos/actuator_pb2.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: kos/actuator.proto +# Protobuf Python Version: 5.28.1 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 28, + 1, + '', + 'kos/actuator.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 +from kos import common_pb2 as kos_dot_common__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12kos/actuator.proto\x12\x0ckos.actuator\x1a\x1bgoogle/protobuf/empty.proto\x1a#google/longrunning/operations.proto\x1a\x10kos/common.proto\"\x8e\x01\n\x0f\x41\x63tuatorCommand\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12\x15\n\x08position\x18\x02 \x01(\x01H\x00\x88\x01\x01\x12\x15\n\x08velocity\x18\x03 \x01(\x01H\x01\x88\x01\x01\x12\x13\n\x06torque\x18\x04 \x01(\x01H\x02\x88\x01\x01\x42\x0b\n\t_positionB\x0b\n\t_velocityB\t\n\x07_torque\"J\n\x17\x43ommandActuatorsRequest\x12/\n\x08\x63ommands\x18\x01 \x03(\x0b\x32\x1d.kos.actuator.ActuatorCommand\"E\n\x18\x43ommandActuatorsResponse\x12)\n\x07results\x18\x01 \x03(\x0b\x32\x18.kos.common.ActionResult\"\x97\x03\n\x18\x43onfigureActuatorRequest\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12\x0f\n\x02kp\x18\x02 \x01(\x01H\x00\x88\x01\x01\x12\x0f\n\x02kd\x18\x03 \x01(\x01H\x01\x88\x01\x01\x12\x0f\n\x02ki\x18\x04 \x01(\x01H\x02\x88\x01\x01\x12\x17\n\nmax_torque\x18\x05 \x01(\x01H\x03\x88\x01\x01\x12\x1e\n\x11protective_torque\x18\x06 \x01(\x01H\x04\x88\x01\x01\x12\x1c\n\x0fprotection_time\x18\x07 \x01(\x02H\x05\x88\x01\x01\x12\x1b\n\x0etorque_enabled\x18\x08 \x01(\x08H\x06\x88\x01\x01\x12\x1c\n\x0fnew_actuator_id\x18\t \x01(\rH\x07\x88\x01\x01\x12\x1a\n\rzero_position\x18\n \x01(\x08H\x08\x88\x01\x01\x42\x05\n\x03_kpB\x05\n\x03_kdB\x05\n\x03_kiB\r\n\x0b_max_torqueB\x14\n\x12_protective_torqueB\x12\n\x10_protection_timeB\x11\n\x0f_torque_enabledB\x12\n\x10_new_actuator_idB\x10\n\x0e_zero_position\"\x9b\x01\n\x18\x43\x61librateActuatorRequest\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12\x1e\n\x11\x63\x61libration_speed\x18\x02 \x01(\x01H\x00\x88\x01\x01\x12\x1e\n\x11threshold_current\x18\x03 \x01(\x02H\x01\x88\x01\x01\x42\x14\n\x12_calibration_speedB\x14\n\x12_threshold_current\"R\n\x19\x43\x61librateActuatorResponse\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.Error\"@\n\x19\x43\x61librateActuatorMetadata\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12\x0e\n\x06status\x18\x02 \x01(\t\"0\n\x18GetActuatorsStateRequest\x12\x14\n\x0c\x61\x63tuator_ids\x18\x01 \x03(\r\"P\n\x19GetActuatorsStateResponse\x12\x33\n\x06states\x18\x01 \x03(\x0b\x32#.kos.actuator.ActuatorStateResponse\"\x92\x02\n\x15\x41\x63tuatorStateResponse\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12\x0e\n\x06online\x18\x02 \x01(\x08\x12\x15\n\x08position\x18\x03 \x01(\x01H\x00\x88\x01\x01\x12\x15\n\x08velocity\x18\x04 \x01(\x01H\x01\x88\x01\x01\x12\x13\n\x06torque\x18\x05 \x01(\x01H\x02\x88\x01\x01\x12\x18\n\x0btemperature\x18\x06 \x01(\x01H\x03\x88\x01\x01\x12\x14\n\x07voltage\x18\x07 \x01(\x02H\x04\x88\x01\x01\x12\x14\n\x07\x63urrent\x18\x08 \x01(\x02H\x05\x88\x01\x01\x42\x0b\n\t_positionB\x0b\n\t_velocityB\t\n\x07_torqueB\x0e\n\x0c_temperatureB\n\n\x08_voltageB\n\n\x08_current2\xcb\x03\n\x0f\x41\x63tuatorService\x12\x61\n\x10\x43ommandActuators\x12%.kos.actuator.CommandActuatorsRequest\x1a&.kos.actuator.CommandActuatorsResponse\x12W\n\x11\x43onfigureActuator\x12&.kos.actuator.ConfigureActuatorRequest\x1a\x1a.kos.common.ActionResponse\x12\x95\x01\n\x11\x43\x61librateActuator\x12&.kos.actuator.CalibrateActuatorRequest\x1a\x1d.google.longrunning.Operation\"9\xca\x41\x36\n\x19\x43\x61librateActuatorResponse\x12\x19\x43\x61librateActuatorMetadata\x12\x64\n\x11GetActuatorsState\x12&.kos.actuator.GetActuatorsStateRequest\x1a\'.kos.actuator.GetActuatorsStateResponseB8\n\x10\x63om.kos.actuatorZ\x15kos/actuator;actuator\xaa\x02\x0cKOS.Actuatorb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'kos.actuator_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\020com.kos.actuatorZ\025kos/actuator;actuator\252\002\014KOS.Actuator' + _globals['_ACTUATORSERVICE'].methods_by_name['CalibrateActuator']._loaded_options = None + _globals['_ACTUATORSERVICE'].methods_by_name['CalibrateActuator']._serialized_options = b'\312A6\n\031CalibrateActuatorResponse\022\031CalibrateActuatorMetadata' + _globals['_ACTUATORCOMMAND']._serialized_start=121 + _globals['_ACTUATORCOMMAND']._serialized_end=263 + _globals['_COMMANDACTUATORSREQUEST']._serialized_start=265 + _globals['_COMMANDACTUATORSREQUEST']._serialized_end=339 + _globals['_COMMANDACTUATORSRESPONSE']._serialized_start=341 + _globals['_COMMANDACTUATORSRESPONSE']._serialized_end=410 + _globals['_CONFIGUREACTUATORREQUEST']._serialized_start=413 + _globals['_CONFIGUREACTUATORREQUEST']._serialized_end=820 + _globals['_CALIBRATEACTUATORREQUEST']._serialized_start=823 + _globals['_CALIBRATEACTUATORREQUEST']._serialized_end=978 + _globals['_CALIBRATEACTUATORRESPONSE']._serialized_start=980 + _globals['_CALIBRATEACTUATORRESPONSE']._serialized_end=1062 + _globals['_CALIBRATEACTUATORMETADATA']._serialized_start=1064 + _globals['_CALIBRATEACTUATORMETADATA']._serialized_end=1128 + _globals['_GETACTUATORSSTATEREQUEST']._serialized_start=1130 + _globals['_GETACTUATORSSTATEREQUEST']._serialized_end=1178 + _globals['_GETACTUATORSSTATERESPONSE']._serialized_start=1180 + _globals['_GETACTUATORSSTATERESPONSE']._serialized_end=1260 + _globals['_ACTUATORSTATERESPONSE']._serialized_start=1263 + _globals['_ACTUATORSTATERESPONSE']._serialized_end=1537 + _globals['_ACTUATORSERVICE']._serialized_start=1540 + _globals['_ACTUATORSERVICE']._serialized_end=1999 +# @@protoc_insertion_point(module_scope) diff --git a/kos_core/kos/actuator_pb2_grpc.py b/kos_core/kos/actuator_pb2_grpc.py new file mode 100644 index 0000000..5ab751d --- /dev/null +++ b/kos_core/kos/actuator_pb2_grpc.py @@ -0,0 +1,235 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc +import warnings + +from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 +from kos import actuator_pb2 as kos_dot_actuator__pb2 +from kos import common_pb2 as kos_dot_common__pb2 + +GRPC_GENERATED_VERSION = '1.68.1' +GRPC_VERSION = grpc.__version__ +_version_not_supported = False + +try: + from grpc._utilities import first_version_is_lower + _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) +except ImportError: + _version_not_supported = True + +if _version_not_supported: + raise RuntimeError( + f'The grpc package installed is at version {GRPC_VERSION},' + + f' but the generated code in kos/actuator_pb2_grpc.py depends on' + + f' grpcio>={GRPC_GENERATED_VERSION}.' + + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' + + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' + ) + + +class ActuatorServiceStub(object): + """The ActuatorService provides methods to control and monitor actuators. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.CommandActuators = channel.unary_unary( + '/kos.actuator.ActuatorService/CommandActuators', + request_serializer=kos_dot_actuator__pb2.CommandActuatorsRequest.SerializeToString, + response_deserializer=kos_dot_actuator__pb2.CommandActuatorsResponse.FromString, + _registered_method=True) + self.ConfigureActuator = channel.unary_unary( + '/kos.actuator.ActuatorService/ConfigureActuator', + request_serializer=kos_dot_actuator__pb2.ConfigureActuatorRequest.SerializeToString, + response_deserializer=kos_dot_common__pb2.ActionResponse.FromString, + _registered_method=True) + self.CalibrateActuator = channel.unary_unary( + '/kos.actuator.ActuatorService/CalibrateActuator', + request_serializer=kos_dot_actuator__pb2.CalibrateActuatorRequest.SerializeToString, + response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, + _registered_method=True) + self.GetActuatorsState = channel.unary_unary( + '/kos.actuator.ActuatorService/GetActuatorsState', + request_serializer=kos_dot_actuator__pb2.GetActuatorsStateRequest.SerializeToString, + response_deserializer=kos_dot_actuator__pb2.GetActuatorsStateResponse.FromString, + _registered_method=True) + + +class ActuatorServiceServicer(object): + """The ActuatorService provides methods to control and monitor actuators. + """ + + def CommandActuators(self, request, context): + """Commands multiple actuators at once. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def ConfigureActuator(self, request, context): + """Configures an actuator's parameters. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CalibrateActuator(self, request, context): + """Calibrates an actuator (long-running operation). + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetActuatorsState(self, request, context): + """Retrieves the state of multiple actuators. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_ActuatorServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'CommandActuators': grpc.unary_unary_rpc_method_handler( + servicer.CommandActuators, + request_deserializer=kos_dot_actuator__pb2.CommandActuatorsRequest.FromString, + response_serializer=kos_dot_actuator__pb2.CommandActuatorsResponse.SerializeToString, + ), + 'ConfigureActuator': grpc.unary_unary_rpc_method_handler( + servicer.ConfigureActuator, + request_deserializer=kos_dot_actuator__pb2.ConfigureActuatorRequest.FromString, + response_serializer=kos_dot_common__pb2.ActionResponse.SerializeToString, + ), + 'CalibrateActuator': grpc.unary_unary_rpc_method_handler( + servicer.CalibrateActuator, + request_deserializer=kos_dot_actuator__pb2.CalibrateActuatorRequest.FromString, + response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, + ), + 'GetActuatorsState': grpc.unary_unary_rpc_method_handler( + servicer.GetActuatorsState, + request_deserializer=kos_dot_actuator__pb2.GetActuatorsStateRequest.FromString, + response_serializer=kos_dot_actuator__pb2.GetActuatorsStateResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'kos.actuator.ActuatorService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + server.add_registered_method_handlers('kos.actuator.ActuatorService', rpc_method_handlers) + + + # This class is part of an EXPERIMENTAL API. +class ActuatorService(object): + """The ActuatorService provides methods to control and monitor actuators. + """ + + @staticmethod + def CommandActuators(request, + 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, + '/kos.actuator.ActuatorService/CommandActuators', + kos_dot_actuator__pb2.CommandActuatorsRequest.SerializeToString, + kos_dot_actuator__pb2.CommandActuatorsResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def ConfigureActuator(request, + 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, + '/kos.actuator.ActuatorService/ConfigureActuator', + kos_dot_actuator__pb2.ConfigureActuatorRequest.SerializeToString, + kos_dot_common__pb2.ActionResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def CalibrateActuator(request, + 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, + '/kos.actuator.ActuatorService/CalibrateActuator', + kos_dot_actuator__pb2.CalibrateActuatorRequest.SerializeToString, + google_dot_longrunning_dot_operations__pb2.Operation.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def GetActuatorsState(request, + 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, + '/kos.actuator.ActuatorService/GetActuatorsState', + kos_dot_actuator__pb2.GetActuatorsStateRequest.SerializeToString, + kos_dot_actuator__pb2.GetActuatorsStateResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) diff --git a/kos_core/kos/common_pb2.py b/kos_core/kos/common_pb2.py new file mode 100644 index 0000000..c0050cb --- /dev/null +++ b/kos_core/kos/common_pb2.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: kos/common.proto +# Protobuf Python Version: 5.28.1 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 28, + 1, + '', + 'kos/common.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10kos/common.proto\x12\nkos.common\"=\n\x05\x45rror\x12#\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x15.kos.common.ErrorCode\x12\x0f\n\x07message\x18\x02 \x01(\t\"C\n\x0e\x41\x63tionResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.Error\"V\n\x0c\x41\x63tionResult\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12\x0f\n\x07success\x18\x02 \x01(\x08\x12 \n\x05\x65rror\x18\x03 \x01(\x0b\x32\x11.kos.common.Error*x\n\tErrorCode\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x13\n\x0fNOT_IMPLEMENTED\x10\x01\x12\x14\n\x10INVALID_ARGUMENT\x10\x02\x12\x14\n\x10HARDWARE_FAILURE\x10\x03\x12\x0b\n\x07TIMEOUT\x10\x04\x12\x10\n\x0cUNAUTHORIZED\x10\x05\x42\x30\n\x0e\x63om.kos.commonZ\x11kos/common;common\xaa\x02\nKOS.Commonb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'kos.common_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\016com.kos.commonZ\021kos/common;common\252\002\nKOS.Common' + _globals['_ERRORCODE']._serialized_start=252 + _globals['_ERRORCODE']._serialized_end=372 + _globals['_ERROR']._serialized_start=32 + _globals['_ERROR']._serialized_end=93 + _globals['_ACTIONRESPONSE']._serialized_start=95 + _globals['_ACTIONRESPONSE']._serialized_end=162 + _globals['_ACTIONRESULT']._serialized_start=164 + _globals['_ACTIONRESULT']._serialized_end=250 +# @@protoc_insertion_point(module_scope) diff --git a/kos_core/kos/common_pb2_grpc.py b/kos_core/kos/common_pb2_grpc.py new file mode 100644 index 0000000..1d0f29e --- /dev/null +++ b/kos_core/kos/common_pb2_grpc.py @@ -0,0 +1,24 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc +import warnings + + +GRPC_GENERATED_VERSION = '1.68.1' +GRPC_VERSION = grpc.__version__ +_version_not_supported = False + +try: + from grpc._utilities import first_version_is_lower + _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) +except ImportError: + _version_not_supported = True + +if _version_not_supported: + raise RuntimeError( + f'The grpc package installed is at version {GRPC_VERSION},' + + f' but the generated code in kos/common_pb2_grpc.py depends on' + + f' grpcio>={GRPC_GENERATED_VERSION}.' + + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' + + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' + ) diff --git a/kos_core/kos/imu_pb2.py b/kos_core/kos/imu_pb2.py new file mode 100644 index 0000000..792c253 --- /dev/null +++ b/kos_core/kos/imu_pb2.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: kos/imu.proto +# Protobuf Python Version: 5.28.1 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 28, + 1, + '', + 'kos/imu.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 +from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 +from kos import common_pb2 as kos_dot_common__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\rkos/imu.proto\x12\x07kos.imu\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1egoogle/protobuf/duration.proto\x1a#google/longrunning/operations.proto\x1a\x10kos/common.proto\"\xf2\x01\n\x11IMUValuesResponse\x12\x0f\n\x07\x61\x63\x63\x65l_x\x18\x01 \x01(\x01\x12\x0f\n\x07\x61\x63\x63\x65l_y\x18\x02 \x01(\x01\x12\x0f\n\x07\x61\x63\x63\x65l_z\x18\x03 \x01(\x01\x12\x0e\n\x06gyro_x\x18\x04 \x01(\x01\x12\x0e\n\x06gyro_y\x18\x05 \x01(\x01\x12\x0e\n\x06gyro_z\x18\x06 \x01(\x01\x12\x12\n\x05mag_x\x18\x07 \x01(\x01H\x00\x88\x01\x01\x12\x12\n\x05mag_y\x18\x08 \x01(\x01H\x01\x88\x01\x01\x12\x12\n\x05mag_z\x18\t \x01(\x01H\x02\x88\x01\x01\x12 \n\x05\x65rror\x18\n \x01(\x0b\x32\x11.kos.common.ErrorB\x08\n\x06_mag_xB\x08\n\x06_mag_yB\x08\n\x06_mag_z\"8\n\x14\x43\x61librateIMUResponse\x12 \n\x05\x65rror\x18\x01 \x01(\x0b\x32\x11.kos.common.Error\"&\n\x14\x43\x61librateIMUMetadata\x12\x0e\n\x06status\x18\x01 \x01(\t\"\xfd\x01\n\x0eZeroIMURequest\x12+\n\x08\x64uration\x18\x01 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x18\n\x0bmax_retries\x18\x02 \x01(\rH\x00\x88\x01\x01\x12\x1e\n\x11max_angular_error\x18\x03 \x01(\x01H\x01\x88\x01\x01\x12\x19\n\x0cmax_velocity\x18\x04 \x01(\x01H\x02\x88\x01\x01\x12\x1d\n\x10max_acceleration\x18\x05 \x01(\x01H\x03\x88\x01\x01\x42\x0e\n\x0c_max_retriesB\x14\n\x12_max_angular_errorB\x0f\n\r_max_velocityB\x13\n\x11_max_acceleration\"a\n\x13\x45ulerAnglesResponse\x12\x0c\n\x04roll\x18\x01 \x01(\x01\x12\r\n\x05pitch\x18\x02 \x01(\x01\x12\x0b\n\x03yaw\x18\x03 \x01(\x01\x12 \n\x05\x65rror\x18\x04 \x01(\x0b\x32\x11.kos.common.Error\"b\n\x12QuaternionResponse\x12\t\n\x01x\x18\x01 \x01(\x01\x12\t\n\x01y\x18\x02 \x01(\x01\x12\t\n\x01z\x18\x03 \x01(\x01\x12\t\n\x01w\x18\x04 \x01(\x01\x12 \n\x05\x65rror\x18\x05 \x01(\x0b\x32\x11.kos.common.Error2\x87\x03\n\nIMUService\x12?\n\tGetValues\x12\x16.google.protobuf.Empty\x1a\x1a.kos.imu.IMUValuesResponse\x12s\n\tCalibrate\x12\x16.google.protobuf.Empty\x1a\x1d.google.longrunning.Operation\"/\xca\x41,\n\x14\x43\x61librateIMUResponse\x12\x14\x43\x61librateIMUMetadata\x12;\n\x04Zero\x12\x17.kos.imu.ZeroIMURequest\x1a\x1a.kos.common.ActionResponse\x12@\n\x08GetEuler\x12\x16.google.protobuf.Empty\x1a\x1c.kos.imu.EulerAnglesResponse\x12\x44\n\rGetQuaternion\x12\x16.google.protobuf.Empty\x1a\x1b.kos.imu.QuaternionResponseB$\n\x0b\x63om.kos.imuZ\x0bkos/imu;imu\xaa\x02\x07KOS.IMUb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'kos.imu_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\013com.kos.imuZ\013kos/imu;imu\252\002\007KOS.IMU' + _globals['_IMUSERVICE'].methods_by_name['Calibrate']._loaded_options = None + _globals['_IMUSERVICE'].methods_by_name['Calibrate']._serialized_options = b'\312A,\n\024CalibrateIMUResponse\022\024CalibrateIMUMetadata' + _globals['_IMUVALUESRESPONSE']._serialized_start=143 + _globals['_IMUVALUESRESPONSE']._serialized_end=385 + _globals['_CALIBRATEIMURESPONSE']._serialized_start=387 + _globals['_CALIBRATEIMURESPONSE']._serialized_end=443 + _globals['_CALIBRATEIMUMETADATA']._serialized_start=445 + _globals['_CALIBRATEIMUMETADATA']._serialized_end=483 + _globals['_ZEROIMUREQUEST']._serialized_start=486 + _globals['_ZEROIMUREQUEST']._serialized_end=739 + _globals['_EULERANGLESRESPONSE']._serialized_start=741 + _globals['_EULERANGLESRESPONSE']._serialized_end=838 + _globals['_QUATERNIONRESPONSE']._serialized_start=840 + _globals['_QUATERNIONRESPONSE']._serialized_end=938 + _globals['_IMUSERVICE']._serialized_start=941 + _globals['_IMUSERVICE']._serialized_end=1332 +# @@protoc_insertion_point(module_scope) diff --git a/kos_core/kos/imu_pb2_grpc.py b/kos_core/kos/imu_pb2_grpc.py new file mode 100644 index 0000000..167a9c8 --- /dev/null +++ b/kos_core/kos/imu_pb2_grpc.py @@ -0,0 +1,280 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc +import warnings + +from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from kos import common_pb2 as kos_dot_common__pb2 +from kos import imu_pb2 as kos_dot_imu__pb2 + +GRPC_GENERATED_VERSION = '1.68.1' +GRPC_VERSION = grpc.__version__ +_version_not_supported = False + +try: + from grpc._utilities import first_version_is_lower + _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) +except ImportError: + _version_not_supported = True + +if _version_not_supported: + raise RuntimeError( + f'The grpc package installed is at version {GRPC_VERSION},' + + f' but the generated code in kos/imu_pb2_grpc.py depends on' + + f' grpcio>={GRPC_GENERATED_VERSION}.' + + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' + + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' + ) + + +class IMUServiceStub(object): + """The IMUService provides methods to interact with the Inertial Measurement Unit. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.GetValues = channel.unary_unary( + '/kos.imu.IMUService/GetValues', + request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + response_deserializer=kos_dot_imu__pb2.IMUValuesResponse.FromString, + _registered_method=True) + self.Calibrate = channel.unary_unary( + '/kos.imu.IMUService/Calibrate', + request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, + _registered_method=True) + self.Zero = channel.unary_unary( + '/kos.imu.IMUService/Zero', + request_serializer=kos_dot_imu__pb2.ZeroIMURequest.SerializeToString, + response_deserializer=kos_dot_common__pb2.ActionResponse.FromString, + _registered_method=True) + self.GetEuler = channel.unary_unary( + '/kos.imu.IMUService/GetEuler', + request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + response_deserializer=kos_dot_imu__pb2.EulerAnglesResponse.FromString, + _registered_method=True) + self.GetQuaternion = channel.unary_unary( + '/kos.imu.IMUService/GetQuaternion', + request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + response_deserializer=kos_dot_imu__pb2.QuaternionResponse.FromString, + _registered_method=True) + + +class IMUServiceServicer(object): + """The IMUService provides methods to interact with the Inertial Measurement Unit. + """ + + def GetValues(self, request, context): + """Retrieves the latest IMU sensor values. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def Calibrate(self, request, context): + """Calibrates the IMU (long-running operation). + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def Zero(self, request, context): + """Zeros the IMU readings. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetEuler(self, request, context): + """Retrieves Euler angles from the IMU. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetQuaternion(self, request, context): + """Retrieves quaternion from the IMU. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_IMUServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'GetValues': grpc.unary_unary_rpc_method_handler( + servicer.GetValues, + request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + response_serializer=kos_dot_imu__pb2.IMUValuesResponse.SerializeToString, + ), + 'Calibrate': grpc.unary_unary_rpc_method_handler( + servicer.Calibrate, + request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, + ), + 'Zero': grpc.unary_unary_rpc_method_handler( + servicer.Zero, + request_deserializer=kos_dot_imu__pb2.ZeroIMURequest.FromString, + response_serializer=kos_dot_common__pb2.ActionResponse.SerializeToString, + ), + 'GetEuler': grpc.unary_unary_rpc_method_handler( + servicer.GetEuler, + request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + response_serializer=kos_dot_imu__pb2.EulerAnglesResponse.SerializeToString, + ), + 'GetQuaternion': grpc.unary_unary_rpc_method_handler( + servicer.GetQuaternion, + request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + response_serializer=kos_dot_imu__pb2.QuaternionResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'kos.imu.IMUService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + server.add_registered_method_handlers('kos.imu.IMUService', rpc_method_handlers) + + + # This class is part of an EXPERIMENTAL API. +class IMUService(object): + """The IMUService provides methods to interact with the Inertial Measurement Unit. + """ + + @staticmethod + def GetValues(request, + 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, + '/kos.imu.IMUService/GetValues', + google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + kos_dot_imu__pb2.IMUValuesResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def Calibrate(request, + 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, + '/kos.imu.IMUService/Calibrate', + google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + google_dot_longrunning_dot_operations__pb2.Operation.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def Zero(request, + 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, + '/kos.imu.IMUService/Zero', + kos_dot_imu__pb2.ZeroIMURequest.SerializeToString, + kos_dot_common__pb2.ActionResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def GetEuler(request, + 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, + '/kos.imu.IMUService/GetEuler', + google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + kos_dot_imu__pb2.EulerAnglesResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def GetQuaternion(request, + 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, + '/kos.imu.IMUService/GetQuaternion', + google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + kos_dot_imu__pb2.QuaternionResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) diff --git a/kos_core/kos/inference_pb2.py b/kos_core/kos/inference_pb2.py new file mode 100644 index 0000000..f0c5874 --- /dev/null +++ b/kos_core/kos/inference_pb2.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: kos/inference.proto +# Protobuf Python Version: 5.28.1 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 28, + 1, + '', + 'kos/inference.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from kos import common_pb2 as kos_dot_common__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x13kos/inference.proto\x12\rkos.inference\x1a\x1bgoogle/protobuf/empty.proto\x1a\x10kos/common.proto\"#\n\x12UploadModelRequest\x12\r\n\x05model\x18\x01 \x01(\x0c\"J\n\x13UploadModelResponse\x12\x11\n\tmodel_uid\x18\x01 \x01(\t\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.Error\"3\n\x0e\x46orwardRequest\x12\x11\n\tmodel_uid\x18\x01 \x01(\t\x12\x0e\n\x06inputs\x18\x02 \x03(\x02\"D\n\x0f\x46orwardResponse\x12\x0f\n\x07outputs\x18\x01 \x03(\x02\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.Error2\xb2\x01\n\x10InferenceService\x12T\n\x0bUploadModel\x12!.kos.inference.UploadModelRequest\x1a\".kos.inference.UploadModelResponse\x12H\n\x07\x46orward\x12\x1d.kos.inference.ForwardRequest\x1a\x1e.kos.inference.ForwardResponseB<\n\x11\x63om.kos.inferenceZ\x17kos/inference;inference\xaa\x02\rKOS.Inferenceb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'kos.inference_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\021com.kos.inferenceZ\027kos/inference;inference\252\002\rKOS.Inference' + _globals['_UPLOADMODELREQUEST']._serialized_start=85 + _globals['_UPLOADMODELREQUEST']._serialized_end=120 + _globals['_UPLOADMODELRESPONSE']._serialized_start=122 + _globals['_UPLOADMODELRESPONSE']._serialized_end=196 + _globals['_FORWARDREQUEST']._serialized_start=198 + _globals['_FORWARDREQUEST']._serialized_end=249 + _globals['_FORWARDRESPONSE']._serialized_start=251 + _globals['_FORWARDRESPONSE']._serialized_end=319 + _globals['_INFERENCESERVICE']._serialized_start=322 + _globals['_INFERENCESERVICE']._serialized_end=500 +# @@protoc_insertion_point(module_scope) diff --git a/kos_core/kos/inference_pb2_grpc.py b/kos_core/kos/inference_pb2_grpc.py new file mode 100644 index 0000000..7d5140a --- /dev/null +++ b/kos_core/kos/inference_pb2_grpc.py @@ -0,0 +1,145 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc +import warnings + +from kos import inference_pb2 as kos_dot_inference__pb2 + +GRPC_GENERATED_VERSION = '1.68.1' +GRPC_VERSION = grpc.__version__ +_version_not_supported = False + +try: + from grpc._utilities import first_version_is_lower + _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) +except ImportError: + _version_not_supported = True + +if _version_not_supported: + raise RuntimeError( + f'The grpc package installed is at version {GRPC_VERSION},' + + f' but the generated code in kos/inference_pb2_grpc.py depends on' + + f' grpcio>={GRPC_GENERATED_VERSION}.' + + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' + + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' + ) + + +class InferenceServiceStub(object): + """The InferenceService allows uploading models and running inference. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.UploadModel = channel.unary_unary( + '/kos.inference.InferenceService/UploadModel', + request_serializer=kos_dot_inference__pb2.UploadModelRequest.SerializeToString, + response_deserializer=kos_dot_inference__pb2.UploadModelResponse.FromString, + _registered_method=True) + self.Forward = channel.unary_unary( + '/kos.inference.InferenceService/Forward', + request_serializer=kos_dot_inference__pb2.ForwardRequest.SerializeToString, + response_deserializer=kos_dot_inference__pb2.ForwardResponse.FromString, + _registered_method=True) + + +class InferenceServiceServicer(object): + """The InferenceService allows uploading models and running inference. + """ + + def UploadModel(self, request, context): + """Uploads a model to the robot. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def Forward(self, request, context): + """Runs inference using a specified model. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_InferenceServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'UploadModel': grpc.unary_unary_rpc_method_handler( + servicer.UploadModel, + request_deserializer=kos_dot_inference__pb2.UploadModelRequest.FromString, + response_serializer=kos_dot_inference__pb2.UploadModelResponse.SerializeToString, + ), + 'Forward': grpc.unary_unary_rpc_method_handler( + servicer.Forward, + request_deserializer=kos_dot_inference__pb2.ForwardRequest.FromString, + response_serializer=kos_dot_inference__pb2.ForwardResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'kos.inference.InferenceService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + server.add_registered_method_handlers('kos.inference.InferenceService', rpc_method_handlers) + + + # This class is part of an EXPERIMENTAL API. +class InferenceService(object): + """The InferenceService allows uploading models and running inference. + """ + + @staticmethod + def UploadModel(request, + 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, + '/kos.inference.InferenceService/UploadModel', + kos_dot_inference__pb2.UploadModelRequest.SerializeToString, + kos_dot_inference__pb2.UploadModelResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def Forward(request, + 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, + '/kos.inference.InferenceService/Forward', + kos_dot_inference__pb2.ForwardRequest.SerializeToString, + kos_dot_inference__pb2.ForwardResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) diff --git a/kos_core/kos/process_manager_pb2.py b/kos_core/kos/process_manager_pb2.py new file mode 100644 index 0000000..d5aedc0 --- /dev/null +++ b/kos_core/kos/process_manager_pb2.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: kos/process_manager.proto +# Protobuf Python Version: 5.28.1 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 28, + 1, + '', + 'kos/process_manager.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from kos import common_pb2 as kos_dot_common__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x19kos/process_manager.proto\x12\x12kos.processmanager\x1a\x1bgoogle/protobuf/empty.proto\x1a\x10kos/common.proto\"#\n\x11KClipStartRequest\x12\x0e\n\x06\x61\x63tion\x18\x01 \x01(\t\"\\\n\x12KClipStartResponse\x12\x16\n\tclip_uuid\x18\x01 \x01(\tH\x00\x88\x01\x01\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.ErrorB\x0c\n\n_clip_uuid\"[\n\x11KClipStopResponse\x12\x16\n\tclip_uuid\x18\x01 \x01(\tH\x00\x88\x01\x01\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.ErrorB\x0c\n\n_clip_uuid2\xc0\x01\n\x15ProcessManagerService\x12[\n\nStartKClip\x12%.kos.processmanager.KClipStartRequest\x1a&.kos.processmanager.KClipStartResponse\x12J\n\tStopKClip\x12\x16.google.protobuf.Empty\x1a%.kos.processmanager.KClipStopResponseBP\n\x16\x63om.kos.processmanagerZ!kos/processmanager;processmanager\xaa\x02\x12KOS.ProcessManagerb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'kos.process_manager_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\026com.kos.processmanagerZ!kos/processmanager;processmanager\252\002\022KOS.ProcessManager' + _globals['_KCLIPSTARTREQUEST']._serialized_start=96 + _globals['_KCLIPSTARTREQUEST']._serialized_end=131 + _globals['_KCLIPSTARTRESPONSE']._serialized_start=133 + _globals['_KCLIPSTARTRESPONSE']._serialized_end=225 + _globals['_KCLIPSTOPRESPONSE']._serialized_start=227 + _globals['_KCLIPSTOPRESPONSE']._serialized_end=318 + _globals['_PROCESSMANAGERSERVICE']._serialized_start=321 + _globals['_PROCESSMANAGERSERVICE']._serialized_end=513 +# @@protoc_insertion_point(module_scope) diff --git a/kos_core/kos/process_manager_pb2_grpc.py b/kos_core/kos/process_manager_pb2_grpc.py new file mode 100644 index 0000000..5926c80 --- /dev/null +++ b/kos_core/kos/process_manager_pb2_grpc.py @@ -0,0 +1,146 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc +import warnings + +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from kos import process_manager_pb2 as kos_dot_process__manager__pb2 + +GRPC_GENERATED_VERSION = '1.68.1' +GRPC_VERSION = grpc.__version__ +_version_not_supported = False + +try: + from grpc._utilities import first_version_is_lower + _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) +except ImportError: + _version_not_supported = True + +if _version_not_supported: + raise RuntimeError( + f'The grpc package installed is at version {GRPC_VERSION},' + + f' but the generated code in kos/process_manager_pb2_grpc.py depends on' + + f' grpcio>={GRPC_GENERATED_VERSION}.' + + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' + + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' + ) + + +class ProcessManagerServiceStub(object): + """The ProcessManagerService manages processes like video streaming. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.StartKClip = channel.unary_unary( + '/kos.processmanager.ProcessManagerService/StartKClip', + request_serializer=kos_dot_process__manager__pb2.KClipStartRequest.SerializeToString, + response_deserializer=kos_dot_process__manager__pb2.KClipStartResponse.FromString, + _registered_method=True) + self.StopKClip = channel.unary_unary( + '/kos.processmanager.ProcessManagerService/StopKClip', + request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + response_deserializer=kos_dot_process__manager__pb2.KClipStopResponse.FromString, + _registered_method=True) + + +class ProcessManagerServiceServicer(object): + """The ProcessManagerService manages processes like video streaming. + """ + + def StartKClip(self, request, context): + """Starts kclip recording. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def StopKClip(self, request, context): + """Stops kclip recording. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_ProcessManagerServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'StartKClip': grpc.unary_unary_rpc_method_handler( + servicer.StartKClip, + request_deserializer=kos_dot_process__manager__pb2.KClipStartRequest.FromString, + response_serializer=kos_dot_process__manager__pb2.KClipStartResponse.SerializeToString, + ), + 'StopKClip': grpc.unary_unary_rpc_method_handler( + servicer.StopKClip, + request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + response_serializer=kos_dot_process__manager__pb2.KClipStopResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'kos.processmanager.ProcessManagerService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + server.add_registered_method_handlers('kos.processmanager.ProcessManagerService', rpc_method_handlers) + + + # This class is part of an EXPERIMENTAL API. +class ProcessManagerService(object): + """The ProcessManagerService manages processes like video streaming. + """ + + @staticmethod + def StartKClip(request, + 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, + '/kos.processmanager.ProcessManagerService/StartKClip', + kos_dot_process__manager__pb2.KClipStartRequest.SerializeToString, + kos_dot_process__manager__pb2.KClipStartResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def StopKClip(request, + 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, + '/kos.processmanager.ProcessManagerService/StopKClip', + google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + kos_dot_process__manager__pb2.KClipStopResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) diff --git a/kos_core/kos/system_pb2.py b/kos_core/kos/system_pb2.py new file mode 100644 index 0000000..bc1fc47 --- /dev/null +++ b/kos_core/kos/system_pb2.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: kos/system.proto +# Protobuf Python Version: 5.28.1 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 28, + 1, + '', + 'kos/system.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 +from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 +from kos import common_pb2 as kos_dot_common__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10kos/system.proto\x12\nkos.system\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a#google/longrunning/operations.proto\x1a\x10kos/common.proto\"l\n\x16GetIPAddressesResponse\x12\x30\n\ninterfaces\x18\x01 \x03(\x0b\x32\x1c.kos.system.NetworkInterface\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.Error\"6\n\x10NetworkInterface\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0cip_addresses\x18\x02 \x03(\t\";\n\x19SetWiFiCredentialsRequest\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12\x10\n\x08password\x18\x02 \x01(\t\"\x9d\x02\n\x15GetSystemInfoResponse\x12\x16\n\ttotal_ram\x18\x01 \x01(\x04H\x00\x88\x01\x01\x12\x15\n\x08used_ram\x18\x02 \x01(\x04H\x01\x88\x01\x01\x12\x17\n\ntotal_disk\x18\x03 \x01(\x04H\x02\x88\x01\x01\x12\x16\n\tused_disk\x18\x04 \x01(\x04H\x03\x88\x01\x01\x12\x16\n\tcpu_usage\x18\x05 \x01(\x02H\x04\x88\x01\x01\x12\x16\n\tnpu_usage\x18\x06 \x01(\x02H\x05\x88\x01\x01\x12 \n\x05\x65rror\x18\x07 \x01(\x0b\x32\x11.kos.common.ErrorB\x0c\n\n_total_ramB\x0b\n\t_used_ramB\r\n\x0b_total_diskB\x0c\n\n_used_diskB\x0c\n\n_cpu_usageB\x0c\n\n_npu_usage\"x\n\x18GetDiagnosticLogsRequest\x12.\n\nstart_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"K\n\x19GetDiagnosticLogsResponse\x12\x0c\n\x04logs\x18\x01 \x01(\x0c\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.Error\"$\n\x10UploadOTARequest\x12\x10\n\x08ota_file\x18\x01 \x01(\x0c\"5\n\x11UploadOTAResponse\x12 \n\x05\x65rror\x18\x01 \x01(\x0b\x32\x11.kos.common.Error\"#\n\x11UploadOTAMetadata\x12\x0e\n\x06status\x18\x01 \x01(\t2\xd9\x03\n\rSystemService\x12L\n\x0eGetIPAddresses\x12\x16.google.protobuf.Empty\x1a\".kos.system.GetIPAddressesResponse\x12W\n\x12SetWiFiCredentials\x12%.kos.system.SetWiFiCredentialsRequest\x1a\x1a.kos.common.ActionResponse\x12J\n\rGetSystemInfo\x12\x16.google.protobuf.Empty\x1a!.kos.system.GetSystemInfoResponse\x12`\n\x11GetDiagnosticLogs\x12$.kos.system.GetDiagnosticLogsRequest\x1a%.kos.system.GetDiagnosticLogsResponse\x12s\n\tUploadOTA\x12\x1c.kos.system.UploadOTARequest\x1a\x1d.google.longrunning.Operation\")\xca\x41&\n\x11UploadOTAResponse\x12\x11UploadOTAMetadataB0\n\x0e\x63om.kos.systemZ\x11kos/system;system\xaa\x02\nKOS.Systemb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'kos.system_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\016com.kos.systemZ\021kos/system;system\252\002\nKOS.System' + _globals['_SYSTEMSERVICE'].methods_by_name['UploadOTA']._loaded_options = None + _globals['_SYSTEMSERVICE'].methods_by_name['UploadOTA']._serialized_options = b'\312A&\n\021UploadOTAResponse\022\021UploadOTAMetadata' + _globals['_GETIPADDRESSESRESPONSE']._serialized_start=149 + _globals['_GETIPADDRESSESRESPONSE']._serialized_end=257 + _globals['_NETWORKINTERFACE']._serialized_start=259 + _globals['_NETWORKINTERFACE']._serialized_end=313 + _globals['_SETWIFICREDENTIALSREQUEST']._serialized_start=315 + _globals['_SETWIFICREDENTIALSREQUEST']._serialized_end=374 + _globals['_GETSYSTEMINFORESPONSE']._serialized_start=377 + _globals['_GETSYSTEMINFORESPONSE']._serialized_end=662 + _globals['_GETDIAGNOSTICLOGSREQUEST']._serialized_start=664 + _globals['_GETDIAGNOSTICLOGSREQUEST']._serialized_end=784 + _globals['_GETDIAGNOSTICLOGSRESPONSE']._serialized_start=786 + _globals['_GETDIAGNOSTICLOGSRESPONSE']._serialized_end=861 + _globals['_UPLOADOTAREQUEST']._serialized_start=863 + _globals['_UPLOADOTAREQUEST']._serialized_end=899 + _globals['_UPLOADOTARESPONSE']._serialized_start=901 + _globals['_UPLOADOTARESPONSE']._serialized_end=954 + _globals['_UPLOADOTAMETADATA']._serialized_start=956 + _globals['_UPLOADOTAMETADATA']._serialized_end=991 + _globals['_SYSTEMSERVICE']._serialized_start=994 + _globals['_SYSTEMSERVICE']._serialized_end=1467 +# @@protoc_insertion_point(module_scope) diff --git a/kos_core/kos/system_pb2_grpc.py b/kos_core/kos/system_pb2_grpc.py new file mode 100644 index 0000000..c7b8677 --- /dev/null +++ b/kos_core/kos/system_pb2_grpc.py @@ -0,0 +1,280 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc +import warnings + +from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from kos import common_pb2 as kos_dot_common__pb2 +from kos import system_pb2 as kos_dot_system__pb2 + +GRPC_GENERATED_VERSION = '1.68.1' +GRPC_VERSION = grpc.__version__ +_version_not_supported = False + +try: + from grpc._utilities import first_version_is_lower + _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) +except ImportError: + _version_not_supported = True + +if _version_not_supported: + raise RuntimeError( + f'The grpc package installed is at version {GRPC_VERSION},' + + f' but the generated code in kos/system_pb2_grpc.py depends on' + + f' grpcio>={GRPC_GENERATED_VERSION}.' + + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' + + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' + ) + + +class SystemServiceStub(object): + """The SystemService provides methods to interact with system-level functions. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.GetIPAddresses = channel.unary_unary( + '/kos.system.SystemService/GetIPAddresses', + request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + response_deserializer=kos_dot_system__pb2.GetIPAddressesResponse.FromString, + _registered_method=True) + self.SetWiFiCredentials = channel.unary_unary( + '/kos.system.SystemService/SetWiFiCredentials', + request_serializer=kos_dot_system__pb2.SetWiFiCredentialsRequest.SerializeToString, + response_deserializer=kos_dot_common__pb2.ActionResponse.FromString, + _registered_method=True) + self.GetSystemInfo = channel.unary_unary( + '/kos.system.SystemService/GetSystemInfo', + request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + response_deserializer=kos_dot_system__pb2.GetSystemInfoResponse.FromString, + _registered_method=True) + self.GetDiagnosticLogs = channel.unary_unary( + '/kos.system.SystemService/GetDiagnosticLogs', + request_serializer=kos_dot_system__pb2.GetDiagnosticLogsRequest.SerializeToString, + response_deserializer=kos_dot_system__pb2.GetDiagnosticLogsResponse.FromString, + _registered_method=True) + self.UploadOTA = channel.unary_unary( + '/kos.system.SystemService/UploadOTA', + request_serializer=kos_dot_system__pb2.UploadOTARequest.SerializeToString, + response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, + _registered_method=True) + + +class SystemServiceServicer(object): + """The SystemService provides methods to interact with system-level functions. + """ + + def GetIPAddresses(self, request, context): + """Retrieves IP addresses of network interfaces. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def SetWiFiCredentials(self, request, context): + """Sets Wi-Fi credentials. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetSystemInfo(self, request, context): + """Retrieves system information. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetDiagnosticLogs(self, request, context): + """Retrieves diagnostic logs. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def UploadOTA(self, request, context): + """Uploads an OTA update (long-running operation). + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_SystemServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'GetIPAddresses': grpc.unary_unary_rpc_method_handler( + servicer.GetIPAddresses, + request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + response_serializer=kos_dot_system__pb2.GetIPAddressesResponse.SerializeToString, + ), + 'SetWiFiCredentials': grpc.unary_unary_rpc_method_handler( + servicer.SetWiFiCredentials, + request_deserializer=kos_dot_system__pb2.SetWiFiCredentialsRequest.FromString, + response_serializer=kos_dot_common__pb2.ActionResponse.SerializeToString, + ), + 'GetSystemInfo': grpc.unary_unary_rpc_method_handler( + servicer.GetSystemInfo, + request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + response_serializer=kos_dot_system__pb2.GetSystemInfoResponse.SerializeToString, + ), + 'GetDiagnosticLogs': grpc.unary_unary_rpc_method_handler( + servicer.GetDiagnosticLogs, + request_deserializer=kos_dot_system__pb2.GetDiagnosticLogsRequest.FromString, + response_serializer=kos_dot_system__pb2.GetDiagnosticLogsResponse.SerializeToString, + ), + 'UploadOTA': grpc.unary_unary_rpc_method_handler( + servicer.UploadOTA, + request_deserializer=kos_dot_system__pb2.UploadOTARequest.FromString, + response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'kos.system.SystemService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + server.add_registered_method_handlers('kos.system.SystemService', rpc_method_handlers) + + + # This class is part of an EXPERIMENTAL API. +class SystemService(object): + """The SystemService provides methods to interact with system-level functions. + """ + + @staticmethod + def GetIPAddresses(request, + 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, + '/kos.system.SystemService/GetIPAddresses', + google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + kos_dot_system__pb2.GetIPAddressesResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def SetWiFiCredentials(request, + 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, + '/kos.system.SystemService/SetWiFiCredentials', + kos_dot_system__pb2.SetWiFiCredentialsRequest.SerializeToString, + kos_dot_common__pb2.ActionResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def GetSystemInfo(request, + 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, + '/kos.system.SystemService/GetSystemInfo', + google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + kos_dot_system__pb2.GetSystemInfoResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def GetDiagnosticLogs(request, + 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, + '/kos.system.SystemService/GetDiagnosticLogs', + kos_dot_system__pb2.GetDiagnosticLogsRequest.SerializeToString, + kos_dot_system__pb2.GetDiagnosticLogsResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def UploadOTA(request, + 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, + '/kos.system.SystemService/UploadOTA', + kos_dot_system__pb2.UploadOTARequest.SerializeToString, + google_dot_longrunning_dot_operations__pb2.Operation.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) diff --git a/test.py b/test.py new file mode 100644 index 0000000..ade7a80 --- /dev/null +++ b/test.py @@ -0,0 +1,10 @@ +"""Test the speech service """ +from pykos import KOS + +# Connect to KOS running on localhost at port 50051 +client = KOS(ip='localhost', port=50051) + +# Call the synthesize method +response = client.speech.synthesize(text="Hello, world!") + +print(response) From b8eb62565dbeed8570502494b1ac174d9170bd36 Mon Sep 17 00:00:00 2001 From: budzianowski Date: Wed, 22 Jan 2025 22:08:58 -0800 Subject: [PATCH 2/5] stub works, add fmt --- kos-py/pykos/services/speech.py | 16 +- kos-stub/src/speech.rs | 43 ---- kos/src/hal.rs | 12 +- kos/src/lib.rs | 1 - kos/src/services/mod.rs | 2 +- kos/src/services/speech.rs | 13 +- kos_core/kos/actuator_pb2.py | 62 ----- kos_core/kos/actuator_pb2_grpc.py | 235 ------------------- kos_core/kos/common_pb2.py | 43 ---- kos_core/kos/common_pb2_grpc.py | 24 -- kos_core/kos/imu_pb2.py | 55 ----- kos_core/kos/imu_pb2_grpc.py | 280 ----------------------- kos_core/kos/inference_pb2.py | 47 ---- kos_core/kos/inference_pb2_grpc.py | 145 ------------ kos_core/kos/process_manager_pb2.py | 45 ---- kos_core/kos/process_manager_pb2_grpc.py | 146 ------------ kos_core/kos/system_pb2.py | 61 ----- kos_core/kos/system_pb2_grpc.py | 280 ----------------------- test.py | 10 - 19 files changed, 18 insertions(+), 1502 deletions(-) delete mode 100644 kos-stub/src/speech.rs delete mode 100644 kos_core/kos/actuator_pb2.py delete mode 100644 kos_core/kos/actuator_pb2_grpc.py delete mode 100644 kos_core/kos/common_pb2.py delete mode 100644 kos_core/kos/common_pb2_grpc.py delete mode 100644 kos_core/kos/imu_pb2.py delete mode 100644 kos_core/kos/imu_pb2_grpc.py delete mode 100644 kos_core/kos/inference_pb2.py delete mode 100644 kos_core/kos/inference_pb2_grpc.py delete mode 100644 kos_core/kos/process_manager_pb2.py delete mode 100644 kos_core/kos/process_manager_pb2_grpc.py delete mode 100644 kos_core/kos/system_pb2.py delete mode 100644 kos_core/kos/system_pb2_grpc.py delete mode 100644 test.py diff --git a/kos-py/pykos/services/speech.py b/kos-py/pykos/services/speech.py index 4265a0f..531dff2 100644 --- a/kos-py/pykos/services/speech.py +++ b/kos-py/pykos/services/speech.py @@ -16,6 +16,7 @@ class AudioConfig(TypedDict): bit_depth: Bit depth (e.g., 16) channels: Number of channels (1 for mono, 2 for stereo) """ + sample_rate: int bit_depth: int channels: int @@ -35,15 +36,11 @@ def __init__(self, channel: grpc.aio.Channel) -> None: """ self.stub = speech_pb2_grpc.SpeechServiceStub(channel) - async def synthesize(self, text: str, **kwargs: Unpack[AudioConfig]) -> str: + async def synthesize(self, text: str) -> speech_pb2.SynthesizeResponse: """Synthesize speech from text. Args: text: Text to synthesize - **kwargs: Audio configuration parameters - sample_rate: Sample rate in Hz (e.g., 44100) - bit_depth: Bit depth (e.g., 16) - channels: Number of channels (1 for mono, 2 for stereo) Returns: Audio data as a string. @@ -51,15 +48,12 @@ async def synthesize(self, text: str, **kwargs: Unpack[AudioConfig]) -> str: Raises: RuntimeError: If synthesis fails. """ - request = speech_pb2.SynthesizeRequest( - text=text, - config=speech_pb2.AudioConfig(**kwargs) if kwargs else None, - ) + request = speech_pb2.SynthesizeRequest(text=text) response = await self.stub.Synthesize(request) if response.HasField("error"): raise RuntimeError(f"Synthesis error: {response.error}") - return response.audio_data + return response.output_file async def transcribe(self, audio_data: str) -> str: """Transcribe speech to text. @@ -80,4 +74,4 @@ async def transcribe(self, audio_data: str) -> str: response = await self.stub.Transcribe(request) if response.HasField("error"): raise RuntimeError(f"Transcription error: {response.error}") - return response.text \ No newline at end of file + return response.text diff --git a/kos-stub/src/speech.rs b/kos-stub/src/speech.rs deleted file mode 100644 index 54701d1..0000000 --- a/kos-stub/src/speech.rs +++ /dev/null @@ -1,43 +0,0 @@ -use async_trait::async_trait; -use kos::hal::Speech; -use std::process::Command; -use uuid::Uuid; -use kos::kos_proto::speech::SynthesizeResponse; - - -pub struct StubSpeech {} - -impl Default for StubSpeech { - fn default() -> Self { - Self::new() - } -} - -impl StubSpeech { - pub fn new() -> Self { - StubSpeech {} - } -} - -#[async_trait] -impl Speech for StubSpeech { - async fn synthesize(&self, text: String) -> Result { - // Generate a unique filename for the wav output - let output_file = format!("/tmp/speech_{}.wav", Uuid::new_v4()); - - // Create espeak command - Command::new("espeak") - .args([ - "-w", - &output_file, - "-v", - "en", - &text, - ]); - - Ok(SynthesizeResponse { - output_file: output_file, - error: None, - }) - } -} diff --git a/kos/src/hal.rs b/kos/src/hal.rs index acaf4bb..c7b4a32 100644 --- a/kos/src/hal.rs +++ b/kos/src/hal.rs @@ -44,12 +44,6 @@ pub trait IMU: Send + Sync { async fn get_quaternion(&self) -> Result; } -#[async_trait] -pub trait ProcessManager: Send + Sync { - async fn start_kclip(&self, action: String) -> Result; - async fn stop_kclip(&self) -> Result; -} - #[async_trait] pub trait Inference: Send + Sync { async fn upload_model( @@ -107,6 +101,12 @@ pub trait Sound: Send + Sync { async fn stop_recording(&self) -> Result; } +#[async_trait] +pub trait ProcessManager: Send + Sync { + async fn start_kclip(&self, action: String) -> Result; + async fn stop_kclip(&self) -> Result; +} + // TODO action response pfb30 #[async_trait] pub trait Speech: Send + Sync { diff --git a/kos/src/lib.rs b/kos/src/lib.rs index 55ed7d7..8453843 100644 --- a/kos/src/lib.rs +++ b/kos/src/lib.rs @@ -10,7 +10,6 @@ pub mod services; pub mod telemetry; pub mod telemetry_types; - pub use grpc_interface::google as google_proto; pub use grpc_interface::kos as kos_proto; diff --git a/kos/src/services/mod.rs b/kos/src/services/mod.rs index d5af47b..33a81e9 100644 --- a/kos/src/services/mod.rs +++ b/kos/src/services/mod.rs @@ -16,4 +16,4 @@ pub use led_matrix::*; pub use operations::*; pub use process_manager::*; pub use sound::*; -pub use speech::*; \ No newline at end of file +pub use speech::*; diff --git a/kos/src/services/speech.rs b/kos/src/services/speech.rs index 374697a..9efaaf8 100644 --- a/kos/src/services/speech.rs +++ b/kos/src/services/speech.rs @@ -24,20 +24,19 @@ impl SpeechService for SpeechServiceImpl { let req = request.into_inner(); trace!("Synthesizing text: {}", req.text); - - Ok(Response::new( - self + let response = self .speech .synthesize(req.text) .await - .map_err(|e| Status::internal(format!("Failed to synthesize text, {:?}", e)))?, - )) + .map_err(|e| Status::internal(format!("Failed to synthesize text, {:?}", e)))?; + + Ok(Response::new(response)) } - + async fn transcribe( &self, request: Request, ) -> Result, Status> { Err(Status::unimplemented("Transcribe not implemented")) } -} \ No newline at end of file +} diff --git a/kos_core/kos/actuator_pb2.py b/kos_core/kos/actuator_pb2.py deleted file mode 100644 index 82716a0..0000000 --- a/kos_core/kos/actuator_pb2.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# NO CHECKED-IN PROTOBUF GENCODE -# source: kos/actuator.proto -# Protobuf Python Version: 5.28.1 -"""Generated protocol buffer code.""" -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import runtime_version as _runtime_version -from google.protobuf import symbol_database as _symbol_database -from google.protobuf.internal import builder as _builder -_runtime_version.ValidateProtobufRuntimeVersion( - _runtime_version.Domain.PUBLIC, - 5, - 28, - 1, - '', - 'kos/actuator.proto' -) -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 -from kos import common_pb2 as kos_dot_common__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12kos/actuator.proto\x12\x0ckos.actuator\x1a\x1bgoogle/protobuf/empty.proto\x1a#google/longrunning/operations.proto\x1a\x10kos/common.proto\"\x8e\x01\n\x0f\x41\x63tuatorCommand\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12\x15\n\x08position\x18\x02 \x01(\x01H\x00\x88\x01\x01\x12\x15\n\x08velocity\x18\x03 \x01(\x01H\x01\x88\x01\x01\x12\x13\n\x06torque\x18\x04 \x01(\x01H\x02\x88\x01\x01\x42\x0b\n\t_positionB\x0b\n\t_velocityB\t\n\x07_torque\"J\n\x17\x43ommandActuatorsRequest\x12/\n\x08\x63ommands\x18\x01 \x03(\x0b\x32\x1d.kos.actuator.ActuatorCommand\"E\n\x18\x43ommandActuatorsResponse\x12)\n\x07results\x18\x01 \x03(\x0b\x32\x18.kos.common.ActionResult\"\x97\x03\n\x18\x43onfigureActuatorRequest\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12\x0f\n\x02kp\x18\x02 \x01(\x01H\x00\x88\x01\x01\x12\x0f\n\x02kd\x18\x03 \x01(\x01H\x01\x88\x01\x01\x12\x0f\n\x02ki\x18\x04 \x01(\x01H\x02\x88\x01\x01\x12\x17\n\nmax_torque\x18\x05 \x01(\x01H\x03\x88\x01\x01\x12\x1e\n\x11protective_torque\x18\x06 \x01(\x01H\x04\x88\x01\x01\x12\x1c\n\x0fprotection_time\x18\x07 \x01(\x02H\x05\x88\x01\x01\x12\x1b\n\x0etorque_enabled\x18\x08 \x01(\x08H\x06\x88\x01\x01\x12\x1c\n\x0fnew_actuator_id\x18\t \x01(\rH\x07\x88\x01\x01\x12\x1a\n\rzero_position\x18\n \x01(\x08H\x08\x88\x01\x01\x42\x05\n\x03_kpB\x05\n\x03_kdB\x05\n\x03_kiB\r\n\x0b_max_torqueB\x14\n\x12_protective_torqueB\x12\n\x10_protection_timeB\x11\n\x0f_torque_enabledB\x12\n\x10_new_actuator_idB\x10\n\x0e_zero_position\"\x9b\x01\n\x18\x43\x61librateActuatorRequest\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12\x1e\n\x11\x63\x61libration_speed\x18\x02 \x01(\x01H\x00\x88\x01\x01\x12\x1e\n\x11threshold_current\x18\x03 \x01(\x02H\x01\x88\x01\x01\x42\x14\n\x12_calibration_speedB\x14\n\x12_threshold_current\"R\n\x19\x43\x61librateActuatorResponse\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.Error\"@\n\x19\x43\x61librateActuatorMetadata\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12\x0e\n\x06status\x18\x02 \x01(\t\"0\n\x18GetActuatorsStateRequest\x12\x14\n\x0c\x61\x63tuator_ids\x18\x01 \x03(\r\"P\n\x19GetActuatorsStateResponse\x12\x33\n\x06states\x18\x01 \x03(\x0b\x32#.kos.actuator.ActuatorStateResponse\"\x92\x02\n\x15\x41\x63tuatorStateResponse\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12\x0e\n\x06online\x18\x02 \x01(\x08\x12\x15\n\x08position\x18\x03 \x01(\x01H\x00\x88\x01\x01\x12\x15\n\x08velocity\x18\x04 \x01(\x01H\x01\x88\x01\x01\x12\x13\n\x06torque\x18\x05 \x01(\x01H\x02\x88\x01\x01\x12\x18\n\x0btemperature\x18\x06 \x01(\x01H\x03\x88\x01\x01\x12\x14\n\x07voltage\x18\x07 \x01(\x02H\x04\x88\x01\x01\x12\x14\n\x07\x63urrent\x18\x08 \x01(\x02H\x05\x88\x01\x01\x42\x0b\n\t_positionB\x0b\n\t_velocityB\t\n\x07_torqueB\x0e\n\x0c_temperatureB\n\n\x08_voltageB\n\n\x08_current2\xcb\x03\n\x0f\x41\x63tuatorService\x12\x61\n\x10\x43ommandActuators\x12%.kos.actuator.CommandActuatorsRequest\x1a&.kos.actuator.CommandActuatorsResponse\x12W\n\x11\x43onfigureActuator\x12&.kos.actuator.ConfigureActuatorRequest\x1a\x1a.kos.common.ActionResponse\x12\x95\x01\n\x11\x43\x61librateActuator\x12&.kos.actuator.CalibrateActuatorRequest\x1a\x1d.google.longrunning.Operation\"9\xca\x41\x36\n\x19\x43\x61librateActuatorResponse\x12\x19\x43\x61librateActuatorMetadata\x12\x64\n\x11GetActuatorsState\x12&.kos.actuator.GetActuatorsStateRequest\x1a\'.kos.actuator.GetActuatorsStateResponseB8\n\x10\x63om.kos.actuatorZ\x15kos/actuator;actuator\xaa\x02\x0cKOS.Actuatorb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'kos.actuator_pb2', _globals) -if not _descriptor._USE_C_DESCRIPTORS: - _globals['DESCRIPTOR']._loaded_options = None - _globals['DESCRIPTOR']._serialized_options = b'\n\020com.kos.actuatorZ\025kos/actuator;actuator\252\002\014KOS.Actuator' - _globals['_ACTUATORSERVICE'].methods_by_name['CalibrateActuator']._loaded_options = None - _globals['_ACTUATORSERVICE'].methods_by_name['CalibrateActuator']._serialized_options = b'\312A6\n\031CalibrateActuatorResponse\022\031CalibrateActuatorMetadata' - _globals['_ACTUATORCOMMAND']._serialized_start=121 - _globals['_ACTUATORCOMMAND']._serialized_end=263 - _globals['_COMMANDACTUATORSREQUEST']._serialized_start=265 - _globals['_COMMANDACTUATORSREQUEST']._serialized_end=339 - _globals['_COMMANDACTUATORSRESPONSE']._serialized_start=341 - _globals['_COMMANDACTUATORSRESPONSE']._serialized_end=410 - _globals['_CONFIGUREACTUATORREQUEST']._serialized_start=413 - _globals['_CONFIGUREACTUATORREQUEST']._serialized_end=820 - _globals['_CALIBRATEACTUATORREQUEST']._serialized_start=823 - _globals['_CALIBRATEACTUATORREQUEST']._serialized_end=978 - _globals['_CALIBRATEACTUATORRESPONSE']._serialized_start=980 - _globals['_CALIBRATEACTUATORRESPONSE']._serialized_end=1062 - _globals['_CALIBRATEACTUATORMETADATA']._serialized_start=1064 - _globals['_CALIBRATEACTUATORMETADATA']._serialized_end=1128 - _globals['_GETACTUATORSSTATEREQUEST']._serialized_start=1130 - _globals['_GETACTUATORSSTATEREQUEST']._serialized_end=1178 - _globals['_GETACTUATORSSTATERESPONSE']._serialized_start=1180 - _globals['_GETACTUATORSSTATERESPONSE']._serialized_end=1260 - _globals['_ACTUATORSTATERESPONSE']._serialized_start=1263 - _globals['_ACTUATORSTATERESPONSE']._serialized_end=1537 - _globals['_ACTUATORSERVICE']._serialized_start=1540 - _globals['_ACTUATORSERVICE']._serialized_end=1999 -# @@protoc_insertion_point(module_scope) diff --git a/kos_core/kos/actuator_pb2_grpc.py b/kos_core/kos/actuator_pb2_grpc.py deleted file mode 100644 index 5ab751d..0000000 --- a/kos_core/kos/actuator_pb2_grpc.py +++ /dev/null @@ -1,235 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc -import warnings - -from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 -from kos import actuator_pb2 as kos_dot_actuator__pb2 -from kos import common_pb2 as kos_dot_common__pb2 - -GRPC_GENERATED_VERSION = '1.68.1' -GRPC_VERSION = grpc.__version__ -_version_not_supported = False - -try: - from grpc._utilities import first_version_is_lower - _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) -except ImportError: - _version_not_supported = True - -if _version_not_supported: - raise RuntimeError( - f'The grpc package installed is at version {GRPC_VERSION},' - + f' but the generated code in kos/actuator_pb2_grpc.py depends on' - + f' grpcio>={GRPC_GENERATED_VERSION}.' - + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' - + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' - ) - - -class ActuatorServiceStub(object): - """The ActuatorService provides methods to control and monitor actuators. - """ - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.CommandActuators = channel.unary_unary( - '/kos.actuator.ActuatorService/CommandActuators', - request_serializer=kos_dot_actuator__pb2.CommandActuatorsRequest.SerializeToString, - response_deserializer=kos_dot_actuator__pb2.CommandActuatorsResponse.FromString, - _registered_method=True) - self.ConfigureActuator = channel.unary_unary( - '/kos.actuator.ActuatorService/ConfigureActuator', - request_serializer=kos_dot_actuator__pb2.ConfigureActuatorRequest.SerializeToString, - response_deserializer=kos_dot_common__pb2.ActionResponse.FromString, - _registered_method=True) - self.CalibrateActuator = channel.unary_unary( - '/kos.actuator.ActuatorService/CalibrateActuator', - request_serializer=kos_dot_actuator__pb2.CalibrateActuatorRequest.SerializeToString, - response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, - _registered_method=True) - self.GetActuatorsState = channel.unary_unary( - '/kos.actuator.ActuatorService/GetActuatorsState', - request_serializer=kos_dot_actuator__pb2.GetActuatorsStateRequest.SerializeToString, - response_deserializer=kos_dot_actuator__pb2.GetActuatorsStateResponse.FromString, - _registered_method=True) - - -class ActuatorServiceServicer(object): - """The ActuatorService provides methods to control and monitor actuators. - """ - - def CommandActuators(self, request, context): - """Commands multiple actuators at once. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ConfigureActuator(self, request, context): - """Configures an actuator's parameters. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CalibrateActuator(self, request, context): - """Calibrates an actuator (long-running operation). - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetActuatorsState(self, request, context): - """Retrieves the state of multiple actuators. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_ActuatorServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'CommandActuators': grpc.unary_unary_rpc_method_handler( - servicer.CommandActuators, - request_deserializer=kos_dot_actuator__pb2.CommandActuatorsRequest.FromString, - response_serializer=kos_dot_actuator__pb2.CommandActuatorsResponse.SerializeToString, - ), - 'ConfigureActuator': grpc.unary_unary_rpc_method_handler( - servicer.ConfigureActuator, - request_deserializer=kos_dot_actuator__pb2.ConfigureActuatorRequest.FromString, - response_serializer=kos_dot_common__pb2.ActionResponse.SerializeToString, - ), - 'CalibrateActuator': grpc.unary_unary_rpc_method_handler( - servicer.CalibrateActuator, - request_deserializer=kos_dot_actuator__pb2.CalibrateActuatorRequest.FromString, - response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, - ), - 'GetActuatorsState': grpc.unary_unary_rpc_method_handler( - servicer.GetActuatorsState, - request_deserializer=kos_dot_actuator__pb2.GetActuatorsStateRequest.FromString, - response_serializer=kos_dot_actuator__pb2.GetActuatorsStateResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'kos.actuator.ActuatorService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - server.add_registered_method_handlers('kos.actuator.ActuatorService', rpc_method_handlers) - - - # This class is part of an EXPERIMENTAL API. -class ActuatorService(object): - """The ActuatorService provides methods to control and monitor actuators. - """ - - @staticmethod - def CommandActuators(request, - 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, - '/kos.actuator.ActuatorService/CommandActuators', - kos_dot_actuator__pb2.CommandActuatorsRequest.SerializeToString, - kos_dot_actuator__pb2.CommandActuatorsResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def ConfigureActuator(request, - 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, - '/kos.actuator.ActuatorService/ConfigureActuator', - kos_dot_actuator__pb2.ConfigureActuatorRequest.SerializeToString, - kos_dot_common__pb2.ActionResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def CalibrateActuator(request, - 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, - '/kos.actuator.ActuatorService/CalibrateActuator', - kos_dot_actuator__pb2.CalibrateActuatorRequest.SerializeToString, - google_dot_longrunning_dot_operations__pb2.Operation.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def GetActuatorsState(request, - 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, - '/kos.actuator.ActuatorService/GetActuatorsState', - kos_dot_actuator__pb2.GetActuatorsStateRequest.SerializeToString, - kos_dot_actuator__pb2.GetActuatorsStateResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) diff --git a/kos_core/kos/common_pb2.py b/kos_core/kos/common_pb2.py deleted file mode 100644 index c0050cb..0000000 --- a/kos_core/kos/common_pb2.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# NO CHECKED-IN PROTOBUF GENCODE -# source: kos/common.proto -# Protobuf Python Version: 5.28.1 -"""Generated protocol buffer code.""" -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import runtime_version as _runtime_version -from google.protobuf import symbol_database as _symbol_database -from google.protobuf.internal import builder as _builder -_runtime_version.ValidateProtobufRuntimeVersion( - _runtime_version.Domain.PUBLIC, - 5, - 28, - 1, - '', - 'kos/common.proto' -) -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10kos/common.proto\x12\nkos.common\"=\n\x05\x45rror\x12#\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x15.kos.common.ErrorCode\x12\x0f\n\x07message\x18\x02 \x01(\t\"C\n\x0e\x41\x63tionResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.Error\"V\n\x0c\x41\x63tionResult\x12\x13\n\x0b\x61\x63tuator_id\x18\x01 \x01(\r\x12\x0f\n\x07success\x18\x02 \x01(\x08\x12 \n\x05\x65rror\x18\x03 \x01(\x0b\x32\x11.kos.common.Error*x\n\tErrorCode\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x13\n\x0fNOT_IMPLEMENTED\x10\x01\x12\x14\n\x10INVALID_ARGUMENT\x10\x02\x12\x14\n\x10HARDWARE_FAILURE\x10\x03\x12\x0b\n\x07TIMEOUT\x10\x04\x12\x10\n\x0cUNAUTHORIZED\x10\x05\x42\x30\n\x0e\x63om.kos.commonZ\x11kos/common;common\xaa\x02\nKOS.Commonb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'kos.common_pb2', _globals) -if not _descriptor._USE_C_DESCRIPTORS: - _globals['DESCRIPTOR']._loaded_options = None - _globals['DESCRIPTOR']._serialized_options = b'\n\016com.kos.commonZ\021kos/common;common\252\002\nKOS.Common' - _globals['_ERRORCODE']._serialized_start=252 - _globals['_ERRORCODE']._serialized_end=372 - _globals['_ERROR']._serialized_start=32 - _globals['_ERROR']._serialized_end=93 - _globals['_ACTIONRESPONSE']._serialized_start=95 - _globals['_ACTIONRESPONSE']._serialized_end=162 - _globals['_ACTIONRESULT']._serialized_start=164 - _globals['_ACTIONRESULT']._serialized_end=250 -# @@protoc_insertion_point(module_scope) diff --git a/kos_core/kos/common_pb2_grpc.py b/kos_core/kos/common_pb2_grpc.py deleted file mode 100644 index 1d0f29e..0000000 --- a/kos_core/kos/common_pb2_grpc.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc -import warnings - - -GRPC_GENERATED_VERSION = '1.68.1' -GRPC_VERSION = grpc.__version__ -_version_not_supported = False - -try: - from grpc._utilities import first_version_is_lower - _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) -except ImportError: - _version_not_supported = True - -if _version_not_supported: - raise RuntimeError( - f'The grpc package installed is at version {GRPC_VERSION},' - + f' but the generated code in kos/common_pb2_grpc.py depends on' - + f' grpcio>={GRPC_GENERATED_VERSION}.' - + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' - + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' - ) diff --git a/kos_core/kos/imu_pb2.py b/kos_core/kos/imu_pb2.py deleted file mode 100644 index 792c253..0000000 --- a/kos_core/kos/imu_pb2.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# NO CHECKED-IN PROTOBUF GENCODE -# source: kos/imu.proto -# Protobuf Python Version: 5.28.1 -"""Generated protocol buffer code.""" -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import runtime_version as _runtime_version -from google.protobuf import symbol_database as _symbol_database -from google.protobuf.internal import builder as _builder -_runtime_version.ValidateProtobufRuntimeVersion( - _runtime_version.Domain.PUBLIC, - 5, - 28, - 1, - '', - 'kos/imu.proto' -) -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 -from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 -from kos import common_pb2 as kos_dot_common__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\rkos/imu.proto\x12\x07kos.imu\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1egoogle/protobuf/duration.proto\x1a#google/longrunning/operations.proto\x1a\x10kos/common.proto\"\xf2\x01\n\x11IMUValuesResponse\x12\x0f\n\x07\x61\x63\x63\x65l_x\x18\x01 \x01(\x01\x12\x0f\n\x07\x61\x63\x63\x65l_y\x18\x02 \x01(\x01\x12\x0f\n\x07\x61\x63\x63\x65l_z\x18\x03 \x01(\x01\x12\x0e\n\x06gyro_x\x18\x04 \x01(\x01\x12\x0e\n\x06gyro_y\x18\x05 \x01(\x01\x12\x0e\n\x06gyro_z\x18\x06 \x01(\x01\x12\x12\n\x05mag_x\x18\x07 \x01(\x01H\x00\x88\x01\x01\x12\x12\n\x05mag_y\x18\x08 \x01(\x01H\x01\x88\x01\x01\x12\x12\n\x05mag_z\x18\t \x01(\x01H\x02\x88\x01\x01\x12 \n\x05\x65rror\x18\n \x01(\x0b\x32\x11.kos.common.ErrorB\x08\n\x06_mag_xB\x08\n\x06_mag_yB\x08\n\x06_mag_z\"8\n\x14\x43\x61librateIMUResponse\x12 \n\x05\x65rror\x18\x01 \x01(\x0b\x32\x11.kos.common.Error\"&\n\x14\x43\x61librateIMUMetadata\x12\x0e\n\x06status\x18\x01 \x01(\t\"\xfd\x01\n\x0eZeroIMURequest\x12+\n\x08\x64uration\x18\x01 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x18\n\x0bmax_retries\x18\x02 \x01(\rH\x00\x88\x01\x01\x12\x1e\n\x11max_angular_error\x18\x03 \x01(\x01H\x01\x88\x01\x01\x12\x19\n\x0cmax_velocity\x18\x04 \x01(\x01H\x02\x88\x01\x01\x12\x1d\n\x10max_acceleration\x18\x05 \x01(\x01H\x03\x88\x01\x01\x42\x0e\n\x0c_max_retriesB\x14\n\x12_max_angular_errorB\x0f\n\r_max_velocityB\x13\n\x11_max_acceleration\"a\n\x13\x45ulerAnglesResponse\x12\x0c\n\x04roll\x18\x01 \x01(\x01\x12\r\n\x05pitch\x18\x02 \x01(\x01\x12\x0b\n\x03yaw\x18\x03 \x01(\x01\x12 \n\x05\x65rror\x18\x04 \x01(\x0b\x32\x11.kos.common.Error\"b\n\x12QuaternionResponse\x12\t\n\x01x\x18\x01 \x01(\x01\x12\t\n\x01y\x18\x02 \x01(\x01\x12\t\n\x01z\x18\x03 \x01(\x01\x12\t\n\x01w\x18\x04 \x01(\x01\x12 \n\x05\x65rror\x18\x05 \x01(\x0b\x32\x11.kos.common.Error2\x87\x03\n\nIMUService\x12?\n\tGetValues\x12\x16.google.protobuf.Empty\x1a\x1a.kos.imu.IMUValuesResponse\x12s\n\tCalibrate\x12\x16.google.protobuf.Empty\x1a\x1d.google.longrunning.Operation\"/\xca\x41,\n\x14\x43\x61librateIMUResponse\x12\x14\x43\x61librateIMUMetadata\x12;\n\x04Zero\x12\x17.kos.imu.ZeroIMURequest\x1a\x1a.kos.common.ActionResponse\x12@\n\x08GetEuler\x12\x16.google.protobuf.Empty\x1a\x1c.kos.imu.EulerAnglesResponse\x12\x44\n\rGetQuaternion\x12\x16.google.protobuf.Empty\x1a\x1b.kos.imu.QuaternionResponseB$\n\x0b\x63om.kos.imuZ\x0bkos/imu;imu\xaa\x02\x07KOS.IMUb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'kos.imu_pb2', _globals) -if not _descriptor._USE_C_DESCRIPTORS: - _globals['DESCRIPTOR']._loaded_options = None - _globals['DESCRIPTOR']._serialized_options = b'\n\013com.kos.imuZ\013kos/imu;imu\252\002\007KOS.IMU' - _globals['_IMUSERVICE'].methods_by_name['Calibrate']._loaded_options = None - _globals['_IMUSERVICE'].methods_by_name['Calibrate']._serialized_options = b'\312A,\n\024CalibrateIMUResponse\022\024CalibrateIMUMetadata' - _globals['_IMUVALUESRESPONSE']._serialized_start=143 - _globals['_IMUVALUESRESPONSE']._serialized_end=385 - _globals['_CALIBRATEIMURESPONSE']._serialized_start=387 - _globals['_CALIBRATEIMURESPONSE']._serialized_end=443 - _globals['_CALIBRATEIMUMETADATA']._serialized_start=445 - _globals['_CALIBRATEIMUMETADATA']._serialized_end=483 - _globals['_ZEROIMUREQUEST']._serialized_start=486 - _globals['_ZEROIMUREQUEST']._serialized_end=739 - _globals['_EULERANGLESRESPONSE']._serialized_start=741 - _globals['_EULERANGLESRESPONSE']._serialized_end=838 - _globals['_QUATERNIONRESPONSE']._serialized_start=840 - _globals['_QUATERNIONRESPONSE']._serialized_end=938 - _globals['_IMUSERVICE']._serialized_start=941 - _globals['_IMUSERVICE']._serialized_end=1332 -# @@protoc_insertion_point(module_scope) diff --git a/kos_core/kos/imu_pb2_grpc.py b/kos_core/kos/imu_pb2_grpc.py deleted file mode 100644 index 167a9c8..0000000 --- a/kos_core/kos/imu_pb2_grpc.py +++ /dev/null @@ -1,280 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc -import warnings - -from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from kos import common_pb2 as kos_dot_common__pb2 -from kos import imu_pb2 as kos_dot_imu__pb2 - -GRPC_GENERATED_VERSION = '1.68.1' -GRPC_VERSION = grpc.__version__ -_version_not_supported = False - -try: - from grpc._utilities import first_version_is_lower - _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) -except ImportError: - _version_not_supported = True - -if _version_not_supported: - raise RuntimeError( - f'The grpc package installed is at version {GRPC_VERSION},' - + f' but the generated code in kos/imu_pb2_grpc.py depends on' - + f' grpcio>={GRPC_GENERATED_VERSION}.' - + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' - + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' - ) - - -class IMUServiceStub(object): - """The IMUService provides methods to interact with the Inertial Measurement Unit. - """ - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.GetValues = channel.unary_unary( - '/kos.imu.IMUService/GetValues', - request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - response_deserializer=kos_dot_imu__pb2.IMUValuesResponse.FromString, - _registered_method=True) - self.Calibrate = channel.unary_unary( - '/kos.imu.IMUService/Calibrate', - request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, - _registered_method=True) - self.Zero = channel.unary_unary( - '/kos.imu.IMUService/Zero', - request_serializer=kos_dot_imu__pb2.ZeroIMURequest.SerializeToString, - response_deserializer=kos_dot_common__pb2.ActionResponse.FromString, - _registered_method=True) - self.GetEuler = channel.unary_unary( - '/kos.imu.IMUService/GetEuler', - request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - response_deserializer=kos_dot_imu__pb2.EulerAnglesResponse.FromString, - _registered_method=True) - self.GetQuaternion = channel.unary_unary( - '/kos.imu.IMUService/GetQuaternion', - request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - response_deserializer=kos_dot_imu__pb2.QuaternionResponse.FromString, - _registered_method=True) - - -class IMUServiceServicer(object): - """The IMUService provides methods to interact with the Inertial Measurement Unit. - """ - - def GetValues(self, request, context): - """Retrieves the latest IMU sensor values. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Calibrate(self, request, context): - """Calibrates the IMU (long-running operation). - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Zero(self, request, context): - """Zeros the IMU readings. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetEuler(self, request, context): - """Retrieves Euler angles from the IMU. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetQuaternion(self, request, context): - """Retrieves quaternion from the IMU. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_IMUServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'GetValues': grpc.unary_unary_rpc_method_handler( - servicer.GetValues, - request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - response_serializer=kos_dot_imu__pb2.IMUValuesResponse.SerializeToString, - ), - 'Calibrate': grpc.unary_unary_rpc_method_handler( - servicer.Calibrate, - request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, - ), - 'Zero': grpc.unary_unary_rpc_method_handler( - servicer.Zero, - request_deserializer=kos_dot_imu__pb2.ZeroIMURequest.FromString, - response_serializer=kos_dot_common__pb2.ActionResponse.SerializeToString, - ), - 'GetEuler': grpc.unary_unary_rpc_method_handler( - servicer.GetEuler, - request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - response_serializer=kos_dot_imu__pb2.EulerAnglesResponse.SerializeToString, - ), - 'GetQuaternion': grpc.unary_unary_rpc_method_handler( - servicer.GetQuaternion, - request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - response_serializer=kos_dot_imu__pb2.QuaternionResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'kos.imu.IMUService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - server.add_registered_method_handlers('kos.imu.IMUService', rpc_method_handlers) - - - # This class is part of an EXPERIMENTAL API. -class IMUService(object): - """The IMUService provides methods to interact with the Inertial Measurement Unit. - """ - - @staticmethod - def GetValues(request, - 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, - '/kos.imu.IMUService/GetValues', - google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - kos_dot_imu__pb2.IMUValuesResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def Calibrate(request, - 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, - '/kos.imu.IMUService/Calibrate', - google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - google_dot_longrunning_dot_operations__pb2.Operation.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def Zero(request, - 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, - '/kos.imu.IMUService/Zero', - kos_dot_imu__pb2.ZeroIMURequest.SerializeToString, - kos_dot_common__pb2.ActionResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def GetEuler(request, - 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, - '/kos.imu.IMUService/GetEuler', - google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - kos_dot_imu__pb2.EulerAnglesResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def GetQuaternion(request, - 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, - '/kos.imu.IMUService/GetQuaternion', - google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - kos_dot_imu__pb2.QuaternionResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) diff --git a/kos_core/kos/inference_pb2.py b/kos_core/kos/inference_pb2.py deleted file mode 100644 index f0c5874..0000000 --- a/kos_core/kos/inference_pb2.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# NO CHECKED-IN PROTOBUF GENCODE -# source: kos/inference.proto -# Protobuf Python Version: 5.28.1 -"""Generated protocol buffer code.""" -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import runtime_version as _runtime_version -from google.protobuf import symbol_database as _symbol_database -from google.protobuf.internal import builder as _builder -_runtime_version.ValidateProtobufRuntimeVersion( - _runtime_version.Domain.PUBLIC, - 5, - 28, - 1, - '', - 'kos/inference.proto' -) -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from kos import common_pb2 as kos_dot_common__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x13kos/inference.proto\x12\rkos.inference\x1a\x1bgoogle/protobuf/empty.proto\x1a\x10kos/common.proto\"#\n\x12UploadModelRequest\x12\r\n\x05model\x18\x01 \x01(\x0c\"J\n\x13UploadModelResponse\x12\x11\n\tmodel_uid\x18\x01 \x01(\t\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.Error\"3\n\x0e\x46orwardRequest\x12\x11\n\tmodel_uid\x18\x01 \x01(\t\x12\x0e\n\x06inputs\x18\x02 \x03(\x02\"D\n\x0f\x46orwardResponse\x12\x0f\n\x07outputs\x18\x01 \x03(\x02\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.Error2\xb2\x01\n\x10InferenceService\x12T\n\x0bUploadModel\x12!.kos.inference.UploadModelRequest\x1a\".kos.inference.UploadModelResponse\x12H\n\x07\x46orward\x12\x1d.kos.inference.ForwardRequest\x1a\x1e.kos.inference.ForwardResponseB<\n\x11\x63om.kos.inferenceZ\x17kos/inference;inference\xaa\x02\rKOS.Inferenceb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'kos.inference_pb2', _globals) -if not _descriptor._USE_C_DESCRIPTORS: - _globals['DESCRIPTOR']._loaded_options = None - _globals['DESCRIPTOR']._serialized_options = b'\n\021com.kos.inferenceZ\027kos/inference;inference\252\002\rKOS.Inference' - _globals['_UPLOADMODELREQUEST']._serialized_start=85 - _globals['_UPLOADMODELREQUEST']._serialized_end=120 - _globals['_UPLOADMODELRESPONSE']._serialized_start=122 - _globals['_UPLOADMODELRESPONSE']._serialized_end=196 - _globals['_FORWARDREQUEST']._serialized_start=198 - _globals['_FORWARDREQUEST']._serialized_end=249 - _globals['_FORWARDRESPONSE']._serialized_start=251 - _globals['_FORWARDRESPONSE']._serialized_end=319 - _globals['_INFERENCESERVICE']._serialized_start=322 - _globals['_INFERENCESERVICE']._serialized_end=500 -# @@protoc_insertion_point(module_scope) diff --git a/kos_core/kos/inference_pb2_grpc.py b/kos_core/kos/inference_pb2_grpc.py deleted file mode 100644 index 7d5140a..0000000 --- a/kos_core/kos/inference_pb2_grpc.py +++ /dev/null @@ -1,145 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc -import warnings - -from kos import inference_pb2 as kos_dot_inference__pb2 - -GRPC_GENERATED_VERSION = '1.68.1' -GRPC_VERSION = grpc.__version__ -_version_not_supported = False - -try: - from grpc._utilities import first_version_is_lower - _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) -except ImportError: - _version_not_supported = True - -if _version_not_supported: - raise RuntimeError( - f'The grpc package installed is at version {GRPC_VERSION},' - + f' but the generated code in kos/inference_pb2_grpc.py depends on' - + f' grpcio>={GRPC_GENERATED_VERSION}.' - + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' - + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' - ) - - -class InferenceServiceStub(object): - """The InferenceService allows uploading models and running inference. - """ - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.UploadModel = channel.unary_unary( - '/kos.inference.InferenceService/UploadModel', - request_serializer=kos_dot_inference__pb2.UploadModelRequest.SerializeToString, - response_deserializer=kos_dot_inference__pb2.UploadModelResponse.FromString, - _registered_method=True) - self.Forward = channel.unary_unary( - '/kos.inference.InferenceService/Forward', - request_serializer=kos_dot_inference__pb2.ForwardRequest.SerializeToString, - response_deserializer=kos_dot_inference__pb2.ForwardResponse.FromString, - _registered_method=True) - - -class InferenceServiceServicer(object): - """The InferenceService allows uploading models and running inference. - """ - - def UploadModel(self, request, context): - """Uploads a model to the robot. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Forward(self, request, context): - """Runs inference using a specified model. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_InferenceServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'UploadModel': grpc.unary_unary_rpc_method_handler( - servicer.UploadModel, - request_deserializer=kos_dot_inference__pb2.UploadModelRequest.FromString, - response_serializer=kos_dot_inference__pb2.UploadModelResponse.SerializeToString, - ), - 'Forward': grpc.unary_unary_rpc_method_handler( - servicer.Forward, - request_deserializer=kos_dot_inference__pb2.ForwardRequest.FromString, - response_serializer=kos_dot_inference__pb2.ForwardResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'kos.inference.InferenceService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - server.add_registered_method_handlers('kos.inference.InferenceService', rpc_method_handlers) - - - # This class is part of an EXPERIMENTAL API. -class InferenceService(object): - """The InferenceService allows uploading models and running inference. - """ - - @staticmethod - def UploadModel(request, - 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, - '/kos.inference.InferenceService/UploadModel', - kos_dot_inference__pb2.UploadModelRequest.SerializeToString, - kos_dot_inference__pb2.UploadModelResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def Forward(request, - 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, - '/kos.inference.InferenceService/Forward', - kos_dot_inference__pb2.ForwardRequest.SerializeToString, - kos_dot_inference__pb2.ForwardResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) diff --git a/kos_core/kos/process_manager_pb2.py b/kos_core/kos/process_manager_pb2.py deleted file mode 100644 index d5aedc0..0000000 --- a/kos_core/kos/process_manager_pb2.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# NO CHECKED-IN PROTOBUF GENCODE -# source: kos/process_manager.proto -# Protobuf Python Version: 5.28.1 -"""Generated protocol buffer code.""" -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import runtime_version as _runtime_version -from google.protobuf import symbol_database as _symbol_database -from google.protobuf.internal import builder as _builder -_runtime_version.ValidateProtobufRuntimeVersion( - _runtime_version.Domain.PUBLIC, - 5, - 28, - 1, - '', - 'kos/process_manager.proto' -) -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from kos import common_pb2 as kos_dot_common__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x19kos/process_manager.proto\x12\x12kos.processmanager\x1a\x1bgoogle/protobuf/empty.proto\x1a\x10kos/common.proto\"#\n\x11KClipStartRequest\x12\x0e\n\x06\x61\x63tion\x18\x01 \x01(\t\"\\\n\x12KClipStartResponse\x12\x16\n\tclip_uuid\x18\x01 \x01(\tH\x00\x88\x01\x01\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.ErrorB\x0c\n\n_clip_uuid\"[\n\x11KClipStopResponse\x12\x16\n\tclip_uuid\x18\x01 \x01(\tH\x00\x88\x01\x01\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.ErrorB\x0c\n\n_clip_uuid2\xc0\x01\n\x15ProcessManagerService\x12[\n\nStartKClip\x12%.kos.processmanager.KClipStartRequest\x1a&.kos.processmanager.KClipStartResponse\x12J\n\tStopKClip\x12\x16.google.protobuf.Empty\x1a%.kos.processmanager.KClipStopResponseBP\n\x16\x63om.kos.processmanagerZ!kos/processmanager;processmanager\xaa\x02\x12KOS.ProcessManagerb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'kos.process_manager_pb2', _globals) -if not _descriptor._USE_C_DESCRIPTORS: - _globals['DESCRIPTOR']._loaded_options = None - _globals['DESCRIPTOR']._serialized_options = b'\n\026com.kos.processmanagerZ!kos/processmanager;processmanager\252\002\022KOS.ProcessManager' - _globals['_KCLIPSTARTREQUEST']._serialized_start=96 - _globals['_KCLIPSTARTREQUEST']._serialized_end=131 - _globals['_KCLIPSTARTRESPONSE']._serialized_start=133 - _globals['_KCLIPSTARTRESPONSE']._serialized_end=225 - _globals['_KCLIPSTOPRESPONSE']._serialized_start=227 - _globals['_KCLIPSTOPRESPONSE']._serialized_end=318 - _globals['_PROCESSMANAGERSERVICE']._serialized_start=321 - _globals['_PROCESSMANAGERSERVICE']._serialized_end=513 -# @@protoc_insertion_point(module_scope) diff --git a/kos_core/kos/process_manager_pb2_grpc.py b/kos_core/kos/process_manager_pb2_grpc.py deleted file mode 100644 index 5926c80..0000000 --- a/kos_core/kos/process_manager_pb2_grpc.py +++ /dev/null @@ -1,146 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc -import warnings - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from kos import process_manager_pb2 as kos_dot_process__manager__pb2 - -GRPC_GENERATED_VERSION = '1.68.1' -GRPC_VERSION = grpc.__version__ -_version_not_supported = False - -try: - from grpc._utilities import first_version_is_lower - _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) -except ImportError: - _version_not_supported = True - -if _version_not_supported: - raise RuntimeError( - f'The grpc package installed is at version {GRPC_VERSION},' - + f' but the generated code in kos/process_manager_pb2_grpc.py depends on' - + f' grpcio>={GRPC_GENERATED_VERSION}.' - + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' - + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' - ) - - -class ProcessManagerServiceStub(object): - """The ProcessManagerService manages processes like video streaming. - """ - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.StartKClip = channel.unary_unary( - '/kos.processmanager.ProcessManagerService/StartKClip', - request_serializer=kos_dot_process__manager__pb2.KClipStartRequest.SerializeToString, - response_deserializer=kos_dot_process__manager__pb2.KClipStartResponse.FromString, - _registered_method=True) - self.StopKClip = channel.unary_unary( - '/kos.processmanager.ProcessManagerService/StopKClip', - request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - response_deserializer=kos_dot_process__manager__pb2.KClipStopResponse.FromString, - _registered_method=True) - - -class ProcessManagerServiceServicer(object): - """The ProcessManagerService manages processes like video streaming. - """ - - def StartKClip(self, request, context): - """Starts kclip recording. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def StopKClip(self, request, context): - """Stops kclip recording. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_ProcessManagerServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'StartKClip': grpc.unary_unary_rpc_method_handler( - servicer.StartKClip, - request_deserializer=kos_dot_process__manager__pb2.KClipStartRequest.FromString, - response_serializer=kos_dot_process__manager__pb2.KClipStartResponse.SerializeToString, - ), - 'StopKClip': grpc.unary_unary_rpc_method_handler( - servicer.StopKClip, - request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - response_serializer=kos_dot_process__manager__pb2.KClipStopResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'kos.processmanager.ProcessManagerService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - server.add_registered_method_handlers('kos.processmanager.ProcessManagerService', rpc_method_handlers) - - - # This class is part of an EXPERIMENTAL API. -class ProcessManagerService(object): - """The ProcessManagerService manages processes like video streaming. - """ - - @staticmethod - def StartKClip(request, - 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, - '/kos.processmanager.ProcessManagerService/StartKClip', - kos_dot_process__manager__pb2.KClipStartRequest.SerializeToString, - kos_dot_process__manager__pb2.KClipStartResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def StopKClip(request, - 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, - '/kos.processmanager.ProcessManagerService/StopKClip', - google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - kos_dot_process__manager__pb2.KClipStopResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) diff --git a/kos_core/kos/system_pb2.py b/kos_core/kos/system_pb2.py deleted file mode 100644 index bc1fc47..0000000 --- a/kos_core/kos/system_pb2.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# NO CHECKED-IN PROTOBUF GENCODE -# source: kos/system.proto -# Protobuf Python Version: 5.28.1 -"""Generated protocol buffer code.""" -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import runtime_version as _runtime_version -from google.protobuf import symbol_database as _symbol_database -from google.protobuf.internal import builder as _builder -_runtime_version.ValidateProtobufRuntimeVersion( - _runtime_version.Domain.PUBLIC, - 5, - 28, - 1, - '', - 'kos/system.proto' -) -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 -from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 -from kos import common_pb2 as kos_dot_common__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10kos/system.proto\x12\nkos.system\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a#google/longrunning/operations.proto\x1a\x10kos/common.proto\"l\n\x16GetIPAddressesResponse\x12\x30\n\ninterfaces\x18\x01 \x03(\x0b\x32\x1c.kos.system.NetworkInterface\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.Error\"6\n\x10NetworkInterface\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0cip_addresses\x18\x02 \x03(\t\";\n\x19SetWiFiCredentialsRequest\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12\x10\n\x08password\x18\x02 \x01(\t\"\x9d\x02\n\x15GetSystemInfoResponse\x12\x16\n\ttotal_ram\x18\x01 \x01(\x04H\x00\x88\x01\x01\x12\x15\n\x08used_ram\x18\x02 \x01(\x04H\x01\x88\x01\x01\x12\x17\n\ntotal_disk\x18\x03 \x01(\x04H\x02\x88\x01\x01\x12\x16\n\tused_disk\x18\x04 \x01(\x04H\x03\x88\x01\x01\x12\x16\n\tcpu_usage\x18\x05 \x01(\x02H\x04\x88\x01\x01\x12\x16\n\tnpu_usage\x18\x06 \x01(\x02H\x05\x88\x01\x01\x12 \n\x05\x65rror\x18\x07 \x01(\x0b\x32\x11.kos.common.ErrorB\x0c\n\n_total_ramB\x0b\n\t_used_ramB\r\n\x0b_total_diskB\x0c\n\n_used_diskB\x0c\n\n_cpu_usageB\x0c\n\n_npu_usage\"x\n\x18GetDiagnosticLogsRequest\x12.\n\nstart_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"K\n\x19GetDiagnosticLogsResponse\x12\x0c\n\x04logs\x18\x01 \x01(\x0c\x12 \n\x05\x65rror\x18\x02 \x01(\x0b\x32\x11.kos.common.Error\"$\n\x10UploadOTARequest\x12\x10\n\x08ota_file\x18\x01 \x01(\x0c\"5\n\x11UploadOTAResponse\x12 \n\x05\x65rror\x18\x01 \x01(\x0b\x32\x11.kos.common.Error\"#\n\x11UploadOTAMetadata\x12\x0e\n\x06status\x18\x01 \x01(\t2\xd9\x03\n\rSystemService\x12L\n\x0eGetIPAddresses\x12\x16.google.protobuf.Empty\x1a\".kos.system.GetIPAddressesResponse\x12W\n\x12SetWiFiCredentials\x12%.kos.system.SetWiFiCredentialsRequest\x1a\x1a.kos.common.ActionResponse\x12J\n\rGetSystemInfo\x12\x16.google.protobuf.Empty\x1a!.kos.system.GetSystemInfoResponse\x12`\n\x11GetDiagnosticLogs\x12$.kos.system.GetDiagnosticLogsRequest\x1a%.kos.system.GetDiagnosticLogsResponse\x12s\n\tUploadOTA\x12\x1c.kos.system.UploadOTARequest\x1a\x1d.google.longrunning.Operation\")\xca\x41&\n\x11UploadOTAResponse\x12\x11UploadOTAMetadataB0\n\x0e\x63om.kos.systemZ\x11kos/system;system\xaa\x02\nKOS.Systemb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'kos.system_pb2', _globals) -if not _descriptor._USE_C_DESCRIPTORS: - _globals['DESCRIPTOR']._loaded_options = None - _globals['DESCRIPTOR']._serialized_options = b'\n\016com.kos.systemZ\021kos/system;system\252\002\nKOS.System' - _globals['_SYSTEMSERVICE'].methods_by_name['UploadOTA']._loaded_options = None - _globals['_SYSTEMSERVICE'].methods_by_name['UploadOTA']._serialized_options = b'\312A&\n\021UploadOTAResponse\022\021UploadOTAMetadata' - _globals['_GETIPADDRESSESRESPONSE']._serialized_start=149 - _globals['_GETIPADDRESSESRESPONSE']._serialized_end=257 - _globals['_NETWORKINTERFACE']._serialized_start=259 - _globals['_NETWORKINTERFACE']._serialized_end=313 - _globals['_SETWIFICREDENTIALSREQUEST']._serialized_start=315 - _globals['_SETWIFICREDENTIALSREQUEST']._serialized_end=374 - _globals['_GETSYSTEMINFORESPONSE']._serialized_start=377 - _globals['_GETSYSTEMINFORESPONSE']._serialized_end=662 - _globals['_GETDIAGNOSTICLOGSREQUEST']._serialized_start=664 - _globals['_GETDIAGNOSTICLOGSREQUEST']._serialized_end=784 - _globals['_GETDIAGNOSTICLOGSRESPONSE']._serialized_start=786 - _globals['_GETDIAGNOSTICLOGSRESPONSE']._serialized_end=861 - _globals['_UPLOADOTAREQUEST']._serialized_start=863 - _globals['_UPLOADOTAREQUEST']._serialized_end=899 - _globals['_UPLOADOTARESPONSE']._serialized_start=901 - _globals['_UPLOADOTARESPONSE']._serialized_end=954 - _globals['_UPLOADOTAMETADATA']._serialized_start=956 - _globals['_UPLOADOTAMETADATA']._serialized_end=991 - _globals['_SYSTEMSERVICE']._serialized_start=994 - _globals['_SYSTEMSERVICE']._serialized_end=1467 -# @@protoc_insertion_point(module_scope) diff --git a/kos_core/kos/system_pb2_grpc.py b/kos_core/kos/system_pb2_grpc.py deleted file mode 100644 index c7b8677..0000000 --- a/kos_core/kos/system_pb2_grpc.py +++ /dev/null @@ -1,280 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc -import warnings - -from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from kos import common_pb2 as kos_dot_common__pb2 -from kos import system_pb2 as kos_dot_system__pb2 - -GRPC_GENERATED_VERSION = '1.68.1' -GRPC_VERSION = grpc.__version__ -_version_not_supported = False - -try: - from grpc._utilities import first_version_is_lower - _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) -except ImportError: - _version_not_supported = True - -if _version_not_supported: - raise RuntimeError( - f'The grpc package installed is at version {GRPC_VERSION},' - + f' but the generated code in kos/system_pb2_grpc.py depends on' - + f' grpcio>={GRPC_GENERATED_VERSION}.' - + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' - + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' - ) - - -class SystemServiceStub(object): - """The SystemService provides methods to interact with system-level functions. - """ - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.GetIPAddresses = channel.unary_unary( - '/kos.system.SystemService/GetIPAddresses', - request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - response_deserializer=kos_dot_system__pb2.GetIPAddressesResponse.FromString, - _registered_method=True) - self.SetWiFiCredentials = channel.unary_unary( - '/kos.system.SystemService/SetWiFiCredentials', - request_serializer=kos_dot_system__pb2.SetWiFiCredentialsRequest.SerializeToString, - response_deserializer=kos_dot_common__pb2.ActionResponse.FromString, - _registered_method=True) - self.GetSystemInfo = channel.unary_unary( - '/kos.system.SystemService/GetSystemInfo', - request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - response_deserializer=kos_dot_system__pb2.GetSystemInfoResponse.FromString, - _registered_method=True) - self.GetDiagnosticLogs = channel.unary_unary( - '/kos.system.SystemService/GetDiagnosticLogs', - request_serializer=kos_dot_system__pb2.GetDiagnosticLogsRequest.SerializeToString, - response_deserializer=kos_dot_system__pb2.GetDiagnosticLogsResponse.FromString, - _registered_method=True) - self.UploadOTA = channel.unary_unary( - '/kos.system.SystemService/UploadOTA', - request_serializer=kos_dot_system__pb2.UploadOTARequest.SerializeToString, - response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, - _registered_method=True) - - -class SystemServiceServicer(object): - """The SystemService provides methods to interact with system-level functions. - """ - - def GetIPAddresses(self, request, context): - """Retrieves IP addresses of network interfaces. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def SetWiFiCredentials(self, request, context): - """Sets Wi-Fi credentials. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetSystemInfo(self, request, context): - """Retrieves system information. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetDiagnosticLogs(self, request, context): - """Retrieves diagnostic logs. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def UploadOTA(self, request, context): - """Uploads an OTA update (long-running operation). - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_SystemServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'GetIPAddresses': grpc.unary_unary_rpc_method_handler( - servicer.GetIPAddresses, - request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - response_serializer=kos_dot_system__pb2.GetIPAddressesResponse.SerializeToString, - ), - 'SetWiFiCredentials': grpc.unary_unary_rpc_method_handler( - servicer.SetWiFiCredentials, - request_deserializer=kos_dot_system__pb2.SetWiFiCredentialsRequest.FromString, - response_serializer=kos_dot_common__pb2.ActionResponse.SerializeToString, - ), - 'GetSystemInfo': grpc.unary_unary_rpc_method_handler( - servicer.GetSystemInfo, - request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - response_serializer=kos_dot_system__pb2.GetSystemInfoResponse.SerializeToString, - ), - 'GetDiagnosticLogs': grpc.unary_unary_rpc_method_handler( - servicer.GetDiagnosticLogs, - request_deserializer=kos_dot_system__pb2.GetDiagnosticLogsRequest.FromString, - response_serializer=kos_dot_system__pb2.GetDiagnosticLogsResponse.SerializeToString, - ), - 'UploadOTA': grpc.unary_unary_rpc_method_handler( - servicer.UploadOTA, - request_deserializer=kos_dot_system__pb2.UploadOTARequest.FromString, - response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'kos.system.SystemService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - server.add_registered_method_handlers('kos.system.SystemService', rpc_method_handlers) - - - # This class is part of an EXPERIMENTAL API. -class SystemService(object): - """The SystemService provides methods to interact with system-level functions. - """ - - @staticmethod - def GetIPAddresses(request, - 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, - '/kos.system.SystemService/GetIPAddresses', - google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - kos_dot_system__pb2.GetIPAddressesResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def SetWiFiCredentials(request, - 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, - '/kos.system.SystemService/SetWiFiCredentials', - kos_dot_system__pb2.SetWiFiCredentialsRequest.SerializeToString, - kos_dot_common__pb2.ActionResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def GetSystemInfo(request, - 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, - '/kos.system.SystemService/GetSystemInfo', - google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - kos_dot_system__pb2.GetSystemInfoResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def GetDiagnosticLogs(request, - 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, - '/kos.system.SystemService/GetDiagnosticLogs', - kos_dot_system__pb2.GetDiagnosticLogsRequest.SerializeToString, - kos_dot_system__pb2.GetDiagnosticLogsResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def UploadOTA(request, - 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, - '/kos.system.SystemService/UploadOTA', - kos_dot_system__pb2.UploadOTARequest.SerializeToString, - google_dot_longrunning_dot_operations__pb2.Operation.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) diff --git a/test.py b/test.py deleted file mode 100644 index ade7a80..0000000 --- a/test.py +++ /dev/null @@ -1,10 +0,0 @@ -"""Test the speech service """ -from pykos import KOS - -# Connect to KOS running on localhost at port 50051 -client = KOS(ip='localhost', port=50051) - -# Call the synthesize method -response = client.speech.synthesize(text="Hello, world!") - -print(response) From 1066a9ccca40d35ee3b875e1fdb15dfe9a454580 Mon Sep 17 00:00:00 2001 From: budzianowski Date: Thu, 23 Jan 2025 00:45:32 -0800 Subject: [PATCH 3/5] add stub fmt --- kos-py/pykos/services/speech.py | 2 +- kos-py/tests/test_pykos.py | 4 ++++ kos-stub/src/speech.rs | 32 ++++++++++++++++++++++++++++++++ kos/build.rs | 5 ++++- kos/proto/kos/speech.proto | 2 +- 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 kos-stub/src/speech.rs diff --git a/kos-py/pykos/services/speech.py b/kos-py/pykos/services/speech.py index 531dff2..3cf353e 100644 --- a/kos-py/pykos/services/speech.py +++ b/kos-py/pykos/services/speech.py @@ -53,7 +53,7 @@ async def synthesize(self, text: str) -> speech_pb2.SynthesizeResponse: response = await self.stub.Synthesize(request) if response.HasField("error"): raise RuntimeError(f"Synthesis error: {response.error}") - return response.output_file + return response.file_path async def transcribe(self, audio_data: str) -> str: """Transcribe speech to text. diff --git a/kos-py/tests/test_pykos.py b/kos-py/tests/test_pykos.py index 0c66bef..a8eb0a7 100644 --- a/kos-py/tests/test_pykos.py +++ b/kos-py/tests/test_pykos.py @@ -42,6 +42,10 @@ async def test_pykos() -> None: stop_kclip_response = await client.process_manager.stop_kclip() assert stop_kclip_response.clip_uuid is not None + # Tests the speech endpoints. + speech_response = await client.speech.synthesize(text="Hello, world!") + assert speech_response is not None + def _is_server_running(address: str) -> bool: try: diff --git a/kos-stub/src/speech.rs b/kos-stub/src/speech.rs new file mode 100644 index 0000000..000f75e --- /dev/null +++ b/kos-stub/src/speech.rs @@ -0,0 +1,32 @@ +use async_trait::async_trait; +use eyre::Result; +use kos::hal::Speech; +use kos::kos_proto::speech::SynthesizeResponse; +use std::process::Command; +use uuid::Uuid; +pub struct StubSpeech {} + +impl Default for StubSpeech { + fn default() -> Self { + Self::new() + } +} + +impl StubSpeech { + pub fn new() -> Self { + StubSpeech {} + } +} + +#[async_trait] +impl Speech for StubSpeech { + async fn synthesize(&self, text: String) -> Result { + // Generate a unique filename for the wav output + let output_file = format!("synthesize_{}.wav", Uuid::new_v4()); + + Ok(SynthesizeResponse { + file_path: output_file, + error: None, + }) + } +} diff --git a/kos/build.rs b/kos/build.rs index b3e1b74..f09f9ea 100644 --- a/kos/build.rs +++ b/kos/build.rs @@ -6,7 +6,10 @@ fn main() { let proto_root = "proto"; // Where to output the compiled Rust files - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let out_dir = PathBuf::from(match env::var("OUT_DIR") { + Ok(dir) => dir, + Err(e) => panic!("Failed to get OUT_DIR: {}", e), + }); // List of Protobuf files let protos = [ diff --git a/kos/proto/kos/speech.proto b/kos/proto/kos/speech.proto index 3d5aa17..1551b19 100644 --- a/kos/proto/kos/speech.proto +++ b/kos/proto/kos/speech.proto @@ -32,6 +32,6 @@ message SynthesizeRequest { } message SynthesizeResponse { - string output_file = 1; + string file_path = 1; kos.common.Error error = 2; } From 76cf7c1921c13efc598db988b42133683acaf064 Mon Sep 17 00:00:00 2001 From: budzianowski Date: Thu, 23 Jan 2025 00:49:04 -0800 Subject: [PATCH 4/5] static fix --- kos-py/pykos/services/speech.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/kos-py/pykos/services/speech.py b/kos-py/pykos/services/speech.py index 3cf353e..59c4986 100644 --- a/kos-py/pykos/services/speech.py +++ b/kos-py/pykos/services/speech.py @@ -1,27 +1,11 @@ """Speech service client.""" -from typing import TypedDict, Unpack - import grpc import grpc.aio from kos_protos import speech_pb2, speech_pb2_grpc -class AudioConfig(TypedDict): - """Audio configuration parameters. - - Args: - sample_rate: Sample rate in Hz (e.g., 44100) - bit_depth: Bit depth (e.g., 16) - channels: Number of channels (1 for mono, 2 for stereo) - """ - - sample_rate: int - bit_depth: int - channels: int - - class SpeechServiceClient: """Client for the SpeechService. From 3a7d6cd38e5aed4e322ccbaf5fde6d672b7839d5 Mon Sep 17 00:00:00 2001 From: budzianowski Date: Thu, 23 Jan 2025 00:59:31 -0800 Subject: [PATCH 5/5] fix pasta --- kos-py/pykos/services/speech.py | 2 +- kos-py/tests/test_pykos.py | 56 --------------------------------- kos/proto/kos/speech.proto | 7 +++++ kos/src/hal.rs | 2 -- 4 files changed, 8 insertions(+), 59 deletions(-) delete mode 100644 kos-py/tests/test_pykos.py diff --git a/kos-py/pykos/services/speech.py b/kos-py/pykos/services/speech.py index 59c4986..bb0d139 100644 --- a/kos-py/pykos/services/speech.py +++ b/kos-py/pykos/services/speech.py @@ -27,7 +27,7 @@ async def synthesize(self, text: str) -> speech_pb2.SynthesizeResponse: text: Text to synthesize Returns: - Audio data as a string. + Output file to the synthesized speech. Raises: RuntimeError: If synthesis fails. diff --git a/kos-py/tests/test_pykos.py b/kos-py/tests/test_pykos.py deleted file mode 100644 index a8eb0a7..0000000 --- a/kos-py/tests/test_pykos.py +++ /dev/null @@ -1,56 +0,0 @@ -"""Defines a dummy test.""" - -import grpc -import pytest - -import pykos - - -def test_dummy() -> None: - assert True - - -@pytest.mark.asyncio -async def test_pykos() -> None: - # In order to test this client, you should run the stub KOS server. - # This can be done from the parent directory with `cargo run --bin kos-stub` - if not _is_server_running("127.0.0.1:50051"): - pytest.skip("No active gRPC server at 127.0.0.1:50051") - - # Tests configuring the actuator. - async with pykos.KOS("127.0.0.1") as client: - actuator_response = await client.actuator.configure_actuator(actuator_id=1) - assert actuator_response.success - - # Tests getting the actuator state. - actuator_state = await client.actuator.get_actuators_state(actuator_ids=[1]) - assert actuator_state.states[0].actuator_id == 1 - - # Tests the IMU endpoints. - imu_response = await client.imu.get_imu_values() - assert imu_response.accel_x is not None - await client.imu.get_imu_advanced_values() - await client.imu.get_euler_angles() - await client.imu.get_quaternion() - await client.imu.calibrate() - zero_response = await client.imu.zero(duration=1.0, max_retries=1, max_angular_error=1.0) - assert zero_response.success - - # Tests the K-Clip endpoints. - start_kclip_response = await client.process_manager.start_kclip(action="start") - assert start_kclip_response.clip_uuid is not None - stop_kclip_response = await client.process_manager.stop_kclip() - assert stop_kclip_response.clip_uuid is not None - - # Tests the speech endpoints. - speech_response = await client.speech.synthesize(text="Hello, world!") - assert speech_response is not None - - -def _is_server_running(address: str) -> bool: - try: - channel = grpc.insecure_channel(address) - grpc.channel_ready_future(channel).result(timeout=1) - return True - except grpc.FutureTimeoutError: - return False diff --git a/kos/proto/kos/speech.proto b/kos/proto/kos/speech.proto index 1551b19..afe0a1c 100644 --- a/kos/proto/kos/speech.proto +++ b/kos/proto/kos/speech.proto @@ -18,6 +18,12 @@ service SpeechService { rpc Synthesize(SynthesizeRequest) returns (SynthesizeResponse); } +enum Model { + ESPEAK_NG = 0; + KMODEL = 1; + LOCAL = 2; +} + message TranscribeRequest { string audio_data = 1; } @@ -29,6 +35,7 @@ message TranscribeResponse { message SynthesizeRequest { string text = 1; + Model model = 2; } message SynthesizeResponse { diff --git a/kos/src/hal.rs b/kos/src/hal.rs index c7b4a32..213a732 100644 --- a/kos/src/hal.rs +++ b/kos/src/hal.rs @@ -107,10 +107,8 @@ pub trait ProcessManager: Send + Sync { async fn stop_kclip(&self) -> Result; } -// TODO action response pfb30 #[async_trait] pub trait Speech: Send + Sync { - // async fn start_kclip(&self, action: String) -> Result; async fn synthesize(&self, text: String) -> Result; }