Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use grpc instead of python bindings #52

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ jobs:
pip install cibuildwheel
shell: bash

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Build package
env:
CIBW_SKIP: "pp* *-musllinux*" # Skip PyPy and musllinux builds
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]

members = [
"actuator/actuator",
"actuator/bindings",
"actuator/robstride",
]
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

Defines a package to make it easy and performant to control actuators.

![System Architecture](./docs/architecture.png)

## Getting Started

See the documentation [here](https://docs.kscale.dev/software/actuators/overview) for instructions on getting started with this package.
37 changes: 37 additions & 0 deletions actuator/actuator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]

name = "actuator"
build = "build.rs"
readme = "README.md"
description = "Actuator control service"

version.workspace = true
edition.workspace = true
authors.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]

async-trait = "^0.1"
lazy_static = "^1.4.0"
pest = "^2.5"
pest_derive = "^2.5"
prost = "0.13"
prost-types = "0.13"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
thiserror = "1.0"
tokio = { version = "1", features = ["full"] }
tonic = { version = "^0.12", features = ["transport"] }

[build-dependencies]

prost-build = "^0.13.3"
tonic-build = "^0.12"

[lib]

name = "actuator"
crate-type = ["cdylib", "rlib"]
path = "src/lib.rs"
3 changes: 3 additions & 0 deletions actuator/actuator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# actuator

This crate contains the code for running the actuator control service.
26 changes: 26 additions & 0 deletions actuator/actuator/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use std::env;
use std::path::PathBuf;

fn main() {
let proto_root = "proto";
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let protos = [
"actuator/common.proto",
"google/longrunning/operations.proto",
];

let includes = [proto_root, &format!("{}/googleapis", proto_root)];

std::fs::create_dir_all(out_dir.join("actuator")).expect("Failed to create actuator directory");

tonic_build::configure()
.build_server(true)
.out_dir(out_dir.join("actuator"))
.compile_protos(&protos, &includes)
.expect("Failed to compile protos");

for proto in protos {
println!("cargo:rerun-if-changed={}/actuator/{}", proto_root, proto);
}
println!("cargo:rerun-if-changed={}", proto_root);
}
39 changes: 39 additions & 0 deletions actuator/actuator/proto/actuator/common.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
syntax = "proto3";

package actuator.common;

import "google/protobuf/empty.proto";
import "google/longrunning/operations.proto";

service ActuatorController {
rpc CommandActuators(CommandActuatorsRequest) returns (CommandActuatorsResponse) {}
}

message ActuatorCommand {
uint32 actuator_id = 1;
double position = 2;
double velocity = 3;
double torque = 4;
double kp = 5;
double kd = 6;
}

message ActuatorStatus {
uint32 actuator_id = 1;
double position = 2;
double velocity = 3;
}

message CommandActuatorsRequest {
repeated ActuatorCommand commands = 1;
}

message CommandActuatorsResponse {
repeated ActuatorStatus statuses = 1;
ResponseCode response_code = 2;
}

enum ResponseCode {
OK = 0;
ERROR = 1;
}
31 changes: 31 additions & 0 deletions actuator/actuator/proto/googleapis/google/api/annotations.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.api;

import "google/api/http.proto";
import "google/protobuf/descriptor.proto";

option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";

extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
Loading
Loading