Compare commits
2 commits
053ad4fb63
...
7d8337bd5e
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d8337bd5e | |||
| f65cc9236b |
4 changed files with 75 additions and 6 deletions
52
hostcontrol/Cargo.lock
generated
52
hostcontrol/Cargo.lock
generated
|
|
@ -656,6 +656,46 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831"
|
||||
|
||||
[[package]]
|
||||
name = "clipboard-win"
|
||||
version = "5.4.0"
|
||||
|
|
@ -1443,9 +1483,11 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
|||
name = "hostcontrol"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"eframe",
|
||||
"egui",
|
||||
"env_logger",
|
||||
"log",
|
||||
"nalgebra",
|
||||
"nalgebra-macros",
|
||||
"serialport",
|
||||
|
|
@ -1759,9 +1801,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.27"
|
||||
version = "0.4.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
||||
|
||||
[[package]]
|
||||
name = "mach2"
|
||||
|
|
@ -2935,6 +2977,12 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.26.3"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0", features = ["derive"] }
|
||||
nalgebra = { version = "0.33" }
|
||||
serialport = { version = "4", default-features = false }
|
||||
thiserror = "2"
|
||||
|
|
@ -11,3 +12,4 @@ nalgebra-macros = "^0.2.2"
|
|||
env_logger = "0.11.8"
|
||||
egui = "0.31.1"
|
||||
eframe = "0.31.1"
|
||||
log = "0.4.29"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,24 @@
|
|||
use std::{thread::sleep, time::Duration};
|
||||
use clap::Parser;
|
||||
|
||||
mod stage;
|
||||
|
||||
#[derive(clap::Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct CliArgs {
|
||||
/// Interface to talk to movement stage
|
||||
#[arg(long, default_value="/dev/ttyACM0")]
|
||||
stage_device: String,
|
||||
|
||||
/// Speed of the stage device (bps)
|
||||
#[arg(long, default_value="115200")]
|
||||
tty_speed: u32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = CliArgs::parse();
|
||||
env_logger::init();
|
||||
let stage_io = stage::StageIO::new("/dev/ttyACM0", 115200).unwrap();
|
||||
let stage_io = stage::StageIO::new(&args.stage_device, args.tty_speed).unwrap();
|
||||
let mut s = stage::Stage::new(stage_io, 1.12).unwrap();
|
||||
let origin = nalgebra::vector![3000.0, 0.0, -6000.0];
|
||||
//println!("{}", s.version().unwrap());
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use std::time::Duration;
|
||||
use thiserror::Error;
|
||||
use log::debug;
|
||||
|
||||
fn new_camera_rotation(theta: f64) -> nalgebra::Matrix3<f64> {
|
||||
nalgebra::matrix![
|
||||
|
|
@ -55,6 +56,8 @@ pub type StageIOResult<T> = std::result::Result<T, StageIOError>;
|
|||
impl StageIO {
|
||||
pub fn new(port: &str, speed: u32) -> StageIOResult<Self> {
|
||||
let serial = serialport::new(port, speed).timeout(Duration::from_secs(60)).open()?;
|
||||
// TODO: read and discard initial characters; some devices like to be
|
||||
// chatty on start-up.
|
||||
Ok(Self { serial })
|
||||
}
|
||||
|
||||
|
|
@ -71,10 +74,12 @@ impl StageIO {
|
|||
}
|
||||
|
||||
// Send request and wait for response deliminated with a newline
|
||||
fn send_request<S: AsRef<str>>(&mut self, command: S) -> StageIOResult<String> {
|
||||
pub fn send_request<S: AsRef<str>>(&mut self, command: S) -> StageIOResult<String> {
|
||||
debug!("->: {:?}", command.as_ref());
|
||||
self.serial.write_all(command.as_ref().as_bytes()).map_err(|e| StageIOError::Write(e))?;
|
||||
let res = self.receive_until("\n")?;
|
||||
Ok(res.trim().to_string())
|
||||
let response = self.receive_until("\n")?;
|
||||
debug!("<-: {:?}", response);
|
||||
Ok(response.trim().to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue