Beispiel #1
0
        public static void Test(AUTD autd)
        {
            const double x = AUTD.TransSpacing * (AUTD.NumTransInX - 1) / 2.0;
            const double y = AUTD.TransSpacing * (AUTD.NumTransInY - 1) / 2.0;
            const double z = 150.0;

            var mod = Modulation.Sine(150);

            var center  = new Vector3d(x, y, z);
            var focuses = new[] {
                center + 20.0 * Vector3d.UnitX,
                center - 20.0 * Vector3d.UnitX
            };
            var amps = new[] {
                1.0,
                1.0
            };

            var backend = Gain.Eigen3Backend();
            var gain    = Gain.HoloSDP(focuses, amps, backend);

            autd.Send(gain, mod);

            Gain.DeleteBackend(backend);
        }
Beispiel #2
0
        public static void Test(AUTD autd)
        {
            autd.SilentMode = false;

            var delays = new byte[autd.NumDevices, AUTD.NumTransInDevice];

            delays[0, 0] = 4;
            autd.SetDelayOffset(delays, null);

            var uniform = new ushort[autd.NumDevices, AUTD.NumTransInDevice];

            for (var i = 0; i < autd.NumDevices; i++)
            {
                for (var j = 0; j < AUTD.NumTransInDevice; j++)
                {
                    uniform[i, j] = 0xFFFF;
                }
            }

            var burst = new byte[4000];

            burst[0] = 0xFF;

            var g = Gain.Custom(uniform);
            var m = Modulation.Custom(burst);

            autd.Send(g, m);
        }
Beispiel #3
0
        public static void Test(AUTD autd)
        {
            const double x = AUTD.DeviceWidth / 2;
            const double y = AUTD.DeviceHeight / 2;
            const double z = 150;

            var center = new Vector3d(x, y, z);

            var g1 = Gain.FocalPoint(center);

            var focuses = new[] {
                center + 30.0 * Vector3d.UnitX,
                center - 30.0 * Vector3d.UnitX
            };
            var amps = new[] {
                1.0,
                1.0
            };
            var backend = Gain.Eigen3Backend();
            var g2      = Gain.HoloGSPAT(focuses, amps, backend);

            var gainMap = new Dictionary <int, Gain>
            {
                [0] = g1,
                [1] = g2
            };
            var gain = Gain.Grouped(autd, gainMap);
            var mod  = Modulation.Sine(150); // AM sin 150 Hz

            autd.Send(gain, mod);

            Gain.DeleteBackend(backend);
        }
Beispiel #4
0
        public static void Test(AUTD autd)
        {
            const double x = AUTD.DeviceWidth / 2;
            const double y = AUTD.DeviceHeight / 2;
            const double z = 150.0;

            autd.SilentMode = false;

            var mod = Modulation.Static();

            autd.Send(mod);

            const double radius = 30.0;
            const int    size   = 100;
            var          center = new Vector3d(x, y, z);
            var          stm    = autd.STM();

            for (var i = 0; i < size; i++)
            {
                var theta = 2 * AUTD.Pi * i / size;
                var r     = new Vector3d(Math.Cos(theta), Math.Sin(theta), 0);
                var f     = Gain.FocalPoint(center + radius * r);
                stm.AddSTMGain(f);
            }
            stm.StartSTM(0.5);

            Console.WriteLine("press any key to stop...");
            Console.ReadKey(true);

            stm.StopSTM();
            stm.FinishSTM();
        }
Beispiel #5
0
        public static void Test(AUTD autd)
        {
            const double x = AUTD.DeviceWidth / 2;
            const double y = AUTD.DeviceHeight / 2;
            const double z = 150;

            autd.SilentMode = false;

            var mod = Modulation.Static();

            autd.Send(mod);

            var       center   = new Vector3d(x, y, z);
            var       seq      = PointSequence.Create();
            const int pointNum = 200;

            for (var i = 0; i < pointNum; i++)
            {
                const double radius = 30.0;
                var          theta  = 2.0 * Math.PI * i / pointNum;
                var          p      = radius * new Vector3d(Math.Cos(theta), Math.Sin(theta), 0);
                seq.AddPoint(center + p);
            }
            seq.Frequency = 1;
            Console.WriteLine($"Actual frequency is {seq.Frequency}");
            autd.Send(seq, mod);
        }
Beispiel #6
0
        public static void Run(AUTD autd)
        {
            var examples = new List <(TestFn, string)> {
                (SimpleTest.Test, "Single Focal Point Test"),
                (BesselBeamTest.Test, "BesselBeam Test"),
                (HoloGainTest.Test, "Multiple Focal Points Test"),
                (STMTest.Test, "Spatio-Temporal Modulation Test"),
                (SeqTest.Test, "PointSequence Test (Hardware STM)"),
                (SeqGainTest.Test, "GainSequence Test (Hardware STM with arbitrary Gain)"),
                (AdvancedTest.Test, "Advanced Test (Custom gain/modulation, and output delay)"),
                (CustomTest.Test, "Custom Test (Custom Focus)")
            };

            if (autd.NumDevices == 2)
            {
                examples.Add((GroupTest.Test, "Grouped gain Test"));
            }

            autd.Clear();

            var firmList = autd.FirmwareInfoList().ToArray();

            if (!firmList.Any())
            {
                Console.WriteLine("Failed to read firmware information of some devices. You probably use firmware v1.8 or earlier.");
            }
            foreach (var(firm, index) in firmList.Select((firm, i) => (firm, i)))
            {
                Console.WriteLine($"AUTD {index}: {firm}");
            }

            while (true)
            {
                for (var i = 0; i < examples.Count; i++)
                {
                    Console.WriteLine($"[{i}]: {examples[i].Item2}");
                }

                Console.WriteLine("[Others]: finish");
                Console.Write("Choose number: ");

                if (!int.TryParse(Console.ReadLine(), out var idx) || idx >= examples.Count)
                {
                    break;
                }

                var fn = examples[idx].Item1;
                fn(autd);

                Console.WriteLine("press any key to finish...");
                Console.ReadKey(true);

                Console.WriteLine("finish.");
                autd.Stop();
            }

            autd.Clear();
            autd.Close();
            autd.Dispose();
        }
        private void UpdateInterfacesList()
        {
            Interfaces.Clear();
            var adapters = AUTD.EnumerateAdapters();

            foreach (var adapter in adapters)
            {
                Interfaces.Add($"{adapter}");
            }
        }
Beispiel #8
0
 void Update()
 {
     if (Target != null)
     {
         var g1 = AUTD.FocalPointGain(Target.transform.position + Vector3.right * 0.001f * 7);
         var g2 = AUTD.FocalPointGain(Target.transform.position - Vector3.right * 0.001f * 7);
         _autd.AppendLateralGain(g1, g2);
         _autd.StartLateralModulation(50);
     }
 }
Beispiel #9
0
        public static void Test(AUTD autd)
        {
            const double x = AUTD.DeviceWidth / 2;
            const double y = AUTD.DeviceHeight / 2;
            const double z = 150;

            var mod  = Modulation.Sine(150);
            var gain = Focus(autd, new Vector3d(x, y, z));

            autd.Send(gain, mod);
        }
Beispiel #10
0
        public static void Test(AUTD autd)
        {
            const double x = AUTD.DeviceWidth / 2;
            const double y = AUTD.DeviceHeight / 2;
            const double z = 150;

            var mod  = Modulation.Sine(150);                   // AM sin 150 Hz
            var gain = Gain.FocalPoint(new Vector3d(x, y, z)); // Focal point @ (x, y, z) [mm]

            autd.Send(gain, mod);
        }
Beispiel #11
0
    void Awake()
    {
        _autd = new AUTD();

        // 単位や座標系はUnity空間に合わせてあります
        // つまり, 単位はm, 座標系は"z"軸の反転した左手座標系です
        // また, 回転指定にクオータニオンを直接指定できます.
        _autd.AddDevice(gameObject.transform.position, gameObject.transform.rotation);

        _autd.Open();
        _autd.AppendModulationSync(AUTD.SineModulation(150)); // 150 Hz
    }
Beispiel #12
0
        public static void Test(AUTD autd)
        {
            const double x = AUTD.DeviceWidth / 2;
            const double y = AUTD.DeviceHeight / 2;

            var mod = Modulation.Sine(150); // AM sin 150 Hz

            var start = new Vector3d(x, y, 0);
            var dir   = Vector3d.UnitZ;
            var gain  = Gain.BesselBeam(start, dir, 13.0f / 180f * AUTD.Pi); // BesselBeam from (x, y, 0), theta = 13 deg

            autd.Send(gain, mod);
        }
Beispiel #13
0
    void Awake()
    {
        _autd = new AUTD();

        _autd.AddDevice(gameObject.transform.position, gameObject.transform.rotation);

        string ifname = @"write your interface name here";

        _link = Link.SOEM(ifname, _autd.NumDevices);
        _autd.Open(_link);

        _autd.Clear();

        _autd.Send(Modulation.Sine(150)); // 150 Hz
    }
Beispiel #14
0
        public static string GetIfname()
        {
            IEnumerable <EtherCATAdapter> adapters = AUTD.EnumerateAdapters();

            foreach ((EtherCATAdapter adapter, int index) in adapters.Select((adapter, index) => (adapter, index)))
            {
                Console.WriteLine($"[{index}]: {adapter}");
            }

            Console.Write("Choose number: ");
            int i;

            while (!int.TryParse(Console.ReadLine(), out i))
            {
            }
            return(adapters.ElementAt(i).Name);
        }
Beispiel #15
0
        public static string GetIfname()
        {
            var adapters         = AUTD.EnumerateAdapters();
            var etherCATAdapters = adapters as EtherCATAdapter[] ?? adapters.ToArray();

            foreach (var(adapter, index) in etherCATAdapters.Select((adapter, index) => (adapter, index)))
            {
                Console.WriteLine($"[{index}]: {adapter}");
            }

            Console.Write("Choose number: ");
            int i;

            while (!int.TryParse(Console.ReadLine(), out i))
            {
            }
            return(etherCATAdapters.ElementAt(i).Name);
        }
Beispiel #16
0
        public static void Test()
        {
            Console.WriteLine("Test with TwinCAT");

            var autd = new AUTD();

            autd.AddDevice(Vector3d.Zero, Vector3d.Zero);

            var link = Link.TwinCAT();

            if (!autd.Open(link))
            {
                Console.WriteLine(AUTD.LastError);
                return;
            }

            TestRunner.Run(autd);
        }
Beispiel #17
0
        private static Gain Focus(AUTD autd, Vector3d point)
        {
            var devNum = autd.NumDevices;

            var data = new ushort[devNum, AUTD.NumTransInDevice];

            var waveNumber = 2.0 * Math.PI / autd.Wavelength;

            for (var dev = 0; dev < devNum; dev++)
            {
                for (var i = 0; i < AUTD.NumTransInDevice; i++)
                {
                    var          tp    = autd.TransPosition(dev, i);
                    var          dist  = (tp - point).L2Norm;
                    var          phase = ToPhase(waveNumber * dist);
                    const ushort duty  = 0xFF;
                    data[dev, i] = (ushort)((duty << 8) | phase);
                }
            }

            return(Gain.Custom(data));
        }
Beispiel #18
0
        public static void Test()
        {
            Console.WriteLine("Test with SOEM");

            var autd = new AUTD();

            autd.AddDevice(Vector3d.Zero, Vector3d.Zero);
            //autd.AddDevice(Vector3d.Zero, Vector3d.Zero, 1);

            var ifname = GetIfname();
            var link   = Link.SOEM(ifname, autd.NumDevices, 1, x =>
            {
                Console.WriteLine($"Unrecoverable error occurred: {x}");
                Environment.Exit(-1);
            });

            if (!autd.Open(link))
            {
                Console.WriteLine(AUTD.LastError);
                return;
            }

            TestRunner.Run(autd);
        }
Beispiel #19
0
 public void TransTest(int idx, byte duty, byte phase)
 {
     _autd.AppendGainSync(AUTD.TransducerTestGain(idx, duty, phase));
 }
Beispiel #20
0
 private void OnEnable()
 {
     _adapters = AUTD.EnumerateAdapters().ToArray();
 }
 private AUTDHandler()
 {
     _autd     = new AUTD();
     IsOpen    = new ReactivePropertySlim <bool>();
     IsRunning = new ReactivePropertySlim <bool>();
 }
Beispiel #22
0
 public AUTD3Cnt()
 {
     _autd = new AUTD();
 }
Beispiel #23
0
        public void Open(string ifname)
        {
            var link = AUTD.SOEMLink(ifname, _autd.NumDevices);

            _autd.OpenWith(link);
        }
Beispiel #24
0
 public void StaticMod(byte duty = 0xff)
 {
     _autd.AppendModulationSync(AUTD.Modulation(duty));
 }
Beispiel #25
0
 public void Focus(float x, float y, float z, byte duty = 0xff)
 {
     _autd.AppendGainSync(AUTD.FocalPointGain(new Vector3f(x, y, z), duty));
 }