Skip to content

Commit

Permalink
general structure
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Nov 14, 2024
1 parent a10cb0a commit 0e01da2
Show file tree
Hide file tree
Showing 17 changed files with 1,494 additions and 37 deletions.
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
15 changes: 8 additions & 7 deletions actuator/actuator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ license.workspace = true

[dependencies]

async-trait = "^0.1"
lazy_static = "^1.4.0"
pest = "^2.5"
pest_derive = "^2.5"
thiserror = "1.0"
lazy_static = "^1.4.0"
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"

[[bin]]

name = "server"
path = "src/bin/server.rs"
tonic-build = "^0.12"

[lib]

Expand Down
12 changes: 4 additions & 8 deletions actuator/actuator/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@ use std::env;
use std::path::PathBuf;

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

tonic_build::configure()
.out_dir(out_dir)
.compile(&[proto_root], &[proto_root])
.unwrap();
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"))
.protoc_arg("--experimental_allow_proto3_optional")
.compile(&protos, &includes)
.compile_protos(&protos, &includes)
.expect("Failed to compile protos");

for proto in protos {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@ syntax = "proto3";

package actuator.common;

service ActuatorService {
import "google/protobuf/empty.proto";
import "google/longrunning/operations.proto";

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

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

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

message CommandActuatorsRequest {
repeated SingleActuatorCommand commands = 1;
repeated ActuatorCommand commands = 1;
}

message CommandActuatorsResponse {
Expand Down
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

0 comments on commit 0e01da2

Please sign in to comment.