TrajectoryData
Represents a generic trajectory composed of metadata and multiple JointTrajectoryPoint instances.
Properties:
Property | Type | Description |
|---|---|---|
|
| Trajectory metadata |
|
| List of trajectory points |
Read-only properties:
Property | Type | Description |
|---|---|---|
|
| Trajectory ID, equivalent to |
|
| Joint names in the trajectory, taken from the first point |
|
| Total trajectory duration; seconds can be read via |
TrajectoryData
Signature:
TrajectoryData(
*,
meta: TrajectoryMeta | None = None,
points: list[JointTrajectoryPoint] | None = None,
)
Description:
Constructs a TrajectoryData instance. All parameters must be passed as keyword arguments.
Parameters:
Parameter | Type | Required | Description |
|---|---|---|---|
|
| No | Trajectory metadata; defaults to empty metadata if not provided |
|
| No | Trajectory point list; defaults to empty list if not provided |
Returns:
TrajectoryData instance.
Raises:
None.
save
Signature:
TrajectoryData.save(path: str | PathLike[str]) -> None
Description:
Saves the trajectory as a .btraj trajectory package; the package contains only meta.json and data.json.
Parameters:
Parameter | Type | Required | Description |
|---|---|---|---|
|
| Yes | Output file path, must end with |
Returns:
None.
Raises:
ValueError: Path suffix is not .btraj.
RuntimeError: File write failed.
load
Signature:
@classmethod
TrajectoryData.load(path: str | PathLike[str]) -> TrajectoryData
Description:
Loads from a .btraj trajectory package and validates, returning a new TrajectoryData instance.
Parameters:
Parameter | Type | Required | Description |
|---|---|---|---|
|
| Yes | Trajectory package path, must end with |
Returns:
TrajectoryData instance.
Raises:
ValueError: Path suffix is not .btraj, or path is not a file.
FileNotFoundError: File does not exist.
RuntimeError: Package is not a valid .btraj, JSON parsing failed, metadata missing fields, or trajectory validation failed.
to_numpy
Signature:
TrajectoryData.to_numpy() -> dict[str, Any]
Description:
Exports the trajectory in numpy array format, convenient for analysis or editing. The returned dictionary contains:
meta: originalTrajectoryMetajoint_names:list[str]times:np.ndarray,time_from_start.secondsper framepositions:np.ndarray, shape(n_frames, n_joints), missing values filled withnp.nanvelocities/accelerations/efforts: optional, output when the corresponding field exists in any frame
Parameters:
No parameters.
Returns:
dict[str, Any].
Raises:
None.