added basic controller
This commit is contained in:
parent
8a972cd660
commit
e717238727
8 changed files with 1105 additions and 191 deletions
149
common/Cargo.lock
generated
149
common/Cargo.lock
generated
|
@ -11,106 +11,20 @@ dependencies = [
|
|||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atomic-polyfill"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4"
|
||||
dependencies = [
|
||||
"critical-section",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "cobs"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
|
||||
|
||||
[[package]]
|
||||
name = "common"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"framed",
|
||||
"nalgebra",
|
||||
"postcard",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc16"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "338089f42c427b86394a5ee60ff321da23a5c89c9d89514c829687b26359fcff"
|
||||
|
||||
[[package]]
|
||||
name = "critical-section"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
|
||||
|
||||
[[package]]
|
||||
name = "encode_unicode"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
|
||||
|
||||
[[package]]
|
||||
name = "framed"
|
||||
version = "0.4.3"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"cobs",
|
||||
"crc16",
|
||||
"ref_slice",
|
||||
"serde",
|
||||
"ssmarshal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hash32"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heapless"
|
||||
version = "0.7.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f"
|
||||
dependencies = [
|
||||
"atomic-polyfill",
|
||||
"hash32",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"spin",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nalgebra"
|
||||
version = "0.31.4"
|
||||
|
@ -170,17 +84,6 @@ version = "1.0.15"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "postcard"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "170a2601f67cc9dba8edd8c4870b15f71a6a2dc196daec8c83f72b59dff628a8"
|
||||
dependencies = [
|
||||
"cobs",
|
||||
"heapless",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.93"
|
||||
|
@ -199,33 +102,6 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ref_slice"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4ed1d73fb92eba9b841ba2aef69533a060ccc0d3ec71c90aeda5996d4afb7a9"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.217"
|
||||
|
@ -258,31 +134,6 @@ dependencies = [
|
|||
"paste",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ssmarshal"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850"
|
||||
dependencies = [
|
||||
"encode_unicode",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.96"
|
||||
|
|
|
@ -6,5 +6,3 @@ edition = "2021"
|
|||
[dependencies]
|
||||
nalgebra = { version = "0.31.2", default-features=false, features = ["serde-serialize-no-std"] }
|
||||
serde = { version = "1.0.203", default-features = false, features = ["derive"] }
|
||||
postcard = "1.0.0"
|
||||
framed = {path='/home/andy/programming/framed-rs/framed', default-features=false, features = ["use_nightly"]}
|
||||
|
|
|
@ -61,9 +61,9 @@ async fn telemetry_server() -> Result<()>{
|
|||
tokio::spawn(async move {
|
||||
let mut reader = BufReader::new(receiver).lines();
|
||||
while let Some(line) = reader.next_line().await? {
|
||||
println!("recv: {line}");
|
||||
//println!("recv: {line}");
|
||||
if let result::Result::Ok(control) = serde_json::from_str::<Control>(&line) {
|
||||
println!("deserialized: data is {}", control.data);
|
||||
//println!("deserialized: data is {}", control.data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ async fn telemetry_server() -> Result<()>{
|
|||
async fn camera_manager(await_frame: Arc<Notify>, latest_frame: Arc<RwLock<Vec<u8>>>) -> Result<()>{
|
||||
let cameras = nokhwa::query(ApiBackend::Auto)?;
|
||||
|
||||
let camera = cameras.get(0).context("no cameras")?;
|
||||
let camera = cameras.get(2).context("no cameras")?;
|
||||
println!("using: {}",camera.human_name());
|
||||
|
||||
let requested = RequestedFormat::new::<RgbFormat>(RequestedFormatType::HighestResolution(Resolution::new(320, 240)));
|
||||
|
|
1044
interface/Cargo.lock
generated
Normal file
1044
interface/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
13
interface/Cargo.toml
Normal file
13
interface/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "interface"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
common = { path = "../common" }
|
||||
tokio = { version = "1.43.0", features = ["full"] }
|
||||
anyhow = "1.0.95"
|
||||
gilrs = "0.11.0"
|
||||
futures = "0.3.31"
|
||||
serde = { version = "1.0.217", features = ["alloc"] }
|
||||
postcard = { version = "1.0.0", features = ["alloc", "use-std"] }
|
42
interface/src/main.rs
Normal file
42
interface/src/main.rs
Normal file
|
@ -0,0 +1,42 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use anyhow::Context;
|
||||
use common::Command;
|
||||
use gilrs::{Axis, Gilrs};
|
||||
use tokio::{io::{AsyncWriteExt, BufWriter}, net::TcpStream, time::sleep};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
println!("Hello, world!");
|
||||
|
||||
let gamepads = Gilrs::new().unwrap();
|
||||
let (_, gamepad) = gamepads.gamepads().nth(0).context("no gamepads")?;
|
||||
let ly = gamepad.axis_code(Axis::LeftStickY).context("no left joystick")?;
|
||||
let rx = gamepad.axis_code(Axis::RightStickX).context("no right joystick")?;
|
||||
|
||||
let mut robot = TcpStream::connect("pelican.dyn.wpi.edu:3322").await?;
|
||||
robot.set_nodelay(true)?;
|
||||
|
||||
|
||||
let (_telem, robot_controller) = robot.split();
|
||||
|
||||
let mut robot_controller = BufWriter::new(robot_controller);
|
||||
|
||||
loop {
|
||||
let values = gamepad.state();
|
||||
|
||||
let ly = values.axis_data(ly).context("no left")?.value();
|
||||
let rx = values.axis_data(rx).context("no left")?.value();
|
||||
|
||||
let cmd = Command::Twist(ly, rx);
|
||||
|
||||
let encoded = postcard::to_stdvec(&cmd)?;
|
||||
|
||||
robot_controller.write_u32(encoded.len() as u32).await?;
|
||||
robot_controller.write_all(&encoded).await?;
|
||||
|
||||
robot_controller.flush().await?;
|
||||
|
||||
sleep(Duration::from_micros(3500)).await;
|
||||
}
|
||||
}
|
24
northbridge/Cargo.lock
generated
24
northbridge/Cargo.lock
generated
|
@ -114,9 +114,7 @@ checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
|
|||
name = "common"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"framed 0.4.3",
|
||||
"nalgebra",
|
||||
"postcard",
|
||||
"serde",
|
||||
]
|
||||
|
||||
|
@ -142,12 +140,6 @@ version = "0.3.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11a65c4797332f3e3a5945e0377875afc79b1bdc87082a4f98ac1ef15b47e2dd"
|
||||
|
||||
[[package]]
|
||||
name = "crc16"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "338089f42c427b86394a5ee60ff321da23a5c89c9d89514c829687b26359fcff"
|
||||
|
||||
[[package]]
|
||||
name = "critical-section"
|
||||
version = "1.2.0"
|
||||
|
@ -172,18 +164,6 @@ version = "0.3.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
|
||||
|
||||
[[package]]
|
||||
name = "framed"
|
||||
version = "0.4.3"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"cobs 0.2.3",
|
||||
"crc16 0.4.0",
|
||||
"ref_slice",
|
||||
"serde",
|
||||
"ssmarshal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "framed"
|
||||
version = "0.4.3"
|
||||
|
@ -192,7 +172,7 @@ checksum = "5d939d56a82ce8751cd473e2e399f8d60f0a7f78cd0746fef857bd176c5b8612"
|
|||
dependencies = [
|
||||
"byteorder",
|
||||
"cobs 0.1.4",
|
||||
"crc16 0.3.4",
|
||||
"crc16",
|
||||
"ref_slice",
|
||||
"serde",
|
||||
"ssmarshal",
|
||||
|
@ -463,7 +443,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"common",
|
||||
"framed 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"framed",
|
||||
"futures",
|
||||
"futures-core",
|
||||
"n",
|
||||
|
|
16
southbridge/Cargo.lock
generated
16
southbridge/Cargo.lock
generated
|
@ -148,9 +148,7 @@ dependencies = [
|
|||
name = "common"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"framed 0.4.3",
|
||||
"nalgebra",
|
||||
"postcard",
|
||||
"serde",
|
||||
]
|
||||
|
||||
|
@ -603,18 +601,6 @@ version = "1.0.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "framed"
|
||||
version = "0.4.3"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"cobs",
|
||||
"crc16",
|
||||
"ref_slice",
|
||||
"serde",
|
||||
"ssmarshal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "framed"
|
||||
version = "0.4.3"
|
||||
|
@ -1374,7 +1360,7 @@ dependencies = [
|
|||
"embedded-io",
|
||||
"embedded-io-async",
|
||||
"embedded-storage",
|
||||
"framed 0.4.3 (git+https://git.ank.dev/ank/framed-rs)",
|
||||
"framed",
|
||||
"heapless 0.8.0",
|
||||
"log",
|
||||
"mpu6050",
|
||||
|
|
Loading…
Reference in a new issue