Agent API
The oceansim_client.agents module provides a typed layer over the existing
TCP protocol. It does not replace the AUV wrapper; it gives experiments a
stable vocabulary for agent definitions, action spaces, and runtime control.
Classes
- class AgentDefinition
Serializable description of a runtime agent.
Field
Meaning
agent_nameStable runtime identifier, for example
auv/mainortarget_01.agent_typeLogical type such as
auvorproxy_auv.is_main_agentWhether the definition binds to the scene-owned AUV or spawns a proxy agent.
profileOptional vehicle or runtime profile name.
location/rotationInitial pose fields.
control_schemeOne of the documented
ControlSchemevalues.sensorsOptional sensor declarations. Entries may be sensor names or dictionaries with
nameandsensor_type.metadataRole, semantic label, tags, and experiment-specific annotations.
- from_dict(data)
Build an
AgentDefinitionfrom a dictionary. The parser accepts common aliases such asid/nameandposition/location.
- to_dict()
Return a versioned dictionary suitable for scenario files or protocol payloads.
- class ActionSpace
Machine-readable action vector contract. It records
shape,fields,units,frame, optional bounds, and a short description.- validate(action)
Validate action length and optional bounds, then return a list of floats.
- class OceanSimAgent
Runtime facade bound to an
OceanSimClientand anAgentDefinition.Method or property
Role
nameRuntime identifier.
control_schemeActive control contract.
action_spaceActionSpacefor the current control scheme.act(action)Validate and dispatch an action through TCP.
clear_action()Send a zero action for the current control scheme.
teleport(location, rotation=None)Reposition the main AUV or dynamic proxy agent.
agent_state_dict()Return a dictionary with definition metadata and the latest state.
- class AgentFactory
Factory for binding definitions to live simulator objects.
- build_agent(client_or_auv, definition, spawn=True)
Accepts either an
OceanSimClientorAUVinstance. Main agents are bound to the existing vehicle; non-main agents can be spawned through the currentspawn_agentprotocol action.
Control schemes
Name |
Fields |
Protocol mapping |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Six-degree body wrench contract |
|
|
Six-degree body velocity contract |
|
|
Reserved protocol extension |
list_control_schemes() returns a machine-readable version of the same
contracts:
from oceansim_client import list_control_schemes
for item in list_control_schemes():
print(item["name"], item["action_space"]["fields"])
Example output:
force_3d ['fx', 'fy', 'fz']
body_force_3d ['fx', 'fy', 'fz']
thrusters ['thruster_0', 'thruster_1', 'thruster_2', 'thruster_3', 'thruster_4', 'thruster_5']
external_velocity ['vx', 'vy', 'vz']
waypoint_pid ['world_x', 'world_z', 'depth']
body_wrench_6dof ['fx', 'fy', 'fz', 'tx', 'ty', 'tz']
body_velocity_6dof ['u', 'v', 'w', 'p', 'q', 'r']
custom_dynamics_6dof ['lin_ax', 'lin_ay', 'lin_az', 'ang_ax', 'ang_ay', 'ang_az']
Bounds and vehicle profiles
ActionSpace supports optional low and high bounds. The default
contracts define shape, fields, units, frame, and description. Bounds are kept
optional because some values depend on the active vehicle profile, actuator
configuration, controller gains, and scenario-specific safety limits.
The recommended rule is:
fixed vector shape, field names, units, and frame live in
oceansim_client.agents.ACTION_SPACES;actuator-specific bounds, rate limits, deadbands, and failure modes should be derived from
vehicle_profiles/*.jsonfields such ascommand_bounds,rate_limit_per_s,deadband,failure_mode, andfailure_scale;experiment-specific safety bounds should be written into scenario metadata or controller configuration.
Vehicle profiles can expose Fossen-style six-degree dynamics metadata for
controller design and export auditing: rigid-body mass matrix, added-mass
matrix, total mass matrix, damping vectors, restoring force/torque
coefficients, Coriolis matrix/state terms, and the thruster allocation matrix.
The runtime/profile field names are documented as rigid_body_mass_matrix,
added_mass_matrix, total_mass_matrix, coriolis_matrix,
coriolis_force_torque_body, restoring_force_torque_body,
restoring_torque_body, and thruster_allocation_matrix.
Field |
Meaning |
|---|---|
|
Per-actuator minimum and maximum normalized command. |
|
Maximum actuator command change per second. |
|
Small command region treated as zero input. |
|
Actuator health model, such as healthy, disabled, stuck, or scaled. |
|
Multiplicative actuator scale used by scaled failure cases. |
|
Six-degree rigid-body mass/inertia matrix from the active profile. |
|
Hydrodynamic added-mass matrix. |
|
Runtime total mass matrix used for reporting and controller design. |
|
Fossen-style Coriolis/centripetal matrix computed from the body velocity. |
|
Body-frame Coriolis force/torque vector. |
|
Body-frame restoring force/torque vector. |
|
Restoring torque slice used by attitude diagnostics. |
|
Matrix mapping actuator directions and locations into body wrench terms. |
Error behavior
Error |
Meaning |
|---|---|
|
Raised by |
|
Raised by |
|
Raised by |
Protocol |
Returned by the simulator for unsupported actions, missing runtime objects, or invalid command payloads. |
Runtime fields
The get_agents protocol response should be treated as a runtime state
envelope. The fields below are the documented contract for UI panels, Python
tools, replay metadata, and downstream controllers.
Field |
Meaning |
|---|---|
|
Runtime state schema version. |
|
Stable runtime identifier. |
|
Agent role and profile name. |
|
Visualization shape, semantic class, and grouping labels. |
|
Runtime pose fields. |
|
Optional quaternion rotation, currently provided by the main AUV. |
|
Runtime velocity summary and optional body angular velocity. |
|
Motion mode and scalar speed summary. |
|
Runtime footprint and whether the entry is a lightweight proxy. |
|
Active control contract. |
|
Shape, fields, units, frame, optional bounds, and main AUV alternatives. |
|
Sensor declarations or summaries. |
|
Runtime diagnostics. |
|
Recordable waypoint/controller diagnostics, including error, integral, target, and saturation where available. |
|
Optional proxy-agent depth limits. |
|
Role, semantic label, tags, and experiment annotations. |
Export trace contract
agent_timeline.jsonl rows include state, command,
sensor_sequences, and frame_trace so a dataset consumer can connect an
agent sample to the command that produced it, the sensor summary recorded with
it, and the world/base/sensor frames used by downstream tools.
Release checks
cd path\to\OceanSim\oceansim\python
python tools\agents_schema_smoke.py
python tools\scenario_agent_schema_smoke.py
cd path\to\OceanSim\oceansim
godot --headless --path . --script res://tools/release_agent_runtime_smoke.gd