com.shinolab.autd3-sdk 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTD3.asmdef +18 -0
- package/AUTD3.asmdef.meta +7 -0
- package/AsyncOps.cs +45 -0
- package/AsyncOps.cs.meta +11 -0
- package/Client.cs +357 -0
- package/Client.cs.meta +11 -0
- package/Commands.cs +368 -0
- package/Commands.cs.meta +11 -0
- package/Datagram.cs +214 -0
- package/Datagram.cs.meta +11 -0
- package/GlobalUsings.cs +7 -0
- package/GlobalUsings.cs.meta +11 -0
- package/LICENSE.md +21 -0
- package/LICENSE.md.meta +7 -0
- package/Link.cs +12 -0
- package/Link.cs.meta +11 -0
- package/Native.cs +136 -0
- package/Native.cs.meta +11 -0
- package/Plugins/linux-x64/libautd3capi.so +0 -0
- package/Plugins/linux-x64/libautd3capi.so.meta +35 -0
- package/Plugins/linux-x64.meta +8 -0
- package/Plugins/osx-arm64/libautd3capi.dylib +0 -0
- package/Plugins/osx-arm64/libautd3capi.dylib.meta +35 -0
- package/Plugins/osx-arm64.meta +8 -0
- package/Plugins/win-x64/autd3capi.dll +0 -0
- package/Plugins/win-x64/autd3capi.dll.meta +35 -0
- package/Plugins/win-x64.meta +8 -0
- package/Plugins.meta +8 -0
- package/README.md +43 -0
- package/README.md.meta +7 -0
- package/Samples~/FocusSine/AUTD3.Samples.FocusSine.asmdef +20 -0
- package/Samples~/FocusSine/FocusSineSample.cs +59 -0
- package/Stm.cs +362 -0
- package/Stm.cs.meta +11 -0
- package/THIRD-PARTY-LICENSES.md +1083 -0
- package/THIRD-PARTY-LICENSES.md.meta +7 -0
- package/csc.rsp +2 -0
- package/csc.rsp.meta +7 -0
- package/package.json +24 -0
- package/package.json.meta +7 -0
package/Native.cs
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Runtime.InteropServices;
|
|
3
|
+
|
|
4
|
+
namespace AUTD3
|
|
5
|
+
{
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
9
|
+
internal delegate void CompletionCallback(int code, IntPtr value, IntPtr msg, IntPtr userData);
|
|
10
|
+
|
|
11
|
+
internal static class NativeClient
|
|
12
|
+
{
|
|
13
|
+
private const string Lib = "autd3capi";
|
|
14
|
+
|
|
15
|
+
[DllImport(Lib)]
|
|
16
|
+
internal static extern IntPtr autd3_client_config_new(
|
|
17
|
+
[MarshalAs(UnmanagedType.I1)] bool lowLatency,
|
|
18
|
+
uint timeoutCycles,
|
|
19
|
+
UIntPtr maxInflight,
|
|
20
|
+
uint sendIntervalCycles,
|
|
21
|
+
uint maxResyncRounds,
|
|
22
|
+
uint resetResendCycles,
|
|
23
|
+
[MarshalAs(UnmanagedType.I1)] bool hasRtPriority,
|
|
24
|
+
byte rtPriority,
|
|
25
|
+
[MarshalAs(UnmanagedType.I1)] bool hasRtAffinity,
|
|
26
|
+
UIntPtr rtAffinity,
|
|
27
|
+
[MarshalAs(UnmanagedType.I1)] bool validateState);
|
|
28
|
+
|
|
29
|
+
[DllImport(Lib)]
|
|
30
|
+
internal static extern void autd3_client_config_free(IntPtr config);
|
|
31
|
+
|
|
32
|
+
[DllImport(Lib)]
|
|
33
|
+
internal static extern IntPtr autd3_datagram_builder_new(UIntPtr numDevices);
|
|
34
|
+
|
|
35
|
+
[DllImport(Lib)]
|
|
36
|
+
internal static extern void autd3_datagram_builder_push(IntPtr builder, IntPtr op);
|
|
37
|
+
|
|
38
|
+
[DllImport(Lib)]
|
|
39
|
+
internal static extern void autd3_datagram_builder_push_each(IntPtr builder, IntPtr[] ops, UIntPtr numDevices);
|
|
40
|
+
|
|
41
|
+
[DllImport(Lib)]
|
|
42
|
+
internal static extern void autd3_op_free(IntPtr op);
|
|
43
|
+
|
|
44
|
+
[DllImport(Lib)]
|
|
45
|
+
internal static extern void autd3_datagram_builder_free(IntPtr builder);
|
|
46
|
+
|
|
47
|
+
[DllImport(Lib)]
|
|
48
|
+
internal static extern IntPtr autd3_datagram_builder_build(IntPtr builder, byte[] outErr, UIntPtr outErrLen);
|
|
49
|
+
|
|
50
|
+
[DllImport(Lib)]
|
|
51
|
+
internal static extern UIntPtr autd3_datagrams_num_frames(IntPtr datagrams);
|
|
52
|
+
|
|
53
|
+
[DllImport(Lib)]
|
|
54
|
+
internal static extern void autd3_datagrams_free(IntPtr datagrams);
|
|
55
|
+
|
|
56
|
+
[DllImport(Lib)]
|
|
57
|
+
internal static extern void autd3_client_open(IntPtr geometry, IntPtr link, IntPtr config, CompletionCallback cb, IntPtr userData);
|
|
58
|
+
|
|
59
|
+
[DllImport(Lib)]
|
|
60
|
+
internal static extern UIntPtr autd3_client_num_devices(IntPtr client);
|
|
61
|
+
|
|
62
|
+
[DllImport(Lib)]
|
|
63
|
+
internal static extern void autd3_client_send_checked(IntPtr client, IntPtr datagrams, long frame, CompletionCallback cb, IntPtr userData);
|
|
64
|
+
|
|
65
|
+
[DllImport(Lib)]
|
|
66
|
+
internal static extern void autd3_client_send(IntPtr client, IntPtr datagrams, long frame, CompletionCallback cb, IntPtr userData);
|
|
67
|
+
|
|
68
|
+
[DllImport(Lib)]
|
|
69
|
+
internal static extern void autd3_response_token_await(IntPtr token, CompletionCallback cb, IntPtr userData);
|
|
70
|
+
|
|
71
|
+
[DllImport(Lib)]
|
|
72
|
+
internal static extern void autd3_response_token_free(IntPtr token);
|
|
73
|
+
|
|
74
|
+
[DllImport(Lib)]
|
|
75
|
+
[return: MarshalAs(UnmanagedType.I1)]
|
|
76
|
+
internal static extern bool autd3_response_check(byte[] data, UIntPtr len, byte[] outErr, UIntPtr outErrLen);
|
|
77
|
+
|
|
78
|
+
[DllImport(Lib)]
|
|
79
|
+
internal static extern void autd3_client_stop(IntPtr client, CompletionCallback cb, IntPtr userData);
|
|
80
|
+
|
|
81
|
+
[DllImport(Lib)]
|
|
82
|
+
internal static extern void autd3_client_close(IntPtr client, CompletionCallback cb, IntPtr userData);
|
|
83
|
+
|
|
84
|
+
[DllImport(Lib)]
|
|
85
|
+
internal static extern void autd3_client_free(IntPtr client);
|
|
86
|
+
|
|
87
|
+
[DllImport(Lib)]
|
|
88
|
+
internal static extern void autd3_client_read_firmware_version(IntPtr client, CompletionCallback cb, IntPtr userData);
|
|
89
|
+
|
|
90
|
+
[DllImport(Lib)]
|
|
91
|
+
internal static extern void autd3_client_read_fpga_state(IntPtr client, CompletionCallback cb, IntPtr userData);
|
|
92
|
+
|
|
93
|
+
[DllImport(Lib)]
|
|
94
|
+
internal static extern void autd3_client_read_error_detail(IntPtr client, CompletionCallback cb, IntPtr userData);
|
|
95
|
+
|
|
96
|
+
[DllImport(Lib)]
|
|
97
|
+
internal static extern UIntPtr autd3_byte_array_len(IntPtr array);
|
|
98
|
+
|
|
99
|
+
[DllImport(Lib)]
|
|
100
|
+
internal static extern IntPtr autd3_byte_array_data(IntPtr array);
|
|
101
|
+
|
|
102
|
+
[DllImport(Lib)]
|
|
103
|
+
internal static extern void autd3_byte_array_free(IntPtr array);
|
|
104
|
+
|
|
105
|
+
[DllImport(Lib)]
|
|
106
|
+
internal static extern UIntPtr autd3_string_array_len(IntPtr array);
|
|
107
|
+
|
|
108
|
+
[DllImport(Lib)]
|
|
109
|
+
internal static extern IntPtr autd3_string_array_get(IntPtr array, UIntPtr index);
|
|
110
|
+
|
|
111
|
+
[DllImport(Lib)]
|
|
112
|
+
internal static extern void autd3_string_array_free(IntPtr array);
|
|
113
|
+
|
|
114
|
+
[DllImport(Lib)]
|
|
115
|
+
internal static extern IntPtr autd3_client_checker(IntPtr client);
|
|
116
|
+
|
|
117
|
+
[DllImport(Lib)]
|
|
118
|
+
internal static extern void autd3_checker_check(IntPtr checker, CompletionCallback cb, IntPtr userData);
|
|
119
|
+
|
|
120
|
+
[DllImport(Lib)]
|
|
121
|
+
internal static extern void autd3_checker_free(IntPtr checker);
|
|
122
|
+
|
|
123
|
+
[DllImport(Lib)]
|
|
124
|
+
internal static extern ulong autd3_link_status_recoveries(IntPtr status);
|
|
125
|
+
|
|
126
|
+
[DllImport(Lib)]
|
|
127
|
+
internal static extern UIntPtr autd3_link_status_num_devices(IntPtr status);
|
|
128
|
+
|
|
129
|
+
[DllImport(Lib)]
|
|
130
|
+
[return: MarshalAs(UnmanagedType.I1)]
|
|
131
|
+
internal static extern bool autd3_link_status_device_state(IntPtr status, UIntPtr index, out byte outKind, out byte outBits);
|
|
132
|
+
|
|
133
|
+
[DllImport(Lib)]
|
|
134
|
+
internal static extern void autd3_link_status_free(IntPtr status);
|
|
135
|
+
}
|
|
136
|
+
}
|
package/Native.cs.meta
ADDED
|
Binary file
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 65c0e05b76501ab1aa8dc8b0d996f388
|
|
3
|
+
PluginImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
iconMap: {}
|
|
7
|
+
executionOrder: {}
|
|
8
|
+
defineConstraints: []
|
|
9
|
+
isPreloaded: 0
|
|
10
|
+
isOverridable: 0
|
|
11
|
+
isExplicitlyReferenced: 0
|
|
12
|
+
validateReferences: 1
|
|
13
|
+
platformData:
|
|
14
|
+
- first:
|
|
15
|
+
Any:
|
|
16
|
+
second:
|
|
17
|
+
enabled: 0
|
|
18
|
+
settings: {}
|
|
19
|
+
- first:
|
|
20
|
+
Editor: Editor
|
|
21
|
+
second:
|
|
22
|
+
enabled: 1
|
|
23
|
+
settings:
|
|
24
|
+
CPU: x86_64
|
|
25
|
+
DefaultValueInitialized: true
|
|
26
|
+
OS: Linux
|
|
27
|
+
- first:
|
|
28
|
+
Standalone: Linux64
|
|
29
|
+
second:
|
|
30
|
+
enabled: 1
|
|
31
|
+
settings:
|
|
32
|
+
CPU: x86_64
|
|
33
|
+
userData:
|
|
34
|
+
assetBundleName:
|
|
35
|
+
assetBundleVariant:
|
|
Binary file
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 69e09155f3103c1ddb20d2582ede5c0e
|
|
3
|
+
PluginImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
iconMap: {}
|
|
7
|
+
executionOrder: {}
|
|
8
|
+
defineConstraints: []
|
|
9
|
+
isPreloaded: 0
|
|
10
|
+
isOverridable: 0
|
|
11
|
+
isExplicitlyReferenced: 0
|
|
12
|
+
validateReferences: 1
|
|
13
|
+
platformData:
|
|
14
|
+
- first:
|
|
15
|
+
Any:
|
|
16
|
+
second:
|
|
17
|
+
enabled: 0
|
|
18
|
+
settings: {}
|
|
19
|
+
- first:
|
|
20
|
+
Editor: Editor
|
|
21
|
+
second:
|
|
22
|
+
enabled: 1
|
|
23
|
+
settings:
|
|
24
|
+
CPU: ARM64
|
|
25
|
+
DefaultValueInitialized: true
|
|
26
|
+
OS: OSX
|
|
27
|
+
- first:
|
|
28
|
+
Standalone: OSXUniversal
|
|
29
|
+
second:
|
|
30
|
+
enabled: 1
|
|
31
|
+
settings:
|
|
32
|
+
CPU: ARM64
|
|
33
|
+
userData:
|
|
34
|
+
assetBundleName:
|
|
35
|
+
assetBundleVariant:
|
|
Binary file
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: b8ffcc717c0513e85f16b07c79ce5541
|
|
3
|
+
PluginImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
iconMap: {}
|
|
7
|
+
executionOrder: {}
|
|
8
|
+
defineConstraints: []
|
|
9
|
+
isPreloaded: 0
|
|
10
|
+
isOverridable: 0
|
|
11
|
+
isExplicitlyReferenced: 0
|
|
12
|
+
validateReferences: 1
|
|
13
|
+
platformData:
|
|
14
|
+
- first:
|
|
15
|
+
Any:
|
|
16
|
+
second:
|
|
17
|
+
enabled: 0
|
|
18
|
+
settings: {}
|
|
19
|
+
- first:
|
|
20
|
+
Editor: Editor
|
|
21
|
+
second:
|
|
22
|
+
enabled: 1
|
|
23
|
+
settings:
|
|
24
|
+
CPU: x86_64
|
|
25
|
+
DefaultValueInitialized: true
|
|
26
|
+
OS: Windows
|
|
27
|
+
- first:
|
|
28
|
+
Standalone: Win64
|
|
29
|
+
second:
|
|
30
|
+
enabled: 1
|
|
31
|
+
settings:
|
|
32
|
+
CPU: x86_64
|
|
33
|
+
userData:
|
|
34
|
+
assetBundleName:
|
|
35
|
+
assetBundleVariant:
|
package/Plugins.meta
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# AUTD3 (Unity)
|
|
2
|
+
|
|
3
|
+
The AUTD3 client: opening a link, sending datagrams and driving STM.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Add the scoped registry and the package to `Packages/manifest.json`; sibling
|
|
8
|
+
AUTD3 packages are resolved from the registry automatically.
|
|
9
|
+
|
|
10
|
+
```json
|
|
11
|
+
{
|
|
12
|
+
"scopedRegistries": [
|
|
13
|
+
{ "name": "npmjs", "url": "https://registry.npmjs.org", "scopes": ["com.shinolab"] }
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"com.shinolab.autd3-sdk": "0.1.0"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Packages served from `registry.npmjs.org` do **not** appear in the Package Manager's
|
|
22
|
+
*My Registries* tab, because npmjs does not implement the legacy `/-/all` route that
|
|
23
|
+
Unity's package listing relies on. Resolution is unaffected: edit the manifest as above,
|
|
24
|
+
or use **+ → Add package by name**.
|
|
25
|
+
|
|
26
|
+
The bundled `Focus Sine` sample additionally needs `com.shinolab.autd3-sdk.link.nop`.
|
|
27
|
+
|
|
28
|
+
## Platforms
|
|
29
|
+
|
|
30
|
+
Editor and Standalone builds on Windows (`win-x64`), Linux (`linux-x64`) and Apple
|
|
31
|
+
Silicon macOS (`osx-arm64`). Intel macOS is not shipped.
|
|
32
|
+
|
|
33
|
+
## Notes
|
|
34
|
+
|
|
35
|
+
Minimum Unity version is 6 (6000.x). The API speaks Unity's left-handed, metre frame;
|
|
36
|
+
conversion to the AUTD3 canonical frame happens at the binding boundary.
|
|
37
|
+
|
|
38
|
+
See the [Unity binding README](https://github.com/shinolab/autd3-sdk/blob/main/bindings/unity/README.md) for the
|
|
39
|
+
coordinate system, the full package list and local development with `file:` references.
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT. See `LICENSE.md`. Third-party notices are in `THIRD-PARTY-LICENSES.md`.
|
package/README.md.meta
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "AUTD3.Samples.FocusSine",
|
|
3
|
+
"rootNamespace": "AUTD3.Samples",
|
|
4
|
+
"references": [
|
|
5
|
+
"AUTD3",
|
|
6
|
+
"AUTD3.Core",
|
|
7
|
+
"AUTD3.Pattern",
|
|
8
|
+
"AUTD3.Modulation",
|
|
9
|
+
"AUTD3.Link.Nop"
|
|
10
|
+
],
|
|
11
|
+
"includePlatforms": [],
|
|
12
|
+
"excludePlatforms": [],
|
|
13
|
+
"allowUnsafeCode": false,
|
|
14
|
+
"overrideReferences": false,
|
|
15
|
+
"precompiledReferences": [],
|
|
16
|
+
"autoReferenced": true,
|
|
17
|
+
"defineConstraints": [],
|
|
18
|
+
"versionDefines": [],
|
|
19
|
+
"noEngineReferences": false
|
|
20
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using AUTD3;
|
|
4
|
+
using AUTD3.Link;
|
|
5
|
+
using static AUTD3.Units;
|
|
6
|
+
|
|
7
|
+
namespace AUTD3.Samples
|
|
8
|
+
{
|
|
9
|
+
// Single focus with a 200 Hz sine AM, driven from a MonoBehaviour.
|
|
10
|
+
//
|
|
11
|
+
// Coordinates are in the Unity frame (metres, +z forward): the same focus that the
|
|
12
|
+
// dotnet sample writes as new Vector3(0, 0, 150) is new Vector3(0, 0, 0.15f) here.
|
|
13
|
+
// The Nop link runs without hardware; swap it for new EtherCrab(...) on a real device.
|
|
14
|
+
public sealed class FocusSineSample : MonoBehaviour
|
|
15
|
+
{
|
|
16
|
+
private Client _client;
|
|
17
|
+
private Geometry _geometry;
|
|
18
|
+
|
|
19
|
+
private async void Start()
|
|
20
|
+
{
|
|
21
|
+
_geometry = new Geometry(new List<Autd3> { new Autd3(Vector3.zero) });
|
|
22
|
+
// Fully qualified: the enclosing AUTD3 namespace also has a `Nop` command.
|
|
23
|
+
_client = await Client.OpenAsync(_geometry, new AUTD3.Link.Nop(), new ClientConfig());
|
|
24
|
+
|
|
25
|
+
var target = _geometry.Center + new Vector3(0f, 0f, 0.15f);
|
|
26
|
+
var wavelength = Pattern.Wavelength(340 * m / s);
|
|
27
|
+
using var patterns = _geometry.PatternBuffer();
|
|
28
|
+
Pattern.Focus(_geometry, target, wavelength, new FocusOption(), patterns);
|
|
29
|
+
|
|
30
|
+
using var modulation = Modulation.ModulationBuffer();
|
|
31
|
+
Modulation.Sine(200 * Hz, new SineOption(), modulation);
|
|
32
|
+
|
|
33
|
+
using var builder = _client.DatagramBuilder();
|
|
34
|
+
builder
|
|
35
|
+
.Push(new Pattern(patterns))
|
|
36
|
+
.Push(new Modulation(SamplingConfig.Freq4k, modulation));
|
|
37
|
+
using var frames = builder.Build();
|
|
38
|
+
foreach (var frame in frames)
|
|
39
|
+
{
|
|
40
|
+
await _client.SendCheckedAsync(frame);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
Debug.Log($"AUTD3: emitting a 200 Hz AM focus at {target} (Unity frame, metres)");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private async void OnDestroy()
|
|
47
|
+
{
|
|
48
|
+
if (_client != null)
|
|
49
|
+
{
|
|
50
|
+
await _client.StopAsync();
|
|
51
|
+
await _client.CloseAsync();
|
|
52
|
+
_client.Dispose();
|
|
53
|
+
_client = null;
|
|
54
|
+
}
|
|
55
|
+
_geometry?.Dispose();
|
|
56
|
+
_geometry = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|