antioch-py 2.0.6__py3-none-any.whl
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.
Potentially problematic release.
This version of antioch-py might be problematic. Click here for more details.
- antioch/__init__.py +0 -0
- antioch/message.py +87 -0
- antioch/module/__init__.py +53 -0
- antioch/module/clock.py +62 -0
- antioch/module/execution.py +278 -0
- antioch/module/input.py +127 -0
- antioch/module/module.py +218 -0
- antioch/module/node.py +357 -0
- antioch/module/token.py +42 -0
- antioch/session/__init__.py +150 -0
- antioch/session/ark.py +504 -0
- antioch/session/asset.py +65 -0
- antioch/session/error.py +80 -0
- antioch/session/record.py +158 -0
- antioch/session/scene.py +1521 -0
- antioch/session/session.py +220 -0
- antioch/session/task.py +323 -0
- antioch/session/views/__init__.py +40 -0
- antioch/session/views/animation.py +189 -0
- antioch/session/views/articulation.py +245 -0
- antioch/session/views/basis_curve.py +186 -0
- antioch/session/views/camera.py +92 -0
- antioch/session/views/collision.py +75 -0
- antioch/session/views/geometry.py +74 -0
- antioch/session/views/ground_plane.py +63 -0
- antioch/session/views/imu.py +73 -0
- antioch/session/views/joint.py +64 -0
- antioch/session/views/light.py +175 -0
- antioch/session/views/pir_sensor.py +140 -0
- antioch/session/views/radar.py +73 -0
- antioch/session/views/rigid_body.py +282 -0
- antioch/session/views/xform.py +119 -0
- antioch_py-2.0.6.dist-info/METADATA +115 -0
- antioch_py-2.0.6.dist-info/RECORD +99 -0
- antioch_py-2.0.6.dist-info/WHEEL +5 -0
- antioch_py-2.0.6.dist-info/entry_points.txt +2 -0
- antioch_py-2.0.6.dist-info/top_level.txt +2 -0
- common/__init__.py +0 -0
- common/ark/__init__.py +60 -0
- common/ark/ark.py +128 -0
- common/ark/hardware.py +121 -0
- common/ark/kinematics.py +31 -0
- common/ark/module.py +85 -0
- common/ark/node.py +94 -0
- common/ark/scheduler.py +439 -0
- common/ark/sim.py +33 -0
- common/assets/__init__.py +3 -0
- common/constants.py +47 -0
- common/core/__init__.py +52 -0
- common/core/agent.py +296 -0
- common/core/auth.py +305 -0
- common/core/registry.py +331 -0
- common/core/task.py +36 -0
- common/message/__init__.py +59 -0
- common/message/annotation.py +89 -0
- common/message/array.py +500 -0
- common/message/base.py +517 -0
- common/message/camera.py +91 -0
- common/message/color.py +139 -0
- common/message/frame.py +50 -0
- common/message/image.py +171 -0
- common/message/imu.py +14 -0
- common/message/joint.py +47 -0
- common/message/log.py +31 -0
- common/message/pir.py +16 -0
- common/message/point.py +109 -0
- common/message/point_cloud.py +63 -0
- common/message/pose.py +148 -0
- common/message/quaternion.py +273 -0
- common/message/radar.py +58 -0
- common/message/types.py +37 -0
- common/message/vector.py +786 -0
- common/rome/__init__.py +9 -0
- common/rome/client.py +430 -0
- common/rome/error.py +16 -0
- common/session/__init__.py +54 -0
- common/session/environment.py +31 -0
- common/session/sim.py +240 -0
- common/session/views/__init__.py +263 -0
- common/session/views/animation.py +73 -0
- common/session/views/articulation.py +184 -0
- common/session/views/basis_curve.py +102 -0
- common/session/views/camera.py +147 -0
- common/session/views/collision.py +59 -0
- common/session/views/geometry.py +102 -0
- common/session/views/ground_plane.py +41 -0
- common/session/views/imu.py +66 -0
- common/session/views/joint.py +81 -0
- common/session/views/light.py +96 -0
- common/session/views/pir_sensor.py +115 -0
- common/session/views/radar.py +82 -0
- common/session/views/rigid_body.py +236 -0
- common/session/views/viewport.py +21 -0
- common/session/views/xform.py +39 -0
- common/utils/__init__.py +4 -0
- common/utils/comms.py +571 -0
- common/utils/logger.py +123 -0
- common/utils/time.py +42 -0
- common/utils/usd.py +12 -0
common/__init__.py
ADDED
|
File without changes
|
common/ark/__init__.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from common.ark.ark import (
|
|
2
|
+
Ark,
|
|
3
|
+
ArkInfo,
|
|
4
|
+
ArkMetadata,
|
|
5
|
+
ArkReference,
|
|
6
|
+
ArkVersionReference,
|
|
7
|
+
AssetReference,
|
|
8
|
+
AssetVersionReference,
|
|
9
|
+
Environment,
|
|
10
|
+
Kinematics,
|
|
11
|
+
)
|
|
12
|
+
from common.ark.hardware import CameraHardware, Hardware, HardwareType, ImuHardware, PirHardware, RadarHardware
|
|
13
|
+
from common.ark.kinematics import Joint, Link
|
|
14
|
+
from common.ark.module import Module, ModuleImage, ModuleInfo, ModuleKind, ModuleParameter, ParamType
|
|
15
|
+
from common.ark.node import HardwareAccessMode, Node, NodeInput, NodeOutput, NodeTimer
|
|
16
|
+
from common.ark.scheduler import InputToken, NodeCompleteEvent, NodeEdge, NodeStartEvent, NodeState, OnlineScheduler, ScheduleEvent
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
# Core Ark types
|
|
20
|
+
"Ark",
|
|
21
|
+
"ArkInfo",
|
|
22
|
+
"ArkMetadata",
|
|
23
|
+
"AssetReference",
|
|
24
|
+
"AssetVersionReference",
|
|
25
|
+
"ArkReference",
|
|
26
|
+
"ArkVersionReference",
|
|
27
|
+
"Environment",
|
|
28
|
+
"Kinematics",
|
|
29
|
+
# Module types
|
|
30
|
+
"Module",
|
|
31
|
+
"ModuleImage",
|
|
32
|
+
"ModuleInfo",
|
|
33
|
+
"ModuleKind",
|
|
34
|
+
"ModuleParameter",
|
|
35
|
+
"ParamType",
|
|
36
|
+
# Node types
|
|
37
|
+
"HardwareAccessMode",
|
|
38
|
+
"Node",
|
|
39
|
+
"NodeInput",
|
|
40
|
+
"NodeOutput",
|
|
41
|
+
"NodeTimer",
|
|
42
|
+
# Kinematics types
|
|
43
|
+
"Joint",
|
|
44
|
+
"Link",
|
|
45
|
+
# Hardware types
|
|
46
|
+
"CameraHardware",
|
|
47
|
+
"Hardware",
|
|
48
|
+
"HardwareType",
|
|
49
|
+
"ImuHardware",
|
|
50
|
+
"PirHardware",
|
|
51
|
+
"RadarHardware",
|
|
52
|
+
# Schedule types
|
|
53
|
+
"NodeEdge",
|
|
54
|
+
"InputToken",
|
|
55
|
+
"NodeCompleteEvent",
|
|
56
|
+
"NodeStartEvent",
|
|
57
|
+
"ScheduleEvent",
|
|
58
|
+
"NodeState",
|
|
59
|
+
"OnlineScheduler",
|
|
60
|
+
]
|
common/ark/ark.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
from common.ark.hardware import Hardware
|
|
4
|
+
from common.ark.kinematics import Joint, Link
|
|
5
|
+
from common.ark.module import Module
|
|
6
|
+
from common.ark.scheduler import NodeEdge
|
|
7
|
+
from common.message import Message
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Environment(str, Enum):
|
|
11
|
+
"""
|
|
12
|
+
The environment of the Ark.
|
|
13
|
+
|
|
14
|
+
:cvar SIM: The simulation environment.
|
|
15
|
+
:cvar REAL: The real environment.
|
|
16
|
+
:cvar ALL: All environments.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
SIM = "sim"
|
|
20
|
+
REAL = "real"
|
|
21
|
+
ALL = "all"
|
|
22
|
+
|
|
23
|
+
def __str__(self) -> str:
|
|
24
|
+
return self.value
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ArkMetadata(Message):
|
|
28
|
+
"""
|
|
29
|
+
Metadata about the Ark.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
digest: str
|
|
33
|
+
version: str
|
|
34
|
+
timestamp: str
|
|
35
|
+
asset_hash: str | None = None
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class ArkInfo(Message):
|
|
39
|
+
"""
|
|
40
|
+
Information about the Ark.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
description: str
|
|
44
|
+
version: str
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class Kinematics(Message):
|
|
48
|
+
"""
|
|
49
|
+
The kinematics of the Ark.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
links: list[Link]
|
|
53
|
+
joints: list[Joint]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class ArkVersionReference(Message):
|
|
57
|
+
"""
|
|
58
|
+
Reference to an Ark version in the remote Ark registry.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
version: str
|
|
62
|
+
created_at: str
|
|
63
|
+
updated_at: str
|
|
64
|
+
full_path: str
|
|
65
|
+
size_bytes: int
|
|
66
|
+
asset_path: str | None = None
|
|
67
|
+
asset_size_bytes: int | None = None
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class ArkReference(Message):
|
|
71
|
+
"""
|
|
72
|
+
Reference to an Ark in the remote Ark registry.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
name: str
|
|
76
|
+
versions: list[ArkVersionReference]
|
|
77
|
+
created_at: str
|
|
78
|
+
updated_at: str
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class AssetVersionReference(Message):
|
|
82
|
+
"""
|
|
83
|
+
Reference to a specific asset version.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
version: str
|
|
87
|
+
full_path: str
|
|
88
|
+
size_bytes: int
|
|
89
|
+
created_at: str
|
|
90
|
+
updated_at: str
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class AssetReference(Message):
|
|
94
|
+
"""
|
|
95
|
+
Reference to an asset with all its versions.
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
name: str
|
|
99
|
+
versions: list[AssetVersionReference]
|
|
100
|
+
created_at: str
|
|
101
|
+
updated_at: str
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class Ark(Message):
|
|
105
|
+
"""
|
|
106
|
+
Antioch Ark specification.
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
metadata: ArkMetadata
|
|
110
|
+
name: str
|
|
111
|
+
capability: Environment
|
|
112
|
+
info: ArkInfo
|
|
113
|
+
modules: list[Module]
|
|
114
|
+
edges: list[NodeEdge]
|
|
115
|
+
kinematics: Kinematics
|
|
116
|
+
hardware: list[Hardware]
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
if __name__ == "__main__":
|
|
120
|
+
import argparse
|
|
121
|
+
|
|
122
|
+
parser = argparse.ArgumentParser()
|
|
123
|
+
parser.add_argument("ark_file", type=str, help="The Ark json file to serialize")
|
|
124
|
+
args = parser.parse_args()
|
|
125
|
+
|
|
126
|
+
with open(args.ark_file) as f:
|
|
127
|
+
ark = Ark.model_validate_json(f.read())
|
|
128
|
+
print(ark.to_json(2))
|
common/ark/hardware.py
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
from pydantic import Field, ValidationInfo, field_validator
|
|
6
|
+
|
|
7
|
+
from common.message import Message, Pose
|
|
8
|
+
from common.session.views.articulation import ArticulationConfig
|
|
9
|
+
from common.session.views.camera import CameraConfig
|
|
10
|
+
from common.session.views.imu import ImuConfig
|
|
11
|
+
from common.session.views.pir_sensor import PirSensorConfig
|
|
12
|
+
from common.session.views.radar import RadarConfig
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class HardwareType(str, Enum):
|
|
16
|
+
"""
|
|
17
|
+
Types of hardware that can be attached to an instance.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
CAMERA = "camera"
|
|
21
|
+
IMU = "imu"
|
|
22
|
+
PIR = "pir"
|
|
23
|
+
RADAR = "radar"
|
|
24
|
+
ACTUATOR_GROUP = "actuator_group"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ActuatorGroupHardware(Message):
|
|
28
|
+
"""
|
|
29
|
+
Actuator group hardware that controls multiple joints.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
module: str
|
|
33
|
+
name: str
|
|
34
|
+
config: ArticulationConfig
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class ImuHardware(Message):
|
|
38
|
+
"""
|
|
39
|
+
IMU sensor hardware attached to a link.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
module: str
|
|
43
|
+
name: str
|
|
44
|
+
path: str
|
|
45
|
+
pose: Pose = Field(default_factory=Pose)
|
|
46
|
+
parent_link: str | None = None
|
|
47
|
+
config: ImuConfig
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class PirHardware(Message):
|
|
51
|
+
"""
|
|
52
|
+
PIR (Passive Infrared) sensor hardware attached to a link.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
module: str
|
|
56
|
+
name: str
|
|
57
|
+
path: str
|
|
58
|
+
pose: Pose = Field(default_factory=Pose)
|
|
59
|
+
parent_link: str | None = None
|
|
60
|
+
config: PirSensorConfig
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class RadarHardware(Message):
|
|
64
|
+
"""
|
|
65
|
+
Radar sensor hardware attached to a link.
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
module: str
|
|
69
|
+
name: str
|
|
70
|
+
path: str
|
|
71
|
+
pose: Pose = Field(default_factory=Pose)
|
|
72
|
+
parent_link: str | None = None
|
|
73
|
+
config: RadarConfig
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class CameraHardware(Message):
|
|
77
|
+
"""
|
|
78
|
+
Camera sensor hardware attached to a link.
|
|
79
|
+
|
|
80
|
+
Used for both RGB and depth cameras - the mode is specified in the config.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
module: str
|
|
84
|
+
name: str
|
|
85
|
+
path: str
|
|
86
|
+
pose: Pose = Field(default_factory=Pose)
|
|
87
|
+
parent_link: str | None = None
|
|
88
|
+
config: CameraConfig
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class Hardware(Message):
|
|
92
|
+
"""
|
|
93
|
+
Union of all hardware types for an Ark.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
type: HardwareType
|
|
97
|
+
config: ActuatorGroupHardware | ImuHardware | PirHardware | RadarHardware | CameraHardware
|
|
98
|
+
|
|
99
|
+
@field_validator("config", mode="before")
|
|
100
|
+
@classmethod
|
|
101
|
+
def validate_config(cls, config: dict, info: ValidationInfo):
|
|
102
|
+
"""
|
|
103
|
+
Validate the hardware config based on the type field.
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
hw_type = info.data.get("type")
|
|
107
|
+
if hw_type is None:
|
|
108
|
+
raise ValueError("Hardware type is required")
|
|
109
|
+
match hw_type:
|
|
110
|
+
case HardwareType.ACTUATOR_GROUP:
|
|
111
|
+
return ActuatorGroupHardware.model_validate(config)
|
|
112
|
+
case HardwareType.IMU:
|
|
113
|
+
return ImuHardware.model_validate(config)
|
|
114
|
+
case HardwareType.PIR:
|
|
115
|
+
return PirHardware.model_validate(config)
|
|
116
|
+
case HardwareType.RADAR:
|
|
117
|
+
return RadarHardware.model_validate(config)
|
|
118
|
+
case HardwareType.CAMERA:
|
|
119
|
+
return CameraHardware.model_validate(config)
|
|
120
|
+
case _:
|
|
121
|
+
raise ValueError(f"Unknown hardware type: {hw_type}")
|
common/ark/kinematics.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from common.message import Message, Pose
|
|
2
|
+
from common.session.views.joint import JointAxis, JointType
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Joint(Message):
|
|
6
|
+
"""
|
|
7
|
+
Complete specification for a joint connecting two links in an ark.
|
|
8
|
+
|
|
9
|
+
A joint defines the kinematic relationship between a parent and child link,
|
|
10
|
+
including the type of motion allowed, physical properties, and optional
|
|
11
|
+
actuator_group assignment for coordinated control of multiple joints.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
path: str
|
|
15
|
+
parent: str
|
|
16
|
+
child: str
|
|
17
|
+
type: JointType
|
|
18
|
+
pose: Pose
|
|
19
|
+
axis: JointAxis | None
|
|
20
|
+
lower_limit: float | None
|
|
21
|
+
upper_limit: float | None
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Link(Message):
|
|
25
|
+
"""
|
|
26
|
+
A link in the kinematic tree.
|
|
27
|
+
|
|
28
|
+
Links are uniquely identified by their USD path.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
path: str
|
common/ark/module.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
from common.ark.node import Node
|
|
4
|
+
from common.message import Message
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ModuleKind(str, Enum):
|
|
8
|
+
"""
|
|
9
|
+
Defines the type of module in the system.
|
|
10
|
+
|
|
11
|
+
Modules can be either software primitives that run in containers
|
|
12
|
+
or hardware abstractions that interface with physical/simulated arks.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
SOFTWARE = "software"
|
|
16
|
+
HARDWARE = "hardware"
|
|
17
|
+
|
|
18
|
+
def __str__(self) -> str:
|
|
19
|
+
return self.value
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ModuleInfo(Message):
|
|
23
|
+
"""
|
|
24
|
+
Information about a module.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
name: str
|
|
28
|
+
description: str | None = None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ParamType(str, Enum):
|
|
32
|
+
"""
|
|
33
|
+
Supported parameter types for module configuration.
|
|
34
|
+
|
|
35
|
+
These types define what kinds of configuration values can be
|
|
36
|
+
passed to modules at runtime.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
BOOLEAN = "boolean"
|
|
40
|
+
NUMBER = "number"
|
|
41
|
+
TEXT = "text"
|
|
42
|
+
NULL = "null"
|
|
43
|
+
|
|
44
|
+
def __str__(self):
|
|
45
|
+
return self.value
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class ModuleParameter(Message):
|
|
49
|
+
"""
|
|
50
|
+
Type-safe parameter for module configuration.
|
|
51
|
+
|
|
52
|
+
Wraps parameter values with type information to ensure type safety
|
|
53
|
+
when passing configuration to modules at runtime.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
description: str | None = None
|
|
57
|
+
type: ParamType
|
|
58
|
+
value: bool | int | float | str | None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class ModuleImage(Message):
|
|
62
|
+
"""
|
|
63
|
+
Image configuration for hardware module deployment.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
sim: str | None = None
|
|
67
|
+
real: str | None = None
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class Module(Message):
|
|
71
|
+
"""
|
|
72
|
+
Complete specification for a module in the middleware system.
|
|
73
|
+
|
|
74
|
+
A module is a containerized primitive that contains one or more processing nodes.
|
|
75
|
+
Each module has build configuration, metadata, runtime parameters, and defines
|
|
76
|
+
the nodes it contains. Modules are the unit of deployment and execution in
|
|
77
|
+
the middleware system.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
name: str
|
|
81
|
+
kind: ModuleKind
|
|
82
|
+
image: str | ModuleImage
|
|
83
|
+
info: ModuleInfo
|
|
84
|
+
parameters: dict[str, ModuleParameter]
|
|
85
|
+
nodes: dict[str, Node]
|
common/ark/node.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import math
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
|
|
6
|
+
from common.message import Message
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class HardwareAccessMode(str, Enum):
|
|
10
|
+
"""
|
|
11
|
+
Hardware access mode for a node.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
NONE = "none"
|
|
15
|
+
READ = "read"
|
|
16
|
+
WRITE = "write"
|
|
17
|
+
READ_WRITE = "read_write"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class NodeTimer(Message):
|
|
21
|
+
"""
|
|
22
|
+
Timer configuration for periodic node execution.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
frequency: float | None = None
|
|
26
|
+
period: float | None = None
|
|
27
|
+
|
|
28
|
+
def to_period_us(self) -> int:
|
|
29
|
+
"""
|
|
30
|
+
Convert timer specification to period in microseconds with millisecond rounding.
|
|
31
|
+
|
|
32
|
+
:return: Period in microseconds rounded to the nearest millisecond.
|
|
33
|
+
:raises ValueError: If the timer specification is invalid.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
if self.frequency is not None:
|
|
37
|
+
if self.frequency <= 0 or not math.isfinite(self.frequency):
|
|
38
|
+
raise ValueError("Timer frequency must be positive and finite")
|
|
39
|
+
period_ms = 1000.0 / self.frequency
|
|
40
|
+
elif self.period is not None:
|
|
41
|
+
period_ms = self.period
|
|
42
|
+
else:
|
|
43
|
+
raise ValueError("Timer must specify frequency or period")
|
|
44
|
+
|
|
45
|
+
# Convert to microseconds
|
|
46
|
+
period_us = int(period_ms * 1000)
|
|
47
|
+
|
|
48
|
+
# Round to nearest millisecond
|
|
49
|
+
rounded_us = ((period_us + 500) // 1000) * 1000
|
|
50
|
+
if rounded_us == 0:
|
|
51
|
+
raise ValueError("Timer frequency is too high (sub-millisecond period)")
|
|
52
|
+
|
|
53
|
+
return rounded_us
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class NodeInput(Message):
|
|
57
|
+
"""
|
|
58
|
+
Configuration for a node's input.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
name: str
|
|
62
|
+
description: str | None = None
|
|
63
|
+
type: str
|
|
64
|
+
path: str
|
|
65
|
+
required: bool
|
|
66
|
+
always_run: bool
|
|
67
|
+
last_n: int
|
|
68
|
+
max_age_ms: int | None = None
|
|
69
|
+
consume_inputs: bool
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class NodeOutput(Message):
|
|
73
|
+
"""
|
|
74
|
+
Configuration for a node's output.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
name: str
|
|
78
|
+
description: str | None = None
|
|
79
|
+
type: str
|
|
80
|
+
path: str
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class Node(Message):
|
|
84
|
+
"""
|
|
85
|
+
Complete specification for a processing node within a module.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
name: str
|
|
89
|
+
description: str | None = None
|
|
90
|
+
budget_us: int
|
|
91
|
+
timer: NodeTimer | None = None
|
|
92
|
+
inputs: dict[str, NodeInput] = Field(default_factory=dict)
|
|
93
|
+
outputs: dict[str, NodeOutput] = Field(default_factory=dict)
|
|
94
|
+
hardware_access: dict[str, HardwareAccessMode] = Field(default_factory=dict)
|