Trajectories¶
shinro.trajectories
Reference path generators for smooth point-to-point motion.
Provides polynomial trajectory generators that compute position, velocity, and acceleration profiles from boundary conditions. All generators support arbitrary N-dimensional positions via numpy broadcasting.
Available generators: CubicPolynomial — 3rd-order, position + velocity continuity QuinticPolynomial — 5th-order, position + velocity + acceleration continuity
CubicPolynomial¶
Bases: TrajectoryGenerator
3rd-order polynomial trajectory generator.
Generates smooth point-to-point trajectories using a cubic polynomial:
The coefficients are computed in closed form (no matrix solve) from boundary conditions on position and velocity at both ends. Acceleration is continuous but NOT constrained at boundaries (use QuinticPolynomial if acceleration constraints are needed).
Supports arbitrary N-dimensional positions via element-wise operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Source code in src/shinro/trajectories/cubic_polynomial.py
generate
¶
Compute cubic polynomial coefficients from boundary conditions.
Closed-form solution:
where \(\Delta p = p_f - p_0\) and \(T =\) duration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_position
|
Initial position vector (N,). |
required | |
end_position
|
Final position vector (N,). |
required | |
duration
|
float
|
Total trajectory time in seconds. |
required |
start_vel
|
Initial velocity vector (N,). |
required | |
end_vel
|
Final velocity vector (N,). |
required |
Source code in src/shinro/trajectories/cubic_polynomial.py
position_at
¶
Evaluate position, velocity, and acceleration at time t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Time in seconds (clipped to [0, duration]). |
required |
Returns:
| Type | Description |
|---|---|
|
Tuple of (position, velocity, acceleration) arrays, each of |
|
|
shape matching the input dimensions (N,). |
Source code in src/shinro/trajectories/cubic_polynomial.py
from_config
classmethod
¶
from_config(config, backend: ArrayBackend | None = None)
Create a waypoint schedule from a TOML config dict or CubicSegmentsConfig.
Config fields
dt: Time step. segments: List of segment dicts, each with: - duration: Segment duration (s). - start: Start position list. - end: End position list. - start_vel: Optional start velocity (default: zeros). - end_vel: Optional end velocity (default: zeros).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
TOML config dict or CubicSegmentsConfig. |
required | |
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Returns:
| Type | Description |
|---|---|
|
Array of shape (total_steps, N) with position waypoints. |
Source code in src/shinro/trajectories/cubic_polynomial.py
QuinticPolynomial¶
Bases: TrajectoryGenerator
5th-order polynomial trajectory generator.
Generates smooth point-to-point trajectories using a quintic polynomial:
Enforces position, velocity, AND acceleration constraints at both start and end (6 boundary conditions → 6 coefficients). When all velocities and accelerations are zero (rest-to-rest), this reduces to the minimum-jerk trajectory:
Solves a 6x6 Vandermonde-like linear system via bk.solve().
Supports arbitrary N-dimensional positions — the right-hand side is
stacked as (6, N) and solved once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Source code in src/shinro/trajectories/quintic_polynomial.py
generate
¶
generate(start_position, end_position, duration: float, start_vel=None, end_vel=None, start_acc=None, end_acc=None)
Compute quintic polynomial coefficients by solving the 6x6 system.
Solves \(M c = b\) where:
Any boundary condition set to None defaults to zero (rest-to-rest).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_position
|
Initial position vector (N,). |
required | |
end_position
|
Final position vector (N,). |
required | |
duration
|
float
|
Total trajectory time in seconds. |
required |
start_vel
|
Initial velocity vector (N,). Defaults to zeros. |
None
|
|
end_vel
|
Final velocity vector (N,). Defaults to zeros. |
None
|
|
start_acc
|
Initial acceleration vector (N,). Defaults to zeros. |
None
|
|
end_acc
|
Final acceleration vector (N,). Defaults to zeros. |
None
|
Source code in src/shinro/trajectories/quintic_polynomial.py
position_at
¶
Evaluate position, velocity, and acceleration at time t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Time in seconds (clipped to [0, T]). |
required |
Returns:
| Type | Description |
|---|---|
|
Tuple of (position, velocity, acceleration) arrays, each of |
|
|
shape matching the input dimensions (N,). |