Geometry

Geometry manages how AUTD3 devices are arranged in the real world.

Device/Transducer Index

Devices are assigned an index starting from 0 in the order they are connected.

Each device has 249 transducers arranged, and they are assigned local indices (refer to “AUTD Surface Photo” in Getting Started/Hardware).

Geometry API

  • num_devices(): Get the number of enabled devices
  • num_transducers(): Get the number of all enabled transducers
  • center(): Get the center of all enabled transducers

Note that Geometry can be accessed directly from Controller.

use autd3::prelude::*;
#[allow(unused_variables)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let autd = Controller::open([AUTD3::default()], autd3::link::Nop::new())?;
let num_dev = autd.num_devices();
let num_tr = autd.num_transducers();
let center = autd.center();
Ok(())
}
#include<chrono>
#include<autd3.hpp>
#include<autd3/link/nop.hpp>
int main() {
using namespace autd3;
auto autd =
Controller::open({AUTD3{}}, link::Nop{});
const auto num_dev = autd.num_devices();
const auto num_tr = autd.num_transducers();
const auto center = autd.center();
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Link;
using AUTD3Sharp.Utils;
using var autd = Controller.Open([new AUTD3()], new Nop());
var numDevices = autd.NumDevices();
var numTransducers = autd.NumTransducers();
var center = autd.Center();
from pyautd3 import AUTD3, Controller
from pyautd3.link.nop import Nop
autd = Controller.open([AUTD3()], Nop())
num_devices = autd.num_devices()
num_transducers = autd.num_transducers()
center = autd.center()

Getting a Device

Geometry is a container of Device, and Device is a container of Transducer.

To get a Device, use an indexer. Alternatively, you can use an iterator.

use autd3::prelude::*;
#[allow(unused_variables)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let autd = Controller::open([AUTD3::default()], autd3::link::Nop::new())?;
let dev = &autd[0];
for dev in &autd {
    // do something
}
Ok(())
}
#include<chrono>
#include<autd3.hpp>
#include<autd3/link/nop.hpp>
int main() {
using namespace autd3;
auto autd =
Controller::open({AUTD3{}}, link::Nop{});
{
auto dev = autd[0];
}
{
for (auto& dev : autd) {
  // do something
}
}
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Link;
using AUTD3Sharp.Utils;
using var autd = Controller.Open([new AUTD3()], new Nop());
{
var dev = autd[0];
}
foreach (var dev in autd)
{
  // do something
}
from pyautd3 import AUTD3, Controller
from pyautd3.link.nop import Nop
autd = Controller.open([AUTD3()], Nop())
dev = autd[0]
for _dev in autd:
    pass

Device API

  • idx(): Device index
  • enable: Enable flag. When disabled, the data of the device will not be updated.
    • Note that it does not stop the output, it just stops updating the data.
  • sound_speed: Get/set the speed of sound. The unit is mm/s. It is recommended to set a value as close to reality as possible because it is used for phase calculation, etc. The default speed of sound is , which corresponds to the speed of sound in air at approximately 15 degrees Celsius.
  • set_sound_speed_from_temp(temp): Set the speed of sound from the temperature temp [℃]. Note that Geometry also has a function with the same name, and using it will set the speed of sound from the temperature for all enabled devices.
  • wavelength(): Wavelength of the ultrasound emitted by the device
  • wavenumber(): Wavenumber of the ultrasound emitted by the device
  • rotation(): Rotation of the device
  • x_direction(): X-direction vector of the device
  • y_direction(): Y-direction vector of the device
  • axial_direction(): Axial direction vector of the device (direction the transducers face)
use autd3::prelude::*;
#[allow(unused_variables)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut autd = Controller::open([AUTD3::default()], autd3::link::Nop::new())?;
let dev = &mut autd[0];
let idx = dev.idx();
dev.enable = false;
dev.sound_speed = 340e3;
dev.set_sound_speed_from_temp(15.);
let wavelength = dev.wavelength();
let wavenumber = dev.wavenumber();
let rotation = dev.rotation();
let x_dir = dev.x_direction();
let y_dir = dev.y_direction();
let axial_dir = dev.axial_direction();
Ok(())
}
#include<chrono>
#include<autd3.hpp>
#include<autd3/link/nop.hpp>
int main() {
using namespace autd3;
auto autd =
Controller::open({AUTD3{}}, link::Nop{});
auto dev = autd[0];
const auto idx = dev.idx();
const auto enable = dev.enable();
dev.set_enable(false);
const auto sound_speed = dev.sound_speed();
dev.set_sound_speed(340e3);
dev.set_sound_speed_from_temp(15.);
const auto wavelength = dev.wavelength();
const auto wavenumber = dev.wavenumber();
const auto rotation = dev.rotation();
const auto x_dir = dev.x_direction();
const auto y_dir = dev.y_direction();
const auto axial_dir = dev.axial_direction();
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Link;
using AUTD3Sharp.Utils;
using var autd = Controller.Open([new AUTD3()], new Nop());
var dev = autd[0];
var idx = dev.Idx();
dev.Enable = false;
dev.SoundSpeed = 340e3f;
dev.SetSoundSpeedFromTemp(15);
var wavelength = dev.Wavelength();
var wavenumber = dev.Wavenumber();
var rotation = dev.Rotation();
var xDir = dev.XDirection();
var yDir = dev.YDirection();
var axialDir = dev.AxialDirection();
from pyautd3 import AUTD3, Controller
from pyautd3.link.nop import Nop
autd = Controller.open([AUTD3()], Nop())
dev = autd[0]
idx = dev.idx()
dev.enable = False
dev.sound_speed = 340e3
dev.set_sound_speed_from_temp(15.0)
wavelength = dev.wavelength()
wavenumber = dev.wavenumber()
rotation = dev.rotation()
x_dir = dev.x_direction()
y_dir = dev.y_direction()
axial_dir = dev.axial_direction()

Getting a Transducer

Device is a container of Transducer, and Transducer stores information about each transducer.

To get a Transducer, use an indexer. Alternatively, you can use an iterator.

use autd3::prelude::*;
#[allow(unused_variables)] 
fn main() -> Result<(), Box<dyn std::error::Error>> {
let autd = Controller::open([AUTD3::default()], autd3::link::Nop::new())?;
let tr = &autd[0][0];
for tr in &autd[0] {
    // do something
}
Ok(())
}
#include<chrono>
#include<autd3.hpp>
#include<autd3/link/nop.hpp>
int main() {
using namespace autd3;
auto autd =
Controller::open({AUTD3{}}, link::Nop{});
{
auto tr = autd[0][0];
}
{
for (auto& tr : autd[0]) {
  // do something
}
}
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Link;
using AUTD3Sharp.Utils;
using var autd = Controller.Open([new AUTD3()], new Nop());
{
var tr = autd[0][0];
}
foreach (var tr in autd[0])
{
  // do something
}
from pyautd3 import AUTD3, Controller
from pyautd3.link.nop import Nop
autd = Controller.open([AUTD3()], Nop())
tr = autd[0][0]
for _tr in autd[0]:
    pass

Transducer API

The following information can be obtained.

  • idx(): (Local) index of the transducer
  • dev_idx(): Index of the device to which the transducer belongs
  • position(): Position of the transducer
use autd3::prelude::*;
#[allow(unused_variables)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let autd = Controller::open([AUTD3::default()], autd3::link::Nop::new())?;
let tr = &autd[0][0];
let idx = tr.idx();
let dev_idx = tr.dev_idx();
let position = tr.position();
Ok(())
}
#include<autd3.hpp>
#include<autd3/link/nop.hpp>
int main() {
using namespace autd3;
auto autd =
Controller::open({AUTD3{}}, link::Nop{});
const auto tr = autd[0][0];
const auto idx = tr.idx();
const auto dev_idx = tr.dev_idx();
const auto position = tr.position();
return 0; }
using AUTD3Sharp;
using AUTD3Sharp.Link;
using AUTD3Sharp.Utils;
using var autd = Controller.Open([new AUTD3()], new Nop());
var tr = autd[0][0];
var trIdx = tr.Idx();
var devIdx = tr.DevIdx();
var position = tr.Position();
from pyautd3 import AUTD3, Controller
from pyautd3.link.nop import Nop
autd = Controller.open([AUTD3()], Nop())
tr = autd[0][0]
idx = tr.idx()
dev_idx = tr.dev_idx()
position = tr.position()