Trajectory¶
TimeOptimalParameterizer¶
TimeOptimalParameterizer(max_velocity: np.ndarray, max_acceleration: np.ndarray, max_deviation: float = 0.1, time_step: float = 0.001)
¶
Time-optimal trajectory parameteriser with fixed joint limits.
Instantiate once per robot (limits are cached), then call
:meth:parameterize on every path. The parameteriser itself holds
no state between calls — it is safe to reuse across threads so long
as the limits do not change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_velocity
|
ndarray
|
|
required |
max_acceleration
|
ndarray
|
|
required |
max_deviation
|
float
|
Radial tolerance (same unit as the path) for the
circular blend inserted at every interior waypoint. Larger
values make cornering faster but deviate further from the
original piecewise-linear path. Defaults to |
0.1
|
time_step
|
float
|
Forward-integration step along the path. Smaller
values are more accurate and slower; the MoveIt default of
|
0.001
|
Source code in autolife_planning/trajectory/totg.py
parameterize(path: np.ndarray, velocity_scaling: float = 1.0, acceleration_scaling: float = 1.0) -> Trajectory
¶
Convert a piecewise-linear joint-space path into a time-optimal trajectory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
ndarray
|
|
required |
velocity_scaling
|
float
|
Scalar in |
1.0
|
acceleration_scaling
|
float
|
Scalar in |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
Trajectory
|
class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in autolife_planning/trajectory/totg.py
Convenience function¶
parameterize_path(path: np.ndarray, max_velocity: np.ndarray, max_acceleration: np.ndarray, max_deviation: float = 0.1, time_step: float = 0.001) -> Trajectory
¶
One-shot helper that builds a :class:TimeOptimalParameterizer
and immediately calls :meth:parameterize on path.
Prefer the class form when you are going to re-use the limits — it avoids revalidating them on every call.
Source code in autolife_planning/trajectory/totg.py
Trajectory¶
Trajectory(_handle: '_TotgTrajectory')
dataclass
¶
A time-optimal trajectory produced by
:class:~autolife_planning.trajectory.TimeOptimalParameterizer.
Instances are immutable handles around a C++ TOTG state machine;
query them via :meth:position, :meth:velocity,
:meth:acceleration, or one of the batch samplers.
duration: float
property
¶
Trajectory duration in seconds.
position(t: float) -> np.ndarray
¶
Configuration at time t (seconds), clamped to [0, duration].
velocity(t: float) -> np.ndarray
¶
acceleration(t: float) -> np.ndarray
¶
sample(times: np.ndarray) -> tuple[np.ndarray, np.ndarray, np.ndarray]
¶
Sample at the user-supplied times grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
times
|
ndarray
|
|
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray, ndarray]
|
|
Source code in autolife_planning/trajectory/trajectory.py
sample_uniform(dt: float) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]
¶
Uniformly-spaced rollout at step dt.
The returned times always start at 0 and end at
:attr:duration, which may make the final step shorter than
dt — this matches what a streaming controller expects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
float
|
Sample interval in seconds (must be |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
|
ndarray
|
|
ndarray
|
|
Source code in autolife_planning/trajectory/trajectory.py
Low-level C++ binding¶
TotgTrajectory
¶
Opaque handle to a parameterised trajectory.
Queries are C¹-consistent: :meth:position / :meth:velocity /
:meth:acceleration sample a quadratic segment between the
algorithm's internal forward-integration grid points.
duration: float
property
¶
Total duration in seconds.
position(t: float) -> NDArray[np.float64]
¶
velocity(t: float) -> NDArray[np.float64]
¶
acceleration(t: float) -> NDArray[np.float64]
¶
sample(times: NDArray[np.float64]) -> tuple[NDArray[np.float64], NDArray[np.float64], NDArray[np.float64]]
¶
Batched sampling at times — returns (T, ndof) matrices
of (position, velocity, acceleration).
Source code in autolife_planning/_time_parameterization.pyi
sample_uniform(dt: float) -> tuple[NDArray[np.float64], NDArray[np.float64], NDArray[np.float64], NDArray[np.float64]]
¶
Uniform rollout with step dt.
Returns (times, positions, velocities, accelerations).
times starts at 0 and ends at :attr:duration.
Source code in autolife_planning/_time_parameterization.pyi
compute_trajectory(waypoints: NDArray[np.float64], max_velocity: NDArray[np.float64], max_acceleration: NDArray[np.float64], max_deviation: float = ..., time_step: float = 0.001) -> TotgTrajectory | None
¶
Build a time-optimal trajectory for a piecewise-linear path.
Returns None if waypoints has fewer than two rows, the
velocity/acceleration bounds are infeasible, or the integrator
failed (e.g. a 180-degree reversal in the waypoints).