GainSTM

GainSTM can handle arbitrary Gains, unlike FociSTM. However, the number of Gains that can be used is 1024.

The following is an example of how to use GainSTM. This is a sample that rotates the focus on a circle with a radius of centered on a point directly above the center of the array.

use autd3::prelude::*;
#[allow(unused_variables)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let autd = Controller::builder([AUTD3::new(Point3::origin())]).open(autd3::link::Nop::builder())?;
let center = autd.center() + Vector3::new(0., 0., 150.0 * mm);
let point_num = 200;
let radius = 30.0 * mm;
let stm = GainSTM::new(
    1.0 * Hz,
    (0..point_num).map(|i| {
        let theta = 2.0 * PI * i as f32 / point_num as f32;
        let p = radius * Vector3::new(theta.cos(), theta.sin(), 0.0);
        Focus::new(center + p)
    }),
)?;
Ok(())
}
#include <ranges>
#include<autd3.hpp>
#include<autd3/link/nop.hpp>
using namespace std::ranges::views;
int main() {
auto autd =
autd3::ControllerBuilder({autd3::AUTD3(autd3::Point3::origin())}).open(autd3::link::Nop::builder());
const autd3::Point3 center = autd.center() + autd3::Vector3(0, 0, 150);
const auto points_num = 200;
const auto radius = 30.0f;
autd3::GainSTM stm(1.0f * autd3::Hz,
                   iota(0) | take(points_num) | transform([&](auto i) {
                     const auto theta = 2.0f * autd3::pi *
                                        static_cast<float>(i) /
                                        static_cast<float>(points_num);
                     return autd3::gain::Focus(
                         center + radius * autd3::Vector3(std::cos(theta),
                                                          std::sin(theta), 0));
                   }));
return 0; }

using AUTD3Sharp;
using AUTD3Sharp.Utils;
using AUTD3Sharp.Gain;
using AUTD3Sharp.Link;
using static AUTD3Sharp.Units;
using var autd = Controller.Builder([new AUTD3(Point3.Origin)]).Open(Nop.Builder());
var center = autd.Center + new Vector3(0, 0, 150);
const int pointNum = 200;
const float radius = 30.0f;
var stm = new GainSTM(1.0f * Hz, Enumerable.Range(0, pointNum).Select(i =>
{
    var theta = 2.0f * MathF.PI * i / pointNum;
    return new Focus(center + radius * new Vector3(MathF.Cos(theta), MathF.Sin(theta), 0));
}));
import numpy as np
from pyautd3 import AUTD3, Controller, Focus, GainSTM, Hz
from pyautd3.link.audit import Audit

autd = Controller.builder([AUTD3([0.0, 0.0, 0.0])]).open(Audit.builder())
center = autd.center + np.array([0.0, 0.0, 150.0])
point_num = 200
radius = 30.0
stm = GainSTM(
    1.0 * Hz,
    (
        Focus(center + radius * np.array([np.cos(theta), np.sin(theta), 0]))
        for theta in (2.0 * np.pi * i / point_num for i in range(point_num))
    ),
)

Specify the sampling configuration

You can also specify the sampling frequency instead of frequency.

use autd3::prelude::*;
#[allow(unused_variables)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let stm = GainSTM::new(SamplingConfig::new(1 * Hz)?, [Null::new(), Null::new()]);
Ok(())
}
#include<autd3.hpp>
#include<autd3/link/nop.hpp>
int main() {
autd3::GainSTM stm(autd3::SamplingConfig(1 * autd3::Hz),
                   {autd3::gain::Null(), autd3::gain::Null()});
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Utils;
using AUTD3Sharp.Link;
using AUTD3Sharp.Gain;
using static AUTD3Sharp.Units;
using var autd = Controller.Builder([new AUTD3(Point3.Origin)]).Open(Nop.Builder());
var stm = new GainSTM((SamplingConfig)(1u * Hz), [new Null(), new Null()]);
from pyautd3 import Hz, GainSTM, Null, SamplingConfig
stm = GainSTM(SamplingConfig(1 * Hz), [Null(), Null()])

GainSTMMode

GainSTM sends all phase/amplitude data, so it has a large latency1. To solve this problem, GainSTM has PhaseFull mode that sends only phase and reduces the transmission time by half2.

This mode can be switched with with_mode.

use autd3::prelude::*;
#[allow(unused_variables)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let stm = GainSTM::new(1.0 * Hz, [Null::new(), Null::new()])?
    .with_mode(GainSTMMode::PhaseFull);
Ok(())
}
#include<autd3.hpp>
#include<autd3/link/nop.hpp>
int main() {
auto stm =
    autd3::GainSTM(1.0f * autd3::Hz, {autd3::gain::Null(), autd3::gain::Null()})
        .with_mode(autd3::GainSTMMode::PhaseFull);
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Utils;
using AUTD3Sharp.Link;
using AUTD3Sharp.Gain;
using static AUTD3Sharp.Units;
using var autd = Controller.Builder([new AUTD3(Point3.Origin)]).Open(Nop.Builder());
var stm = new GainSTM(1.0f * Hz, [new Null(), new Null()]).WithMode(GainSTMMode.PhaseFull);
from pyautd3 import Hz, GainSTM, GainSTMMode, Null
stm = GainSTM(1.0 * Hz, [Null(), Null()]).with_mode(GainSTMMode.PhaseFull)

The default is PhaseIntensityFull mode, which sends all information.

1

About 75 times of FociSTM<1>

2

Legacy mode only