antioch-py 2.0.7__py3-none-any.whl → 2.1.0__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.

Files changed (54) hide show
  1. antioch/session/__init__.py +15 -13
  2. antioch/session/ark.py +22 -26
  3. antioch/session/objects/__init__.py +40 -0
  4. antioch/session/{views → objects}/animation.py +25 -52
  5. antioch/session/{views → objects}/articulation.py +30 -95
  6. antioch/session/{views → objects}/basis_curve.py +18 -54
  7. antioch/session/{views → objects}/camera.py +12 -39
  8. antioch/session/objects/collision.py +46 -0
  9. antioch/session/{views → objects}/geometry.py +6 -22
  10. antioch/session/{views → objects}/ground_plane.py +5 -20
  11. antioch/session/{views → objects}/imu.py +10 -30
  12. antioch/session/{views → objects}/joint.py +5 -20
  13. antioch/session/{views → objects}/light.py +14 -66
  14. antioch/session/{views → objects}/pir_sensor.py +20 -62
  15. antioch/session/objects/radar.py +62 -0
  16. antioch/session/{views → objects}/rigid_body.py +25 -110
  17. antioch/session/{views → objects}/xform.py +24 -24
  18. antioch/session/scene.py +83 -134
  19. antioch/session/session.py +34 -43
  20. antioch/session/task.py +2 -16
  21. {antioch_py-2.0.7.dist-info → antioch_py-2.1.0.dist-info}/METADATA +1 -1
  22. {antioch_py-2.0.7.dist-info → antioch_py-2.1.0.dist-info}/RECORD +33 -49
  23. common/ark/hardware.py +1 -5
  24. common/ark/kinematics.py +1 -1
  25. common/core/agent.py +28 -0
  26. common/message/__init__.py +2 -0
  27. common/message/velocity.py +11 -0
  28. common/session/__init__.py +1 -24
  29. common/session/config.py +390 -0
  30. common/session/sim.py +36 -147
  31. antioch/session/views/__init__.py +0 -42
  32. antioch/session/views/collision.py +0 -75
  33. antioch/session/views/material.py +0 -54
  34. antioch/session/views/radar.py +0 -131
  35. common/session/views/__init__.py +0 -263
  36. common/session/views/animation.py +0 -73
  37. common/session/views/articulation.py +0 -184
  38. common/session/views/basis_curve.py +0 -102
  39. common/session/views/camera.py +0 -147
  40. common/session/views/collision.py +0 -59
  41. common/session/views/geometry.py +0 -102
  42. common/session/views/ground_plane.py +0 -41
  43. common/session/views/imu.py +0 -66
  44. common/session/views/joint.py +0 -81
  45. common/session/views/light.py +0 -96
  46. common/session/views/material.py +0 -25
  47. common/session/views/pir_sensor.py +0 -119
  48. common/session/views/radar.py +0 -107
  49. common/session/views/rigid_body.py +0 -236
  50. common/session/views/viewport.py +0 -21
  51. common/session/views/xform.py +0 -39
  52. {antioch_py-2.0.7.dist-info → antioch_py-2.1.0.dist-info}/WHEEL +0 -0
  53. {antioch_py-2.0.7.dist-info → antioch_py-2.1.0.dist-info}/entry_points.txt +0 -0
  54. {antioch_py-2.0.7.dist-info → antioch_py-2.1.0.dist-info}/top_level.txt +0 -0
common/session/sim.py CHANGED
@@ -1,10 +1,10 @@
1
- import time
2
1
  from enum import Enum
3
- from typing import Any
2
+ from typing import Any, TypeVar, cast
4
3
 
5
- from pydantic import Field
4
+ from common.message import Message
6
5
 
7
- from common.message import Message, Pose, Vector3
6
+ T = TypeVar("T")
7
+ _MISSING = object()
8
8
 
9
9
 
10
10
  class SimulationState(str, Enum):
@@ -17,14 +17,6 @@ class SimulationState(str, Enum):
17
17
  STOPPED = "stopped"
18
18
 
19
19
 
20
- class Step(Message):
21
- """
22
- Step the simulation forward by a specified amount of time in microseconds.
23
- """
24
-
25
- dt_us: int = 10000 # Default 10ms
26
-
27
-
28
20
  class SimulationInfo(Message):
29
21
  """
30
22
  Full simulation info.
@@ -42,77 +34,9 @@ class SimulationTime(Message):
42
34
  time_us: int
43
35
 
44
36
 
45
- class ToggleUi(Message):
46
- """
47
- Toggle the UI visibility.
48
- """
49
-
50
- show_ui: bool
51
-
52
-
53
- class GetObject(Message):
54
- """
55
- Get information about a specific object.
56
- """
57
-
58
- path: str
59
-
60
-
61
- class ObjectInfo(Message):
62
- """
63
- Information about a simulation object.
64
- """
65
-
66
- path: str
67
- type: str
68
- config: dict[str, Any]
69
-
70
-
71
- class AllObjectInfo(Message):
72
- """
73
- All objects in the scene.
74
- """
75
-
76
- objects: list[ObjectInfo]
77
-
78
-
79
- class GetWorldPose(Message):
80
- """
81
- Get the world pose of an object.
82
- """
83
-
84
- path: str = Field(description="USD path of the object")
85
-
86
-
87
- class GetLocalPose(Message):
88
- """
89
- Get the local pose of an object.
90
- """
91
-
92
- path: str = Field(description="USD path of the object")
93
-
94
-
95
- class SetWorldPose(Message):
96
- """
97
- Set the world pose of an object.
98
- """
99
-
100
- path: str = Field(description="USD path of the object")
101
- pose: Pose
102
-
103
-
104
- class SetLocalPose(Message):
105
- """
106
- Set the local pose of an object.
107
- """
108
-
109
- path: str = Field(description="USD path of the object")
110
- pose: Pose
111
-
112
-
113
37
  class RpcError(Message):
114
38
  """
115
- RPC error.
39
+ RPC error details.
116
40
  """
117
41
 
118
42
  message: str
@@ -122,69 +46,44 @@ class RpcError(Message):
122
46
 
123
47
  class RpcCall(Message):
124
48
  """
125
- RPC call with optional payload.
126
- """
127
-
128
- ts: int = Field(default_factory=lambda: int(time.time_ns() // 1000))
129
- payload: bytes | None = None
130
-
131
-
132
- class RpcResponse(Message):
133
- """
134
- RPC response with optional payload and error.
49
+ RPC request with dict payload.
135
50
  """
136
51
 
137
- ts: int = Field(default_factory=lambda: int(time.time_ns() // 1000))
138
- payload: bytes | None = None
139
- error: RpcError | None = None
140
-
52
+ data: dict[str, Any] | None = None
141
53
 
142
- class AddAsset(Message):
143
- """
144
- Add an asset to the simulation.
145
- """
54
+ def get(self, key: str, *, type: type[T] | None = None, default: T | object = _MISSING) -> T:
55
+ """
56
+ Get a value from the call data with optional type conversion.
146
57
 
147
- path: str = Field(description="USD path where asset will be added")
148
- asset_file_path: str = Field(description="Path to asset file (USD, FBX, OBJ, etc.)")
149
- asset_prim_path: str | None = Field(default=None, description="Full path to prim in the Usd file to reference")
150
- remove_articulation: bool = Field(default=True, description="Whether to remove articulation APIs")
151
- remove_rigid_body: bool = Field(default=False, description="Whether to remove rigid body APIs")
152
- remove_sensors: bool = Field(default=False, description="Whether to remove sensor and graph prims")
153
- world_pose: Pose | None = Field(default=None, description="Optional world pose")
154
- local_pose: Pose | None = Field(default=None, description="Optional local pose")
155
- scale: Vector3 | None = Field(default=None, description="Optional scale")
58
+ If type is a Message subclass, auto-converts via model_validate.
59
+ Raises KeyError if key missing and no default provided.
156
60
 
61
+ :param key: The key to lookup in data.
62
+ :param type: The expected type class (optional).
63
+ :param default: Default value to return if key is missing (can be None).
64
+ :return: The value (converted if type provided).
65
+ :raises KeyError: If key is missing and no default provided.
66
+ """
157
67
 
158
- class GetPrimAttribute(Message):
159
- """
160
- Get an attribute value from a prim.
68
+ if self.data is None or key not in self.data:
69
+ if default is not _MISSING:
70
+ return cast(T, default)
71
+ raise KeyError(f"Missing required field '{key}'")
161
72
 
162
- Supports primitive and vector types (float, int, bool, string, Vec2/3/4, Quat).
163
- """
73
+ value = self.data[key]
74
+ if type is not None and isinstance(value, dict) and issubclass(type, Message):
75
+ return cast(T, type.model_validate(value))
164
76
 
165
- path: str = Field(description="USD path to the prim")
166
- attribute_name: str = Field(description="Name of the attribute to get")
77
+ return cast(T, value)
167
78
 
168
79
 
169
- class SetPrimAttribute(Message):
170
- """
171
- Set an attribute value on a prim.
172
-
173
- Supports primitive and vector types (float, int, bool, string, Vec2/3/4, Quat).
174
- The attribute must already exist on the prim.
175
- """
176
-
177
- path: str = Field(description="USD path to the prim")
178
- attribute_name: str = Field(description="Name of the attribute to set")
179
- value: float | int | str | bool | list[float] = Field(description="Value to set (must match attribute type)")
180
-
181
-
182
- class PrimAttributeValue(Message):
80
+ class RpcResponse(Message):
183
81
  """
184
- Response containing an attribute value.
82
+ RPC response with arbitrary payload or error.
185
83
  """
186
84
 
187
- value: float | int | str | bool | list[float]
85
+ data: Any = None
86
+ error: RpcError | None = None
188
87
 
189
88
 
190
89
  class SceneTarget(str, Enum):
@@ -210,17 +109,8 @@ class PrimInfo(Message):
210
109
  Information about a prim in the scene with its applicable view types.
211
110
  """
212
111
 
213
- path: str = Field(description="USD path to the prim")
214
- targets: list[SceneTarget] = Field(description="List of applicable scene targets/view types for this prim")
215
-
216
-
217
- class QueryScene(Message):
218
- """
219
- Query the scene hierarchy for prims matching specific criteria.
220
- """
221
-
222
- root_path: str = Field(default="/World", description="Root path to start the query from")
223
- target: SceneTarget | None = Field(default=None, description="Specific target type to filter for (None returns all)")
112
+ path: str
113
+ targets: list[SceneTarget]
224
114
 
225
115
 
226
116
  class SceneQueryResponse(Message):
@@ -228,13 +118,12 @@ class SceneQueryResponse(Message):
228
118
  Response containing the results of a scene query.
229
119
  """
230
120
 
231
- prims: list[PrimInfo] = Field(description="List of matching prims with their applicable targets")
121
+ prims: list[PrimInfo]
232
122
 
233
123
 
234
- class SetSimulationControls(Message):
124
+ class PrimAttributeValue(Message):
235
125
  """
236
- Set simulation control parameters.
126
+ Response containing an attribute value.
237
127
  """
238
128
 
239
- max_physics_dt_us: int | None = Field(default=None, description="Maximum physics timestep in microseconds")
240
- render_interval_us: int | None = Field(default=None, description="Render interval in microseconds")
129
+ value: float | int | str | bool | list[float]
@@ -1,42 +0,0 @@
1
- from antioch.session.views.animation import Animation
2
- from antioch.session.views.articulation import Articulation
3
- from antioch.session.views.basis_curve import BasisCurve
4
- from antioch.session.views.camera import Camera
5
- from antioch.session.views.collision import (
6
- get_mesh_approximation,
7
- has_collision,
8
- remove_collision,
9
- set_collision,
10
- )
11
- from antioch.session.views.geometry import Geometry
12
- from antioch.session.views.ground_plane import GroundPlane
13
- from antioch.session.views.imu import Imu
14
- from antioch.session.views.joint import Joint
15
- from antioch.session.views.light import Light
16
- from antioch.session.views.material import set_nonvisual_material
17
- from antioch.session.views.pir_sensor import PirSensor, set_pir_material
18
- from antioch.session.views.radar import Radar
19
- from antioch.session.views.rigid_body import RigidBody
20
- from antioch.session.views.xform import XForm
21
-
22
- __all__ = [
23
- "Animation",
24
- "Articulation",
25
- "BasisCurve",
26
- "Camera",
27
- "Geometry",
28
- "GroundPlane",
29
- "Imu",
30
- "Joint",
31
- "Light",
32
- "PirSensor",
33
- "Radar",
34
- "RigidBody",
35
- "XForm",
36
- "get_mesh_approximation",
37
- "has_collision",
38
- "remove_collision",
39
- "set_collision",
40
- "set_nonvisual_material",
41
- "set_pir_material",
42
- ]
@@ -1,75 +0,0 @@
1
- from antioch.session.session import Session
2
- from common.session.views.collision import (
3
- GetMeshApproximation,
4
- GetMeshApproximationResponse,
5
- HasCollision,
6
- HasCollisionResponse,
7
- RemoveCollision,
8
- SetCollision,
9
- )
10
- from common.session.views.geometry import MeshApproximation
11
-
12
-
13
- def set_collision(path: str, mesh_approximation: MeshApproximation | None = None) -> None:
14
- """
15
- Apply collision API to a prim, optionally with mesh approximation.
16
-
17
- :param path: USD path to the prim.
18
- :param mesh_approximation: Optional mesh approximation method for collision geometry.
19
- """
20
-
21
- Session.get_current().query_sim_rpc(
22
- endpoint="set_collision",
23
- payload=SetCollision(path=path, mesh_approximation=mesh_approximation),
24
- )
25
-
26
-
27
- def remove_collision(path: str) -> None:
28
- """
29
- Remove collision API from a prim.
30
-
31
- :param path: USD path to the prim.
32
- """
33
-
34
- Session.get_current().query_sim_rpc(
35
- endpoint="remove_collision",
36
- payload=RemoveCollision(path=path),
37
- )
38
-
39
-
40
- def has_collision(path: str) -> bool:
41
- """
42
- Check if a prim has collision API applied.
43
-
44
- :param path: USD path to the prim.
45
- :return: True if collision API is applied.
46
- """
47
-
48
- return (
49
- Session.get_current()
50
- .query_sim_rpc(
51
- endpoint="has_collision",
52
- payload=HasCollision(path=path),
53
- response_type=HasCollisionResponse,
54
- )
55
- .has_collision
56
- )
57
-
58
-
59
- def get_mesh_approximation(path: str) -> MeshApproximation | None:
60
- """
61
- Get mesh collision approximation from a prim.
62
-
63
- :param path: USD path to the prim.
64
- :return: Mesh approximation method, or None if not set.
65
- """
66
-
67
- return (
68
- Session.get_current()
69
- .query_sim_rpc(
70
- endpoint="get_mesh_approximation_rpc",
71
- payload=GetMeshApproximation(path=path),
72
- response_type=GetMeshApproximationResponse,
73
- )
74
- .approximation
75
- )
@@ -1,54 +0,0 @@
1
- from antioch.session.session import Session
2
- from common.session.views.material import SetNonVisualMaterial, SetNonVisualMaterialResponse
3
-
4
-
5
- def set_nonvisual_material(
6
- path: str,
7
- base: str,
8
- coating: str = "none",
9
- attribute: str = "none",
10
- ) -> int:
11
- """
12
- Set non-visual material properties on all Material prims in a subtree.
13
-
14
- These properties define how objects appear to RTX sensors (LiDAR and Radar).
15
-
16
- Valid base materials:
17
- Metals: aluminum, steel, oxidized_steel, iron, oxidized_iron, silver, brass,
18
- bronze, oxidized_bronze_patina, tin
19
- Polymers: plastic, fiberglass, carbon_fiber, vinyl, plexiglass, pvc, nylon, polyester
20
- Glass: clear_glass, frosted_glass, one_way_mirror, mirror, ceramic_glass
21
- Other: asphalt, concrete, leaf_grass, dead_leaf_grass, rubber, wood, bark,
22
- cardboard, paper, fabric, skin, fur_hair, leather, marble, brick,
23
- stone, gravel, dirt, mud, water, salt_water, snow, ice, calibration_lambertion
24
- Default: none
25
-
26
- Valid coatings: none, paint, clearcoat, paint_clearcoat
27
-
28
- Valid attributes: none, emissive, retroreflective, single_sided, visually_transparent
29
-
30
- Example:
31
- # Make a person visible to radar/lidar with skin material
32
- count = set_nonvisual_material("/World/person", base="skin")
33
-
34
- # Make a car with aluminum body and paint coating
35
- count = set_nonvisual_material("/World/car", base="aluminum", coating="paint")
36
-
37
- :param path: USD path of the root prim to configure.
38
- :param base: Base material type.
39
- :param coating: Coating type.
40
- :param attribute: Material attribute.
41
- :return: Number of Material prims modified.
42
- """
43
-
44
- response = Session.get_current().query_sim_rpc(
45
- endpoint="set_nonvisual_material",
46
- payload=SetNonVisualMaterial(
47
- path=path,
48
- base=base,
49
- coating=coating,
50
- attribute=attribute,
51
- ),
52
- response_type=SetNonVisualMaterialResponse,
53
- )
54
- return response.materials_modified
@@ -1,131 +0,0 @@
1
- from antioch.session.session import Session, SessionContainer
2
- from common.message import Pose, RadarScan
3
- from common.session.views.radar import (
4
- AddRadar,
5
- GetRadar,
6
- GetRadarResponse,
7
- GetRadarScan,
8
- RadarConfig,
9
- SetRadarDebugMode,
10
- SetRadarMaterial,
11
- )
12
-
13
-
14
- class Radar(SessionContainer):
15
- """
16
- Radar view for time-synchronized scan data.
17
-
18
- Example:
19
- scene = Scene()
20
- radar = scene.get_radar(name="my_ark/my_module/my_radar")
21
- scan = radar.get_scan()
22
- """
23
-
24
- def __init__(self, path: str):
25
- """
26
- Initialize Radar view.
27
-
28
- :param path: USD path for the radar.
29
- """
30
-
31
- super().__init__()
32
-
33
- self._path = self._session.query_sim_rpc(
34
- endpoint="get_radar",
35
- payload=GetRadar(path=path),
36
- response_type=GetRadarResponse,
37
- ).path
38
-
39
- @classmethod
40
- def add(
41
- cls,
42
- path: str,
43
- config: RadarConfig,
44
- world_pose: Pose | None,
45
- local_pose: Pose | None,
46
- ) -> "Radar":
47
- """
48
- Add radar to the scene.
49
-
50
- :param path: USD path for the radar.
51
- :param config: Radar configuration.
52
- :param world_pose: Optional world pose.
53
- :param local_pose: Optional local pose.
54
- :return: The radar instance.
55
- """
56
-
57
- Session.get_current().query_sim_rpc(
58
- endpoint="add_radar",
59
- payload=AddRadar(
60
- path=path,
61
- config=config,
62
- world_pose=world_pose,
63
- local_pose=local_pose,
64
- ),
65
- )
66
- return cls(path)
67
-
68
- def get_scan(self) -> RadarScan | None:
69
- """
70
- Get radar scan data.
71
-
72
- :return: Radar scan with detections, or None if scan data is not ready.
73
- """
74
-
75
- scan = self._session.query_sim_rpc(
76
- endpoint="get_radar_scan",
77
- payload=GetRadarScan(path=self._path),
78
- response_type=RadarScan,
79
- )
80
-
81
- return scan
82
-
83
- def set_debug_mode(self, enabled: bool) -> None:
84
- """
85
- Enable or disable debug visualization.
86
-
87
- :param enabled: Whether to enable debug visualization.
88
- """
89
-
90
- self._session.query_sim_rpc(
91
- endpoint="set_radar_debug_mode",
92
- payload=SetRadarDebugMode(path=self._path, enabled=enabled),
93
- )
94
-
95
-
96
- def set_radar_material(
97
- path: str,
98
- reflectivity: float | None = None,
99
- metallic: float | None = None,
100
- roughness: float | None = None,
101
- backscattering: float | None = None,
102
- cross_section: float | None = None,
103
- ) -> None:
104
- """
105
- Set radar-specific material properties on a prim and all prims in its subtree.
106
-
107
- These properties define how the prim appears to radar sensors.
108
-
109
- Example:
110
- # Make a target highly reflective to radar
111
- set_radar_material("/World/car", reflectivity=0.9, metallic=1.0)
112
-
113
- :param path: USD path of the prim to configure.
114
- :param reflectivity: Radar reflectivity (0-1).
115
- :param metallic: Metallic property (0-1).
116
- :param roughness: Surface roughness (0-1).
117
- :param backscattering: Backscattering coefficient.
118
- :param cross_section: Radar cross section in dBsm.
119
- """
120
-
121
- Session.get_current().query_sim_rpc(
122
- endpoint="set_radar_material",
123
- payload=SetRadarMaterial(
124
- path=path,
125
- reflectivity=reflectivity,
126
- metallic=metallic,
127
- roughness=roughness,
128
- backscattering=backscattering,
129
- cross_section=cross_section,
130
- ),
131
- )