FociSTM
- The maximum number of sampling points is .
- The sampling frequency is .
THe following is an example of using FociSTM
to focus on a point directly above the center of the array with a radius of centered on 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 = FociSTM::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);
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::FociSTM 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);
autd3::Point3 p =
center + radius * autd3::Vector3(std::cos(theta),
std::sin(theta), 0);
return p;
}));
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Utils;
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 FociSTM(1.0f * Hz, Enumerable.Range(0, pointNum).Select(i =>
{
var theta = 2.0f * MathF.PI * i / pointNum;
return center + radius * new Vector3(MathF.Cos(theta), MathF.Sin(theta), 0);
}));
import numpy as np
from pyautd3 import AUTD3, Controller, FociSTM, 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 = FociSTM(
1.0 * Hz,
(
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))
),
)
FociSTM
's constructor takes the STM frequency as an argument.
Note that the specified frequency and the actual frequency may differ due to constraints on the number of sampling points and the sampling period.
For example, the above example runs 200 points at , so the sampling frequency should be .
However, if point_num=199
, the sampling frequency must be , but there is no integer that satisfies .
Therefore, the closest is selected.
As a result, the specified frequency and the actual frequency are shifted.
frequency
can be used to check the actual frequency.
Specify the sampling configuration
You can specify the sampling frequency by from_sampling_config
instead of frequency.
use autd3::prelude::*;
#[allow(unused_variables)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let stm = FociSTM::new(SamplingConfig::new(1 * Hz)?, [Point3::origin(), Point3::origin()]);
Ok(())
}
#include<autd3.hpp>
#include<autd3/link/nop.hpp>
int main() {
auto autd =
autd3::ControllerBuilder({autd3::AUTD3(autd3::Point3::origin())}).open(autd3::link::Nop::builder());
std::vector<std::array<autd3::Point3, 1>> foci = {
std::array{autd3::Point3(0, 0, 0)},
std::array{autd3::Point3(0, 0, 0)},
};
autd3::FociSTM stm(autd3::SamplingConfig(1 * autd3::Hz), foci);
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Utils;
using AUTD3Sharp.Link;
using static AUTD3Sharp.Units;
using var autd = Controller.Builder([new AUTD3(Point3.Origin)]).Open(Nop.Builder());
var stm = new FociSTM((SamplingConfig)(1u * Hz), [Point3.Origin, Point3.Origin]);
from pyautd3 import Hz, FociSTM, SamplingConfig
import numpy as np
foci = [np.array([0.0, 0.0, 0.0]), np.array([0.0, 0.0, 0.0])]
stm = FociSTM(SamplingConfig(1 * Hz), foci)