This is the development version of the documentation. It may change before the next release. See 0.6.x for the latest release.
ConfigFociStm
ConfigFociStm is a low-level command that configures the playback parameters of the Foci STM bank.
ConfigFociStm { bank, config, size, num_foci, sound_speed, loop_behavior,};ConfigFociStm( bank=bank, config=config, size=size, num_foci=num_foci, sound_speed=sound_speed, loop_behavior=loop_behavior,)new ConfigFociStm( bank: bank, config: config, size: size, numFoci: numFoci, soundSpeed: soundSpeed, loopBehavior: loopBehavior);| Field | Type | Description |
|---|---|---|
bank |
PatternBank |
Target bank |
config |
SamplingConfig |
Playback sampling frequency |
size |
usize |
Number of STM samples (at least 2) |
num_foci |
u8 |
Number of focal points per sample (the N of ControlPoints<N>) |
sound_speed |
Velocity |
Sound speed used for focal point computation |
loop_behavior |
LoopBehavior |
Playback loop count (Infinite / Finite) |
The minimum size is 2.
To emit a single focal point statically, use Pattern instead of an STM.
For the timing at which loop_behavior and the transition take effect see ChangePatternBank.
Example
Section titled “Example”ConfigFociStm is used within the flow of writing the focal point sequence with WriteFociBuffer and then switching playback with ChangePatternBank.
use autd3_rs::commands::{ChangePatternBank, ConfigFociStm, StmConfig, WriteFociBuffer, circle};use autd3_rs::geometry::{Autd3, Geometry, Vector3, offset};use autd3_rs::units::{Hz, m, mm, s};use autd3_rs::value::{Intensity, LoopBehavior, PatternBank, TransitionMode};use autd3_rs::{Client, ClientConfig};use autd3_rs_link_nop::Nop;
let geometry = Geometry::new(vec![Autd3::default()]);let client = Client::open(&geometry, Nop, ClientConfig::default()).await?;
let center = geometry.center() + offset(0.0 * mm, 0.0 * mm, 150.0 * mm);let mut points = Vec::new();circle( center, 30.0 * mm, 200, Vector3::z_axis(), Intensity::MAX, &mut points,);
let bank = PatternBank::B0;
let mut builder = client.datagram_builder();builder.push(WriteFociBuffer { bank, index_offset: 0, points: &points,});builder.push(ConfigFociStm { bank, config: StmConfig::new(1.0 * Hz).into_sampling_config(points.len()), size: points.len(), num_foci: 1, sound_speed: 340.0 * m / s, loop_behavior: LoopBehavior::Infinite,});builder.push(ChangePatternBank { bank, transition_mode: TransitionMode::Immediate,});let frames = builder.build()?;for frame in &frames { client.send_checked(frame).await?;}
client.close().await?;import asyncio
import numpy as np
from autd3 import Client, ClientConfigfrom autd3.commands import ChangePatternBank, ConfigFociStm, StmConfig, WriteFociBuffer, circlefrom autd3.geometry import Autd3, Geometryfrom autd3.units import Hz, m, sfrom autd3.value import Intensity, LoopBehavior, PatternBank, TransitionModefrom autd3_link_nop import Nop
async def main() -> None: geometry = Geometry([Autd3([0.0, 0.0, 0.0], [1.0, 0.0, 0.0, 0.0])]) client = await Client.open(geometry, Nop(), ClientConfig())
center = geometry.center() + np.array([0.0, 0.0, 150.0]) points = [] circle(center, 30.0, 200, [0.0, 0.0, 1.0], Intensity.MAX, points)
bank = PatternBank.B0
builder = client.datagram_builder() builder.push( WriteFociBuffer( bank=bank, index_offset=0, points=points, ) ) builder.push( ConfigFociStm( bank=bank, config=StmConfig(1.0 * Hz).into_sampling_config(len(points)), size=len(points), num_foci=1, sound_speed=340.0 * m / s, loop_behavior=LoopBehavior.Infinite, ) ) builder.push( ChangePatternBank( bank=bank, transition_mode=TransitionMode.Immediate, ) ) frames = builder.build() for frame in frames: await client.send_checked(frame)
await client.close()
asyncio.run(main())using System.Collections.Generic;using System.Numerics;using System.Threading.Tasks;using AUTD3;using AUTD3.Link;using Nop = AUTD3.Link.Nop;using static AUTD3.Units;
var geometry = new Geometry(new[] { new Autd3(Vector3.Zero) });var client = await Client.OpenAsync(geometry, new Nop(), new ClientConfig());
var center = geometry.Center + new Vector3(0.0f, 0.0f, 150.0f);var dst = new List<ControlPoints>();Stm.Circle( center, 30.0f * mm, 200, Vector3.UnitZ, Intensity.Max, dst);var points = dst.ToArray();
var bank = PatternBank.B0;
var builder = client.DatagramBuilder();builder.Push(new WriteFociBuffer( bank: bank, indexOffset: 0, points: points));builder.Push(new ConfigFociStm( bank: bank, config: new SamplingConfig(points.Length * Hz), size: (uint)points.Length, numFoci: 1, soundSpeed: 340.0f * m / s, loopBehavior: LoopBehavior.Infinite));builder.Push(new ChangePatternBank( bank: bank, transitionMode: TransitionMode.Immediate));var frames = builder.Build();foreach (var frame in frames){ await client.SendCheckedAsync(frame);}
await client.CloseAsync();