antioch-py 2.2.4__py3-none-any.whl → 3.0.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.
- antioch/__init__.py +101 -0
- antioch/{module/execution.py → execution.py} +1 -1
- antioch/{module/input.py → input.py} +2 -4
- antioch/{module/module.py → module.py} +17 -34
- antioch/{module/node.py → node.py} +17 -16
- {antioch_py-2.2.4.dist-info → antioch_py-3.0.0.dist-info}/METADATA +8 -11
- antioch_py-3.0.0.dist-info/RECORD +61 -0
- {antioch_py-2.2.4.dist-info → antioch_py-3.0.0.dist-info}/WHEEL +1 -1
- antioch_py-3.0.0.dist-info/licenses/LICENSE +21 -0
- common/ark/__init__.py +6 -16
- common/ark/ark.py +23 -62
- common/ark/hardware.py +1 -1
- common/ark/kinematics.py +1 -1
- common/ark/module.py +22 -0
- common/ark/node.py +46 -3
- common/ark/scheduler.py +2 -29
- common/ark/sim.py +1 -1
- {antioch/module → common/ark}/token.py +17 -0
- common/assets/rigging.usd +0 -0
- common/constants.py +63 -5
- common/core/__init__.py +37 -24
- common/core/auth.py +87 -112
- common/core/container.py +261 -0
- common/core/registry.py +131 -152
- common/core/rome.py +251 -0
- common/core/telemetry.py +176 -0
- common/core/types.py +219 -0
- common/message/__init__.py +19 -5
- common/message/annotation.py +174 -23
- common/message/array.py +25 -1
- common/message/camera.py +23 -1
- common/message/color.py +32 -6
- common/message/detection.py +40 -0
- common/message/foxglove.py +20 -0
- common/message/frame.py +71 -7
- common/message/image.py +58 -9
- common/message/imu.py +24 -4
- common/message/joint.py +69 -10
- common/message/log.py +52 -7
- common/message/pir.py +23 -8
- common/message/plot.py +57 -0
- common/message/point.py +55 -6
- common/message/point_cloud.py +55 -19
- common/message/pose.py +59 -19
- common/message/quaternion.py +105 -92
- common/message/radar.py +195 -29
- common/message/twist.py +34 -0
- common/message/types.py +40 -5
- common/message/vector.py +180 -245
- common/sim/__init__.py +49 -0
- common/{session/config.py → sim/objects.py} +97 -27
- common/sim/state.py +11 -0
- common/utils/comms.py +30 -12
- common/utils/logger.py +26 -7
- antioch/message.py +0 -87
- antioch/module/__init__.py +0 -53
- antioch/session/__init__.py +0 -152
- antioch/session/ark.py +0 -500
- antioch/session/asset.py +0 -65
- antioch/session/error.py +0 -80
- antioch/session/objects/__init__.py +0 -40
- antioch/session/objects/animation.py +0 -162
- antioch/session/objects/articulation.py +0 -180
- antioch/session/objects/basis_curve.py +0 -180
- antioch/session/objects/camera.py +0 -65
- antioch/session/objects/collision.py +0 -46
- antioch/session/objects/geometry.py +0 -58
- antioch/session/objects/ground_plane.py +0 -48
- antioch/session/objects/imu.py +0 -53
- antioch/session/objects/joint.py +0 -49
- antioch/session/objects/light.py +0 -123
- antioch/session/objects/pir_sensor.py +0 -102
- antioch/session/objects/radar.py +0 -62
- antioch/session/objects/rigid_body.py +0 -197
- antioch/session/objects/xform.py +0 -119
- antioch/session/record.py +0 -158
- antioch/session/scene.py +0 -1544
- antioch/session/session.py +0 -211
- antioch/session/task.py +0 -309
- antioch_py-2.2.4.dist-info/RECORD +0 -85
- antioch_py-2.2.4.dist-info/entry_points.txt +0 -2
- common/core/agent.py +0 -324
- common/core/task.py +0 -36
- common/message/velocity.py +0 -11
- common/rome/__init__.py +0 -9
- common/rome/client.py +0 -435
- common/rome/error.py +0 -16
- common/session/__init__.py +0 -31
- common/session/environment.py +0 -31
- common/session/sim.py +0 -129
- common/utils/usd.py +0 -12
- /antioch/{module/clock.py → clock.py} +0 -0
- {antioch_py-2.2.4.dist-info → antioch_py-3.0.0.dist-info}/top_level.txt +0 -0
- /common/message/{base.py → message.py} +0 -0
common/sim/__init__.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from common.sim.objects import (
|
|
2
|
+
ArticulationConfig,
|
|
3
|
+
ArticulationJointConfig,
|
|
4
|
+
BasisCurveConfig,
|
|
5
|
+
BodyType,
|
|
6
|
+
CameraConfig,
|
|
7
|
+
CameraMode,
|
|
8
|
+
DistortionModel,
|
|
9
|
+
GeometryConfig,
|
|
10
|
+
GeometryType,
|
|
11
|
+
GroundPlaneConfig,
|
|
12
|
+
ImuConfig,
|
|
13
|
+
JointAxis,
|
|
14
|
+
JointConfig,
|
|
15
|
+
JointType,
|
|
16
|
+
LightConfig,
|
|
17
|
+
LightType,
|
|
18
|
+
MeshApproximation,
|
|
19
|
+
PirSensorConfig,
|
|
20
|
+
RadarConfig,
|
|
21
|
+
RadarScanParams,
|
|
22
|
+
RigidBodyConfig,
|
|
23
|
+
)
|
|
24
|
+
from common.sim.state import SimulationState
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"ArticulationConfig",
|
|
28
|
+
"ArticulationJointConfig",
|
|
29
|
+
"BasisCurveConfig",
|
|
30
|
+
"BodyType",
|
|
31
|
+
"CameraConfig",
|
|
32
|
+
"CameraMode",
|
|
33
|
+
"DistortionModel",
|
|
34
|
+
"GeometryConfig",
|
|
35
|
+
"GeometryType",
|
|
36
|
+
"GroundPlaneConfig",
|
|
37
|
+
"ImuConfig",
|
|
38
|
+
"JointAxis",
|
|
39
|
+
"JointConfig",
|
|
40
|
+
"JointType",
|
|
41
|
+
"LightConfig",
|
|
42
|
+
"LightType",
|
|
43
|
+
"MeshApproximation",
|
|
44
|
+
"PirSensorConfig",
|
|
45
|
+
"RadarConfig",
|
|
46
|
+
"RadarScanParams",
|
|
47
|
+
"RigidBodyConfig",
|
|
48
|
+
"SimulationState",
|
|
49
|
+
]
|
|
@@ -196,14 +196,19 @@ class JointAxis(str, Enum):
|
|
|
196
196
|
class JointConfig(Message):
|
|
197
197
|
"""
|
|
198
198
|
Configuration for a joint object that connects two bodies.
|
|
199
|
+
|
|
200
|
+
The joint pivot point is defined by two local poses:
|
|
201
|
+
- parent_pose: Position/orientation of joint in parent's local frame.
|
|
202
|
+
- child_pose: Position/orientation of joint in child's local frame.
|
|
199
203
|
"""
|
|
200
204
|
|
|
201
205
|
# Joint relationships
|
|
202
206
|
parent_path: str = Field(description="USD path to parent body")
|
|
203
207
|
child_path: str = Field(description="USD path to child body")
|
|
204
208
|
|
|
205
|
-
#
|
|
206
|
-
pose: Pose = Field(default_factory=Pose.identity, description="Joint pose
|
|
209
|
+
# Transforms - defines where joint attaches on each body
|
|
210
|
+
pose: Pose = Field(default_factory=Pose.identity, description="Joint pose in parent's local frame")
|
|
211
|
+
child_pose: Pose = Field(default_factory=Pose.identity, description="Joint pose in child's local frame")
|
|
207
212
|
|
|
208
213
|
# Joint properties
|
|
209
214
|
joint_type: JointType = Field(default=JointType.FIXED, description="Type of joint motion allowed")
|
|
@@ -269,7 +274,7 @@ class LightConfig(Message):
|
|
|
269
274
|
|
|
270
275
|
light_type: LightType = Field(default=LightType.SPHERE, description="Light type")
|
|
271
276
|
intensity: float = Field(default=30000.0, description="Light intensity")
|
|
272
|
-
exposure: float = Field(default=
|
|
277
|
+
exposure: float = Field(default=0.0, description="Light exposure")
|
|
273
278
|
color: Vector3 = Field(default_factory=Vector3.ones, description="RGB color (0-1)")
|
|
274
279
|
radius: float = Field(default=0.1, description="Radius for sphere lights (meters)")
|
|
275
280
|
width: float | None = Field(default=None, description="Width for rect lights (meters)")
|
|
@@ -286,7 +291,7 @@ class GroundPlaneConfig(Message):
|
|
|
286
291
|
|
|
287
292
|
size: float = Field(default=5000.0, description="Size of the ground plane in meters")
|
|
288
293
|
z_position: float = Field(default=0.0, description="Z position of the ground plane")
|
|
289
|
-
color: Vector3 = Field(
|
|
294
|
+
color: Vector3 = Field(default_factory=lambda: Vector3(x=0.5, y=0.5, z=0.5), description="RGB color (0-1)")
|
|
290
295
|
static_friction: float = Field(default=0.5, description="Static friction coefficient")
|
|
291
296
|
dynamic_friction: float = Field(default=0.5, description="Dynamic friction coefficient")
|
|
292
297
|
restitution: float = Field(default=0.0, description="Restitution (bounciness)")
|
|
@@ -303,39 +308,82 @@ class ImuConfig(Message):
|
|
|
303
308
|
orientation_filter_size: int = Field(default=10, description="Filter window size for orientation")
|
|
304
309
|
|
|
305
310
|
|
|
306
|
-
class
|
|
311
|
+
class RadarScanParams(Message):
|
|
307
312
|
"""
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
All parameters can be customized with sensible defaults provided.
|
|
313
|
+
Per-scan configuration for RTX radar.
|
|
311
314
|
"""
|
|
312
315
|
|
|
313
|
-
# Core sensor parameters
|
|
314
|
-
frequency: int = Field(default=10, description="Sensor update frequency in Hz")
|
|
315
|
-
|
|
316
|
-
# Field of view (degrees from center, so total FOV is 2x these values)
|
|
317
316
|
max_azimuth: float = Field(default=66.0, description="Maximum azimuth angle in degrees (±FOV from center)")
|
|
318
317
|
max_elevation: float = Field(default=20.0, description="Maximum elevation angle in degrees (±FOV from center)")
|
|
319
318
|
|
|
320
|
-
# Range parameters
|
|
321
319
|
max_range: float = Field(default=200.0, description="Maximum detection range in meters")
|
|
322
320
|
range_resolution: float = Field(default=0.4, description="Range resolution in meters")
|
|
323
321
|
|
|
324
|
-
# Angular resolution at boresight (center of FOV)
|
|
325
322
|
azimuth_resolution: float = Field(default=1.3, description="Azimuth resolution at boresight in degrees")
|
|
326
323
|
elevation_resolution: float = Field(default=5.0, description="Elevation resolution at boresight in degrees")
|
|
327
324
|
|
|
328
|
-
# Noise parameters (standard deviation for Gaussian noise)
|
|
329
325
|
azimuth_noise: float = Field(default=0.0, description="Azimuth measurement noise standard deviation in radians")
|
|
330
326
|
range_noise: float = Field(default=0.0, description="Range measurement noise standard deviation in meters")
|
|
331
327
|
|
|
328
|
+
time_offset_usec: int | None = Field(default=None, description="Time offset from frame time in microseconds")
|
|
329
|
+
vel_resolution: float | None = Field(default=None, description="Velocity resolution in m/s")
|
|
330
|
+
|
|
331
|
+
bins_from_spec: bool = Field(default=False, description="Whether to use bins from spec")
|
|
332
|
+
r_bins: int | None = Field(default=None, description="Number of range bins")
|
|
333
|
+
v_bins: int | None = Field(default=None, description="Number of velocity bins")
|
|
334
|
+
az_bins: int | None = Field(default=None, description="Number of azimuth bins")
|
|
335
|
+
el_bins: int | None = Field(default=None, description="Number of elevation bins")
|
|
336
|
+
|
|
337
|
+
cfar_offset: float | None = Field(default=None, description="CFAR threshold offset multiplier")
|
|
338
|
+
cfar_noise_mean: float | None = Field(default=None, description="CFAR noise mean")
|
|
339
|
+
cfar_noise_sdev: float | None = Field(default=None, description="CFAR noise standard deviation")
|
|
340
|
+
cfar_min_val: float | None = Field(default=None, description="CFAR minimum value threshold")
|
|
341
|
+
|
|
342
|
+
# CFAR window sizes: _t = training cells, _g = guard cells
|
|
343
|
+
cfar_rn_t: int | None = Field(default=None, description="CFAR range training cells")
|
|
344
|
+
cfar_rn_g: int | None = Field(default=None, description="CFAR range guard cells")
|
|
345
|
+
cfar_vn_t: int | None = Field(default=None, description="CFAR velocity training cells")
|
|
346
|
+
cfar_vn_g: int | None = Field(default=None, description="CFAR velocity guard cells")
|
|
347
|
+
cfar_azn_t: int | None = Field(default=None, description="CFAR azimuth training cells")
|
|
348
|
+
cfar_azn_g: int | None = Field(default=None, description="CFAR azimuth guard cells")
|
|
349
|
+
cfar_eln_t: int | None = Field(default=None, description="CFAR elevation training cells")
|
|
350
|
+
cfar_eln_g: int | None = Field(default=None, description="CFAR elevation guard cells")
|
|
351
|
+
|
|
352
|
+
rcs_tuning_coefficients: list[float] | None = Field(
|
|
353
|
+
default=None,
|
|
354
|
+
description="RCS tuning polynomial coefficients [offset, linear, quadratic]",
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
max_vel_mps_sequence: list[float] | None = Field(
|
|
358
|
+
default=None,
|
|
359
|
+
description="Maximum unambiguous velocity sequence in m/s (float array)",
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
class RadarConfig(Message):
|
|
364
|
+
"""
|
|
365
|
+
Configuration for RTX radar sensor.
|
|
366
|
+
"""
|
|
367
|
+
|
|
368
|
+
frequency: int | None = Field(default=10, description="Sensor update frequency in Hz")
|
|
369
|
+
scans: list[RadarScanParams] = Field(default_factory=lambda: [RadarScanParams()], description="Per-scan configuration")
|
|
370
|
+
|
|
371
|
+
cfar_mode: str | None = Field(default=None, description='CFAR mode (e.g. "2D", "4D")')
|
|
372
|
+
antenna_gain_mode: str | None = Field(default=None, description='Antenna gain mode (e.g. "COSINEFALLOFF")')
|
|
373
|
+
instance_time_offset_usec: int | None = Field(default=None, description="Radar instance time offset in microseconds")
|
|
374
|
+
wavelength_mm: float | None = Field(default=None, description="Operational wavelength in mm (e.g. 5.0 for 60GHz, 3.9 for 77GHz)")
|
|
375
|
+
|
|
376
|
+
@property
|
|
377
|
+
def num_scans(self) -> int:
|
|
378
|
+
return len(self.scans)
|
|
379
|
+
|
|
332
380
|
|
|
333
381
|
class PirSensorConfig(Message):
|
|
334
382
|
"""
|
|
335
383
|
Configuration for PIR (Passive Infrared) motion sensor.
|
|
336
384
|
|
|
337
385
|
PIR sensors detect infrared radiation changes caused by moving warm objects.
|
|
338
|
-
|
|
386
|
+
Each PIR prim represents a single sensor (single-sensor model).
|
|
339
387
|
"""
|
|
340
388
|
|
|
341
389
|
# Core sensor parameters
|
|
@@ -343,23 +391,15 @@ class PirSensorConfig(Message):
|
|
|
343
391
|
max_range: float = Field(default=20.0, description="Maximum detection range in meters")
|
|
344
392
|
|
|
345
393
|
# FOV configuration
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
sensor_center_fov_deg: float = Field(default=45.0, description="Horizontal FOV for center sensor")
|
|
394
|
+
horiz_fov_deg: float = Field(default=150.0, description="Horizontal field-of-view in degrees")
|
|
395
|
+
vert_fov_deg: float = Field(default=60.0, description="Vertical field-of-view in degrees (symmetric)")
|
|
349
396
|
|
|
350
397
|
# Ray configuration
|
|
351
398
|
sensor_rays_horiz: int = Field(default=128, description="Number of rays per sensor in horizontal direction")
|
|
352
399
|
sensor_rays_vert: int = Field(default=16, description="Number of rays per sensor in vertical direction")
|
|
353
400
|
|
|
354
|
-
# Sensor vertical angle range
|
|
355
|
-
min_vertical_angle_center: float = Field(default=-30.0, description="Minimum vertical angle for center sensor in degrees")
|
|
356
|
-
max_vertical_angle_center: float = Field(default=30.0, description="Maximum vertical angle for center sensor in degrees")
|
|
357
|
-
min_vertical_angle_side: float = Field(default=-30.0, description="Minimum vertical angle for side sensors in degrees")
|
|
358
|
-
max_vertical_angle_side: float = Field(default=30.0, description="Maximum vertical angle for side sensors in degrees")
|
|
359
|
-
|
|
360
401
|
# DSP / electronics parameters
|
|
361
|
-
|
|
362
|
-
gain_sides: float = Field(default=0.01, description="Amplifier gain for side sensors")
|
|
402
|
+
gain: float = Field(default=0.015, description="Amplifier gain")
|
|
363
403
|
hp_corner_hz: float = Field(default=0.4, description="High-pass filter corner frequency in Hz")
|
|
364
404
|
lp_corner_hz: float = Field(default=10.0, description="Low-pass filter corner frequency in Hz")
|
|
365
405
|
blind_time_s: float = Field(default=0.5, description="Blind time after detection in seconds")
|
|
@@ -388,3 +428,33 @@ class PirSensorConfig(Message):
|
|
|
388
428
|
target_distance: float = Field(default=5.0, description="Target distance for threshold calibration in meters")
|
|
389
429
|
target_emissivity: float = Field(default=0.98, description="Target emissivity for threshold calibration")
|
|
390
430
|
target_velocity_mps: float = Field(default=1.0, description="Target velocity for threshold calibration in m/s")
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
class BasisCurveConfig(Message):
|
|
434
|
+
"""
|
|
435
|
+
Configuration for creating basis curves in simulation.
|
|
436
|
+
|
|
437
|
+
Supports two curve types:
|
|
438
|
+
- semi_circle: Creates an arc around a center point
|
|
439
|
+
- line: Creates a straight line between two points
|
|
440
|
+
"""
|
|
441
|
+
|
|
442
|
+
# Curve type
|
|
443
|
+
curve_type: str = Field(default="line", description="Type of curve: 'semi_circle' or 'line'")
|
|
444
|
+
|
|
445
|
+
# Common parameters
|
|
446
|
+
guide: bool = Field(default=False, description="If True, curve is invisible to cameras")
|
|
447
|
+
color: Vector3 | None = Field(default=None, description="RGB color (0-1 range)")
|
|
448
|
+
width: float = Field(default=0.005, description="Width of the curve")
|
|
449
|
+
|
|
450
|
+
# Semi-circle parameters
|
|
451
|
+
center: Vector3 | None = Field(default=None, description="Center point for semi-circle")
|
|
452
|
+
radius: float | None = Field(default=None, description="Radius for semi-circle")
|
|
453
|
+
min_angle_deg: float | None = Field(default=None, description="Start angle in degrees for semi-circle")
|
|
454
|
+
max_angle_deg: float | None = Field(default=None, description="End angle in degrees for semi-circle")
|
|
455
|
+
|
|
456
|
+
# Line parameters (either end point OR angle_deg+length)
|
|
457
|
+
start: Vector3 | None = Field(default=None, description="Start point for line")
|
|
458
|
+
end: Vector3 | None = Field(default=None, description="End point for line")
|
|
459
|
+
angle_deg: float | None = Field(default=None, description="Angle in degrees for line (from start)")
|
|
460
|
+
length: float | None = Field(default=None, description="Length for line (with angle_deg)")
|
common/sim/state.py
ADDED
common/utils/comms.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import os
|
|
4
3
|
from collections.abc import Callable
|
|
5
4
|
from threading import Event
|
|
6
5
|
from typing import Any, TypeVar
|
|
7
6
|
|
|
8
7
|
import zenoh
|
|
9
8
|
|
|
9
|
+
from common.constants import SHM_ENABLED, SHM_MESSAGE_SIZE_THRESHOLD_BYTES, SHM_POOL_SIZE_BYTES
|
|
10
10
|
from common.message import Message
|
|
11
11
|
|
|
12
12
|
DEFAULT_COMMS_SUBSCRIBER_RING_DEPTH = 4096
|
|
@@ -25,16 +25,38 @@ class CommsSession:
|
|
|
25
25
|
def __init__(self):
|
|
26
26
|
"""
|
|
27
27
|
Create a new communication session.
|
|
28
|
-
"""
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
Uses peer mode with multicast discovery on the loopback interface for
|
|
30
|
+
automatic peer discovery without requiring a router.
|
|
31
|
+
"""
|
|
32
32
|
|
|
33
33
|
self.config = zenoh.Config()
|
|
34
|
+
|
|
35
|
+
# Enable peer mode (no Zenoh router)
|
|
34
36
|
self.config.insert_json5("mode", '"peer"')
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
self.config.insert_json5("
|
|
37
|
+
|
|
38
|
+
# Enable multicast discovery on loopback interface for peer discovery
|
|
39
|
+
self.config.insert_json5("scouting/multicast/enabled", "true")
|
|
40
|
+
self.config.insert_json5("scouting/multicast/interface", '"lo"')
|
|
41
|
+
self.config.insert_json5("listen/endpoints", '["tcp/127.0.0.1:0"]')
|
|
42
|
+
|
|
43
|
+
# Enable shared memory transport for high-performance IPC
|
|
44
|
+
# Falls back to TCP automatically when SHM is not available
|
|
45
|
+
if SHM_ENABLED:
|
|
46
|
+
self.config.insert_json5("transport/shared_memory/enabled", "true")
|
|
47
|
+
self.config.insert_json5(
|
|
48
|
+
"transport/shared_memory/transport_optimization/enabled",
|
|
49
|
+
"true",
|
|
50
|
+
)
|
|
51
|
+
self.config.insert_json5(
|
|
52
|
+
"transport/shared_memory/transport_optimization/pool_size",
|
|
53
|
+
str(SHM_POOL_SIZE_BYTES),
|
|
54
|
+
)
|
|
55
|
+
self.config.insert_json5(
|
|
56
|
+
"transport/shared_memory/transport_optimization/message_size_threshold",
|
|
57
|
+
str(SHM_MESSAGE_SIZE_THRESHOLD_BYTES),
|
|
58
|
+
)
|
|
59
|
+
|
|
38
60
|
self.session = zenoh.open(self.config)
|
|
39
61
|
|
|
40
62
|
def __del__(self) -> None:
|
|
@@ -91,11 +113,7 @@ class CommsSession:
|
|
|
91
113
|
|
|
92
114
|
return CommsAsyncSubscriber(self.session, path)
|
|
93
115
|
|
|
94
|
-
def declare_callback_subscriber(
|
|
95
|
-
self,
|
|
96
|
-
path: str,
|
|
97
|
-
callback: Callable[[zenoh.Sample], None],
|
|
98
|
-
) -> zenoh.Subscriber[None]:
|
|
116
|
+
def declare_callback_subscriber(self, path: str, callback: Callable[[zenoh.Sample], None]) -> zenoh.Subscriber[None]:
|
|
99
117
|
"""
|
|
100
118
|
Create a new callback subscriber for the given path.
|
|
101
119
|
|
common/utils/logger.py
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
1
3
|
from common.message import Log, LogLevel, Message
|
|
2
4
|
from common.utils.comms import CommsSession
|
|
3
5
|
|
|
6
|
+
# Valid channel pattern: alphanumeric, underscore, hyphen, period, slash
|
|
7
|
+
# Must start with alphanumeric, cannot have consecutive slashes or end with slash
|
|
8
|
+
CHANNEL_PATTERN = re.compile(r"^[a-zA-Z0-9](?:[a-zA-Z0-9_.\-]*(?:/[a-zA-Z0-9][a-zA-Z0-9_.\-]*)*)?$")
|
|
9
|
+
|
|
4
10
|
|
|
5
11
|
class Logger:
|
|
6
12
|
"""
|
|
7
13
|
Logger that publishes structured logs to the communication system.
|
|
14
|
+
|
|
15
|
+
Creates its own Zenoh session for publishing logs.
|
|
8
16
|
"""
|
|
9
17
|
|
|
10
18
|
def __init__(
|
|
11
19
|
self,
|
|
12
|
-
comms: CommsSession,
|
|
13
20
|
base_channel: str | None = None,
|
|
14
21
|
debug: bool = False,
|
|
15
|
-
print_logs: bool =
|
|
22
|
+
print_logs: bool = True,
|
|
16
23
|
) -> None:
|
|
17
24
|
"""
|
|
18
25
|
Initialize the logger.
|
|
19
26
|
|
|
20
|
-
:param comms: Comms session.
|
|
21
27
|
:param base_channel: Optional base channel for logs and telemetry.
|
|
22
28
|
:param debug: Whether to run in debug mode.
|
|
23
29
|
:param print_logs: Whether to print logs to stdout.
|
|
24
30
|
"""
|
|
25
31
|
|
|
26
|
-
self.
|
|
32
|
+
self._comms = CommsSession()
|
|
33
|
+
self._log_publisher = self._comms.declare_publisher("_logs")
|
|
27
34
|
self._base_channel = base_channel
|
|
28
35
|
self._debug = debug
|
|
29
36
|
self._print_logs = print_logs
|
|
@@ -79,12 +86,16 @@ class Logger:
|
|
|
79
86
|
"""
|
|
80
87
|
Record telemetry data from a Message or a JSON-serializable dictionary.
|
|
81
88
|
|
|
82
|
-
:param channel: Telemetry channel (alphanumeric
|
|
89
|
+
:param channel: Telemetry channel (alphanumeric with underscore/hyphen/period/slash).
|
|
83
90
|
:param telemetry: The message or dict to record.
|
|
91
|
+
:raises ValueError: If channel format is invalid.
|
|
84
92
|
"""
|
|
85
93
|
|
|
86
|
-
if not
|
|
87
|
-
raise ValueError(
|
|
94
|
+
if not CHANNEL_PATTERN.match(channel):
|
|
95
|
+
raise ValueError(
|
|
96
|
+
f"Invalid channel '{channel}': must be alphanumeric with underscore/hyphen/period/slash, "
|
|
97
|
+
"start and end with alphanumeric, no consecutive slashes"
|
|
98
|
+
)
|
|
88
99
|
|
|
89
100
|
# Pack telemetry data based on type
|
|
90
101
|
if isinstance(telemetry, Message):
|
|
@@ -102,6 +113,14 @@ class Logger:
|
|
|
102
113
|
)
|
|
103
114
|
)
|
|
104
115
|
|
|
116
|
+
def close(self) -> None:
|
|
117
|
+
"""
|
|
118
|
+
Close the logger and release resources.
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
self._log_publisher.close()
|
|
122
|
+
self._comms.close()
|
|
123
|
+
|
|
105
124
|
def _log(self, level: LogLevel, message: str) -> None:
|
|
106
125
|
"""
|
|
107
126
|
Send a log message through Zenoh.
|
antioch/message.py
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
from common.message import (
|
|
2
|
-
Array,
|
|
3
|
-
Bool,
|
|
4
|
-
CameraInfo,
|
|
5
|
-
CircleAnnotation,
|
|
6
|
-
Color,
|
|
7
|
-
DeserializationError,
|
|
8
|
-
Float,
|
|
9
|
-
FrameTransform,
|
|
10
|
-
FrameTransforms,
|
|
11
|
-
Image,
|
|
12
|
-
ImageAnnotations,
|
|
13
|
-
ImageEncoding,
|
|
14
|
-
Int,
|
|
15
|
-
JointState,
|
|
16
|
-
JointStates,
|
|
17
|
-
JointTarget,
|
|
18
|
-
JointTargets,
|
|
19
|
-
Log,
|
|
20
|
-
LogLevel,
|
|
21
|
-
Message,
|
|
22
|
-
MessageError,
|
|
23
|
-
MismatchError,
|
|
24
|
-
Point2,
|
|
25
|
-
Point3,
|
|
26
|
-
PointCloud,
|
|
27
|
-
PointsAnnotation,
|
|
28
|
-
PointsAnnotationType,
|
|
29
|
-
Pose,
|
|
30
|
-
Quaternion,
|
|
31
|
-
RadarDetection,
|
|
32
|
-
RadarScan,
|
|
33
|
-
SerializationError,
|
|
34
|
-
String,
|
|
35
|
-
TextAnnotation,
|
|
36
|
-
Vector2,
|
|
37
|
-
Vector3,
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
__all__ = [
|
|
41
|
-
# Base types
|
|
42
|
-
"Message",
|
|
43
|
-
"MessageError",
|
|
44
|
-
"DeserializationError",
|
|
45
|
-
"SerializationError",
|
|
46
|
-
"MismatchError",
|
|
47
|
-
# Primitive types
|
|
48
|
-
"Array",
|
|
49
|
-
"Bool",
|
|
50
|
-
"Float",
|
|
51
|
-
"Int",
|
|
52
|
-
"String",
|
|
53
|
-
# Geometry types
|
|
54
|
-
"Point2",
|
|
55
|
-
"Point3",
|
|
56
|
-
"Vector2",
|
|
57
|
-
"Vector3",
|
|
58
|
-
"Pose",
|
|
59
|
-
"Quaternion",
|
|
60
|
-
# Color
|
|
61
|
-
"Color",
|
|
62
|
-
# Camera types
|
|
63
|
-
"CameraInfo",
|
|
64
|
-
"Image",
|
|
65
|
-
"ImageEncoding",
|
|
66
|
-
# Joint types
|
|
67
|
-
"JointState",
|
|
68
|
-
"JointStates",
|
|
69
|
-
"JointTarget",
|
|
70
|
-
"JointTargets",
|
|
71
|
-
# Sensor types
|
|
72
|
-
"RadarDetection",
|
|
73
|
-
"RadarScan",
|
|
74
|
-
"PointCloud",
|
|
75
|
-
# Logging
|
|
76
|
-
"Log",
|
|
77
|
-
"LogLevel",
|
|
78
|
-
# Annotations
|
|
79
|
-
"CircleAnnotation",
|
|
80
|
-
"ImageAnnotations",
|
|
81
|
-
"PointsAnnotation",
|
|
82
|
-
"PointsAnnotationType",
|
|
83
|
-
"TextAnnotation",
|
|
84
|
-
# Frame transforms
|
|
85
|
-
"FrameTransform",
|
|
86
|
-
"FrameTransforms",
|
|
87
|
-
]
|
antioch/module/__init__.py
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
from antioch.module.clock import Clock, now_us
|
|
2
|
-
from antioch.module.execution import Execution, Input, Output
|
|
3
|
-
from antioch.module.module import Module
|
|
4
|
-
from antioch.module.token import Token, TokenType
|
|
5
|
-
from common.ark import Environment, HardwareAccessMode
|
|
6
|
-
from common.message import (
|
|
7
|
-
CameraInfo,
|
|
8
|
-
Image,
|
|
9
|
-
ImageEncoding,
|
|
10
|
-
ImuSample,
|
|
11
|
-
JointState,
|
|
12
|
-
JointStates,
|
|
13
|
-
JointTarget,
|
|
14
|
-
JointTargets,
|
|
15
|
-
Message,
|
|
16
|
-
Pose,
|
|
17
|
-
Quaternion,
|
|
18
|
-
RadarDetection,
|
|
19
|
-
RadarScan,
|
|
20
|
-
Vector3,
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
__all__ = [
|
|
24
|
-
# Core module types
|
|
25
|
-
"Module",
|
|
26
|
-
"Execution",
|
|
27
|
-
"Input",
|
|
28
|
-
"Output",
|
|
29
|
-
# Token types
|
|
30
|
-
"Token",
|
|
31
|
-
"TokenType",
|
|
32
|
-
# Timing
|
|
33
|
-
"Clock",
|
|
34
|
-
"now_us",
|
|
35
|
-
# Enums
|
|
36
|
-
"Environment",
|
|
37
|
-
"HardwareAccessMode",
|
|
38
|
-
# Message types
|
|
39
|
-
"Message",
|
|
40
|
-
"CameraInfo",
|
|
41
|
-
"Image",
|
|
42
|
-
"ImageEncoding",
|
|
43
|
-
"ImuSample",
|
|
44
|
-
"JointState",
|
|
45
|
-
"JointStates",
|
|
46
|
-
"JointTarget",
|
|
47
|
-
"JointTargets",
|
|
48
|
-
"Pose",
|
|
49
|
-
"Quaternion",
|
|
50
|
-
"RadarDetection",
|
|
51
|
-
"RadarScan",
|
|
52
|
-
"Vector3",
|
|
53
|
-
]
|