Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
bump to v23.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
s5suzuki committed May 11, 2024
1 parent 9761d26 commit ee54692
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "autd3-link-visualizer"
version = "22.0.4"
version = "23.0.0"
authors = ["shun suzuki <suzuki@hapis.k.u-tokyo.ac.jp>"]
edition = "2021"

Expand All @@ -11,8 +11,8 @@ readme = "README.md"
keywords = ["autd"]

[dependencies]
autd3-firmware-emulator = { version = "22.0.4" }
autd3-driver = { version = "22.0.4" }
autd3-firmware-emulator = { version = "23.0.0" }
autd3-driver = { version = "23.0.0" }
thiserror = "1.0.30"
pyo3 = { version = "0.21.0", features = ["abi3", "auto-initialize"], optional = true }
which = { version = "6.0.0", optional = true }
Expand All @@ -26,8 +26,8 @@ num-complex = "0.4.3"

[dev-dependencies]
anyhow = "1.0.75"
autd3 = { version = "22.0.4" }
autd3-gain-holo = { version = "22.0.4" }
autd3 = { version = "23.0.0" }
autd3-gain-holo = { version = "23.0.0" }
tokio = { version = "1.34.0", features = ["macros", "rt-multi-thread"] }

[features]
Expand Down
7 changes: 5 additions & 2 deletions examples/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ async fn main() -> Result<()> {
#[cfg(not(feature = "python"))]
let link = Visualizer::plotters();

#[cfg(feature = "gpu")]
let link = link.with_gpu(-1);

let mut autd = Controller::builder()
.add_device(AUTD3::new(Vector3::zeros()))
.open(link)
.await?;

let center = autd.geometry.center() + Vector3::new(0., 0., 150.0 * MILLIMETER);
let center = autd.geometry.center() + Vector3::new(0., 0., 150.0 * mm);

let g = Focus::new(center);
let m = Square::new(150.);
let m = Square::new(150. * Hz);

autd.send((m, g)).await?;

Expand Down
35 changes: 21 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ use autd3_driver::{
directivity::{Directivity, Sphere},
propagate,
},
common::{EmitIntensity, Phase, Segment},
cpu::{RxMessage, TxDatagram},
defined::Complex,
defined::{Complex, PI},
error::AUTDInternalError,
firmware::{
cpu::{RxMessage, TxDatagram},
fpga::{EmitIntensity, Phase, Segment},
},
geometry::{Geometry, Vector3},
link::{Link, LinkBuilder},
};
Expand Down Expand Up @@ -312,7 +314,7 @@ impl<D: Directivity, B: Backend> Visualizer<D, B> {
}

/// Get raw modulation data
pub fn modulation(&self, segment: Segment) -> Vec<EmitIntensity> {
pub fn modulation(&self, segment: Segment) -> Vec<u8> {
self.cpus[0]
.fpga()
.modulation(segment)
Expand Down Expand Up @@ -344,15 +346,17 @@ impl<D: Directivity, B: Backend> Visualizer<D, B> {
.enumerate()
.flat_map(|(i, cpu)| {
let dev = &geometry[i];
let sound_speed = dev.sound_speed;
let wavenumber = dev.wavenumber() as f32;
cpu.fpga()
.drives(segment, idx)
.iter()
.zip(dev.iter().map(|t| t.wavenumber(sound_speed)))
.map(|(d, w)| {
let amp = d.intensity().value() as f32 / 255.0;
.map(|d| {
let amp = (std::f32::consts::PI
* cpu.fpga().to_pulse_width(d.intensity(), 0xFF) as f32
/ 512.0)
.sin();
let phase = d.phase().radian() as f32;
[amp, phase, 0., w as f32]
[amp, phase, 0., wavenumber]
})
.collect::<Vec<_>>()
})
Expand All @@ -367,14 +371,17 @@ impl<D: Directivity, B: Backend> Visualizer<D, B> {
.iter()
.enumerate()
.fold(Complex::new(0., 0.), |acc, (i, cpu)| {
let sound_speed = geometry[i].sound_speed;
let wavenumber = geometry[i].wavenumber();
let drives = cpu.fpga().drives(segment, idx);
acc + geometry[i].iter().zip(drives.iter()).fold(
Complex::new(0., 0.),
|acc, (t, d)| {
let amp = d.intensity().value() as f64 / 255.0;
let amp = (PI
* cpu.fpga().to_pulse_width(d.intensity(), 0xFF) as f64
/ 512.0)
.sin();
let phase = d.phase().radian();
acc + propagate::<D>(t, 0.0, sound_speed, target)
acc + propagate::<D>(t, 0.0, wavenumber, target)
* Complex::from_polar(amp, phase)
},
)
Expand Down Expand Up @@ -469,7 +476,7 @@ impl<D: Directivity, B: Backend> Visualizer<D, B> {
let m = self
.modulation(segment)
.iter()
.map(|v| v.value() as f64 / 255.0)
.map(|&v| v as f64 / 255.0)
.collect::<Vec<_>>();
B::plot_modulation(m, config)?;
Ok(())
Expand Down Expand Up @@ -506,7 +513,7 @@ impl<D: Directivity, B: Backend> Link for Visualizer<D, B> {

self.cpus.iter_mut().for_each(|cpu| {
cpu.update();
rx[cpu.idx()] = RxMessage::new(cpu.ack(), cpu.rx_data());
rx[cpu.idx()] = cpu.rx();
});

Ok(true)
Expand Down

0 comments on commit ee54692

Please sign in to comment.