Trajectories¶
shinro.trajectories
Reference path generators for smooth point-to-point motion.
Provides polynomial and harmonic 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 Lissajous — odd-harmonic rest-to-rest figure, orientable via R BezierCurve — Bernstein curve over an arbitrary control-point list BSpline — Cox–de Boor B-spline over a knot vector and control polygon CatmullRom — C¹ cubic Hermite through an ordered waypoint list Akima — overshoot-resistant C¹ waypoint spline CubicSpline — natural C² waypoint spline MinSnapPolynomial — 7th-order (minimum-snap) point-to-point CircularArc — analytic circular / helical arc
Sampling helpers:
sample_schedule / sample_segments — stacked (steps, N) position/velocity/
acceleration schedules (the derivatives config opt-in uses them).
Motion limits: limit_trajectory / time_scale_factor — uniform (constant) time scaling: the same path traversed k times slower, for per-component velocity / acceleration limits (TimeScaled). s_curve_limit / s_curve_horizon — min-jerk (S-curve) rest-to-rest time law that also bounds jerk (SCurveScaled).
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) -> Any
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 |
|---|---|
Any
|
Array of shape (total_steps, N) with position waypoints, or — when |
Any
|
|
Any
|
under |
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,). |
Source code in src/shinro/trajectories/quintic_polynomial.py
MinSnapPolynomial¶
Bases: TrajectoryGenerator
7th-order polynomial trajectory, minimum snap when rest-to-rest.
Eight boundary conditions — position, velocity, acceleration, and jerk
at both ends — fix the eight coefficients with one 8x8 bk.solve. With
the free boundary derivatives zero this minimises
\(\int (p''')^2\,\mathrm{d}t\) (snap is \(p''''\)), the 7th-order
sibling of the minimum-jerk quintic:
Jerk is only a boundary condition: position_at returns
(position, velocity, acceleration) like every other generator (the
sampler does not carry a jerk channel).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Source code in src/shinro/trajectories/min_snap.py
generate
¶
generate(start_position, end_position, duration: float, start_vel=None, end_vel=None, start_acc=None, end_acc=None, start_jerk=None, end_jerk=None)
Compute the 7th-order coefficients by solving the 8x8 system.
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, end_vel, start_acc, end_acc, start_jerk, end_jerk
|
Boundary derivatives (N,) or |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/shinro/trajectories/min_snap.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 shape |
|
|
|
Source code in src/shinro/trajectories/min_snap.py
from_config
classmethod
¶
from_config(config, backend: ArrayBackend | None = None) -> Any
Create a waypoint schedule from a TOML config dict or MinSnapConfig.
Config fields
dt: Sampling period (s). start: Initial position (list of floats). end: Final position (list of floats). duration: Trajectory duration (s). start_vel, end_vel, start_acc, end_acc, start_jerk, end_jerk: Optional boundary derivatives (default: zeros). derivatives: Emit the velocity/acceleration dict instead of positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
TOML config dict or MinSnapConfig. |
required | |
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Array of shape (total_steps, N) with position waypoints, or — when |
Any
|
|
Any
|
under |
Source code in src/shinro/trajectories/min_snap.py
Lissajous¶
Bases: TrajectoryGenerator
Lissajous trajectory generator.
Drives every axis through a cosine at an odd-harmonic frequency, giving a
smooth zero-velocity rest-to-rest motion that interpolates start and
end while tracing a Lissajous figure around their midpoint:
with center \(p_0 = (p_f + p_0^\text{start}) / 2\), world amplitude \(A = (\text{start} - \text{end}) / 2\), and local amplitude \(A_\text{local} = R^\top A\).
The per-axis frequencies act on the local frame, so R (a rotation
matrix, world-from-local) orients the figure — mixing axes — while
\(p(0) = p_0 + A = \text{start}\) and \(p(T) = p_0 - A =
\text{end}\) still hold because \(R R^\top = I\). The odd harmonics make
both boundary velocities zero:
Supports arbitrary N-dimensional positions: k has one entry per axis
and R is N x N (or omitted for the identity).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k
|
Per-axis harmonic indices. |
required | |
R
|
Optional |
None
|
|
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Source code in src/shinro/trajectories/lissajous.py
generate
¶
Compute the center, amplitude, and per-axis frequencies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_position
|
One extremum of the oscillation, \(p_0 + A\) (N,). |
required | |
end_position
|
The opposite extremum, \(p_0 - A\) (N,). |
required | |
duration
|
float
|
Trajectory duration \(T\) (s). |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/shinro/trajectories/lissajous.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 |
|
|
|
Source code in src/shinro/trajectories/lissajous.py
from_config
classmethod
¶
from_config(config, backend: ArrayBackend | None = None) -> Any
Create a waypoint schedule from a TOML config dict or LissajousConfig.
Config fields
dt: Sampling period (s). start: One extremum of the oscillation (list of floats). end: The opposite extremum (list of floats). duration: Trajectory duration (s). k: Per-axis harmonic indices. R: Optional rotation matrix (nested list) orienting the figure. Defaults to the identity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
TOML config dict or LissajousConfig. |
required | |
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Array of shape (total_steps, N) with position waypoints, or — when |
Any
|
|
Any
|
under |
Source code in src/shinro/trajectories/lissajous.py
CircularArc¶
Bases: TrajectoryGenerator
Circular arc (optionally helical) around a centre.
With \(R = |\text{start} - c|\), unit in-plane basis \(\hat{u} = (\text{start} - c)/R\) and \(\hat{v} = \hat{n} \times \hat{u}\) (unit normal \(\hat{n}\), \(\hat{u} \perp \hat{n}\)), angular rate \(\omega = \theta_\text{sweep}/T\), and \(\theta(t) = \omega t\):
The speed is constant \(R\omega\) (plus the axial component) and the acceleration points at the centre — an exact circle, no solve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Source code in src/shinro/trajectories/circular_arc.py
generate
¶
Resolve the circle geometry (radius, plane, angular rate).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
Circle centre (3,). |
required | |
start
|
A point on the circle (3,), perpendicular to |
required | |
duration
|
float
|
Trajectory duration \(T\) (s). |
required |
sweep_angle
|
float
|
Signed arc angle (radians). |
required |
normal
|
Arc-plane normal (3,). Defaults to |
None
|
|
pitch
|
float
|
Axial advance along |
0.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
On a non-positive duration, a non-3D centre/start/
normal, a zero-length normal, |
Source code in src/shinro/trajectories/circular_arc.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 shape |
|
|
|
Source code in src/shinro/trajectories/circular_arc.py
from_config
classmethod
¶
from_config(config, backend: ArrayBackend | None = None) -> Any
Create a waypoint schedule from a TOML config dict or CircularArcConfig.
Config fields
dt: Sampling period (s).
center: Circle centre (3,).
start: A point on the circle (3,).
duration: Trajectory duration (s).
sweep_angle: Signed arc angle (radians).
normal: Arc-plane normal (3,); defaults to [0, 0, 1].
pitch: Helix pitch (axial advance per full turn).
derivatives: Emit the velocity/acceleration dict instead of positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
TOML config dict or CircularArcConfig. |
required | |
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Array of shape (total_steps, 3) with position waypoints, or — when |
Any
|
|
Any
|
under |
Source code in src/shinro/trajectories/circular_arc.py
BezierCurve¶
Bases: TrajectoryGenerator
Bézier trajectory over a list of control points.
With \(n =\) (number of control points) \(- 1\) and \(s = t / T\):
The endpoints are interpolated (\(B(0) = P_0\), \(B(T) = P_n\)), and the velocity / acceleration are themselves Bézier curves over the scaled control-point differences:
The boundary velocities are \(\frac{n}{T}(P_1 - P_0)\) and \(\frac{n}{T}(P_n - P_{n-1})\) — not zero unless the end points are duplicated in the control list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control_points
|
Ordered control points, each shape |
required | |
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Source code in src/shinro/trajectories/bezier_curve.py
generate
¶
Compute the Bernstein blocks for position, velocity, acceleration.
start_position / end_position are informational only — the
curve's ends are the first and last control points, and supplying
conflicting values is an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_position
|
Optional expected start; must equal |
None
|
|
end_position
|
Optional expected end; must equal |
None
|
|
duration
|
float | None
|
Trajectory duration \(T\) (s). |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the control list has fewer than 2 points, ragged point dimensions, a non-positive duration, or declared start/end that disagree with the control list ends. |
Source code in src/shinro/trajectories/bezier_curve.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 |
|
|
|
Source code in src/shinro/trajectories/bezier_curve.py
from_config
classmethod
¶
from_config(config, backend: ArrayBackend | None = None) -> Any
Create a waypoint schedule from a TOML config dict or BezierConfig.
Config fields
dt: Sampling period (s). duration: Trajectory duration (s). control_points: Ordered control points (list of float lists).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
TOML config dict or BezierConfig. |
required | |
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Array of shape (total_steps, d) with position waypoints, or — when |
Any
|
|
Any
|
under |
Source code in src/shinro/trajectories/bezier_curve.py
BSpline¶
Bases: TrajectoryGenerator
B-spline trajectory over a knot vector and control polygon.
with \(N_{i,p}\) the Cox–de Boor recursion over the knot vector \(\{u_i\}\) and \(m =\) len(knots) \(= n + p + 2\).
Derivatives reuse the same recursion by degree reduction: the \(k\)-th derivative curve is the B-spline of degree \(p - k\) over the differentiated control polygon
with the first and last knot dropped (applied \(k\) times,
_bspline_derv). generate precomputes the first and second
derivative curves; position_at returns (pos, vel, acc) like
shinro.trajectories.BezierCurve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degree_polynomial
|
int
|
Polynomial degree \(p\) of the curve. |
required |
control_points
|
Sequence[Sequence[float]]
|
Ordered control points, each shape |
required |
time_knot_vector
|
Sequence[float]
|
Knot vector, exactly |
required |
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Source code in src/shinro/trajectories/b_spline.py
generate
¶
Validate the curve data and precompute the derivative curves.
start_position / end_position are informational only — the
curve's ends are interpolated only by a clamped knot vector, so no
agreement check is implied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
duration
|
float
|
Trajectory duration \(T\) (s). |
required |
start_position
|
Unused (see above). |
None
|
|
end_position
|
Unused (see above). |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
On a non-positive duration, fewer than 2 control points, ragged point dimensions, a negative degree, a knot count that disagrees with the control polygon, or a non-monotone knot vector. |
Source code in src/shinro/trajectories/b_spline.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 |
|
|
|
|
|
degree < 1 / < 2 respectively. |
Source code in src/shinro/trajectories/b_spline.py
from_config
classmethod
¶
from_config(config, backend: ArrayBackend | None = None) -> Any
Create a waypoint schedule from a TOML config dict or BSplineConfig.
Config fields
dt: Sampling period (s). duration: Trajectory duration (s). degree: Polynomial degree of the curve. control_points: Ordered control points (list of float lists). knots: Knot vector (list of floats).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
TOML config dict or BSplineConfig. |
required | |
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Array of shape (total_steps, d) with position waypoints, or — when |
Any
|
|
Any
|
under |
Source code in src/shinro/trajectories/b_spline.py
CatmullRom¶
Bases: TrajectoryGenerator
C1 Catmull-Rom spline through a start point and ordered waypoints.
Each hop is a cubic Hermite segment (reusing
shinro.trajectories.CubicPolynomial) whose boundary velocities are
the Catmull-Rom tangents
at interior waypoints, where \(d_i\) is the duration of hop
\(i \to i+1\). Each tangent is the end velocity of one segment and the
start velocity of the next, so the concatenated curve is C1 and passes
through every waypoint without stopping — contrast cubic_segments,
whose per-segment defaults bring the curve to rest at each waypoint.
Endpoint velocities default to zero (rest-to-rest start/stop);
endpoint_tangent="one_sided" uses \((P_1 - P_0)/d_0\) and
\((P_n - P_{n-1})/d_{n-1}\) — the classic one-sided Catmull-Rom ends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Source code in src/shinro/trajectories/catmull_rom.py
generate
¶
Build the C1 segments from waypoints and hop durations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waypoints
|
Sequence of n+1 positions (each shape |
required | |
durations
|
n hop durations (s); |
required | |
endpoint_tangent
|
str
|
|
'zero'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
On fewer than 2 waypoints, ragged dimensions, a
duration count that disagrees with the waypoint count, a
non-positive duration, or an unknown |
Source code in src/shinro/trajectories/catmull_rom.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 |
|
|
|
Source code in src/shinro/trajectories/catmull_rom.py
from_config
classmethod
¶
from_config(config, backend: ArrayBackend | None = None) -> Any
Create a waypoint schedule from a TOML config dict or CatmullRomConfig.
Config fields
dt: Sampling period (s).
start: Position of waypoint 0.
waypoints: Ordered [[waypoints]] entries, each with a
duration (s from the previous waypoint) and a position.
endpoint_tangent: "zero" (default) or "one_sided".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
TOML config dict or CatmullRomConfig. |
required | |
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Array of shape (total_steps, d) with position waypoints, or — when |
Any
|
|
Any
|
under |
Source code in src/shinro/trajectories/catmull_rom.py
Akima¶
Bases: _WaypointSpline
Akima spline — overshoot-resistant C1 waypoint interpolation.
The tangent at interior waypoint \(i\) is Akima's local four-slope estimate over the neighbouring interval slopes \(s_{i-2..i+1}\):
(the average of \(s_{i-1}\) and \(s_i\) where the denominator
vanishes, applied elementwise). End tangents use linearly extrapolated end
slopes, so the curve is defined by a local stencil and — unlike
shinro.trajectories.CatmullRom — is designed not to overshoot
steep changes. Each hop is a cubic Hermite segment
(shinro.trajectories.CubicPolynomial), giving C1 continuity.
Config is start + [[waypoints]]{duration, position}, like
catmull_rom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Source code in src/shinro/trajectories/waypoint_splines.py
CubicSpline¶
Bases: _WaypointSpline
Natural cubic spline — C2 waypoint interpolation.
The interior second derivatives \(M_i = S''(P_i)\) solve the tridiagonal system
with the natural end conditions \(M_0 = M_n = 0\) (zero boundary acceleration). The waypoint velocities are then
and each hop is a cubic Hermite segment
(shinro.trajectories.CubicPolynomial), which reproduces the
spline segment exactly — so the concatenated curve is C2. Unlike Akima it
is global (one bk.solve) and can overshoot steep changes.
Config is start + [[waypoints]]{duration, position}, like
catmull_rom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
ArrayBackend | None
|
Array backend. Defaults to NumpyBackend. |
None
|
Source code in src/shinro/trajectories/waypoint_splines.py
sample_schedule¶
Sample one generator over [0, duration) into stacked (steps, N) arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traj
|
A generator with |
required | |
dt
|
float
|
Sampling period (s). |
required |
duration
|
float | None
|
Horizon (s). Defaults to the generator's own total duration. |
None
|
order
|
int
|
0 = position, 1 = +velocity, 2 = +acceleration. |
2
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict mapping |
dict[str, Any]
|
and |
Source code in src/shinro/trajectories/sampling.py
sample_segments¶
Concatenate per-segment samples into stacked (steps, N) arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segments
|
Iterable of |
required | |
dt
|
float
|
Sampling period (s). |
required |
order
|
int
|
0 = position, 1 = +velocity, 2 = +acceleration. |
2
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict as in |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/shinro/trajectories/sampling.py
limit_trajectory¶
Return a TimeScaled view of traj that respects the limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traj
|
A generator with |
required | |
max_velocity
|
float | None
|
Velocity limit (per component). |
None
|
max_acceleration
|
float | None
|
Acceleration limit (per component). |
None
|
samples
|
int
|
Number of intervals used to locate the peaks. |
1000
|
Returns:
| Type | Description |
|---|---|
TimeScaled
|
A |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both limits are |
Source code in src/shinro/trajectories/time_scaling.py
time_scale_factor¶
Smallest \(k \ge 1\) so traversing trajk times slower respects the limits.
Samples traj.position_at at samples + 1 points and takes the peak
component speed / acceleration. Time-scaling by \(k\) divides velocity
by \(k\) and acceleration by \(k^2\), so
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traj
|
A generator with |
required | |
max_velocity
|
float | None
|
Velocity limit (per component). |
None
|
max_acceleration
|
float | None
|
Acceleration limit (per component). |
None
|
samples
|
int
|
Number of intervals used to locate the peaks. |
1000
|
Returns:
| Type | Description |
|---|---|
float
|
The time-scale factor \(k \ge 1\). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both limits are |
Source code in src/shinro/trajectories/time_scaling.py
TimeScaled¶
Wrap a generator so it is traversed k times slower.
position_at(t) returns inner.position_at(t / k) with the derivatives
rescaled (velocity ÷ k, acceleration ÷ k²). The path is unchanged;
only the timing is stretched, so the horizon grows to k * inner_T.
Source code in src/shinro/trajectories/time_scaling.py
position_at
¶
Evaluate the time-scaled trajectory at time t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Time in seconds on the scaled horizon \([0, k T]\). |
required |
Returns:
| Type | Description |
|---|---|
|
Tuple of (position, velocity, acceleration) arrays. |
Source code in src/shinro/trajectories/time_scaling.py
s_curve_limit¶
Return an SCurveScaled view of traj that respects the limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traj
|
A generator with |
required | |
max_velocity
|
float | None
|
Velocity limit (per component). |
None
|
max_acceleration
|
float | None
|
Acceleration limit (per component). |
None
|
max_jerk
|
float | None
|
Jerk limit (per component). |
None
|
samples
|
int
|
Number of intervals used to locate the peaks. |
1000
|
Returns:
| Type | Description |
|---|---|
SCurveScaled
|
An |
Raises:
| Type | Description |
|---|---|
ValueError
|
If all three limits are |
Source code in src/shinro/trajectories/time_scaling.py
s_curve_horizon¶
Horizon \(T'\) for the min-jerk S-curve time law that respects the limits.
The output is p(T σ(t / T')) with \(\sigma\) the min-jerk profile, so
by the chain rule each output derivative's peak is a fixed function of
\(T'\):
where \(V, A, J\) are sampled from the path. Solving each for \(T'\) and taking the largest (and at least the original horizon \(T\), so the S-curve never speeds the path up) gives the returned horizon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traj
|
A generator with |
required | |
max_velocity
|
float | None
|
Velocity limit (per component). |
None
|
max_acceleration
|
float | None
|
Acceleration limit (per component). |
None
|
max_jerk
|
float | None
|
Jerk limit (per component). |
None
|
samples
|
int
|
Number of intervals used to locate the peaks. |
1000
|
Returns:
| Type | Description |
|---|---|
float
|
The S-curve horizon \(T' \ge T\) (s). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If all three limits are |
Source code in src/shinro/trajectories/time_scaling.py
SCurveScaled¶
Wrap a generator so its path parameter follows a rest-to-rest min-jerk S-curve.
position_at(t) evaluates the inner generator at the path time
φ(t) = T·σ(t / T') (\(\sigma\) = min-jerk) and applies the chain
rule. The path is the same curve traversed with an S-curve timing; the
horizon is T' and the ends come to rest (σ'(0) = σ'(1) = 0).
Source code in src/shinro/trajectories/time_scaling.py
position_at
¶
Evaluate the S-curve time-scaled trajectory at time t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Time in seconds on the scaled horizon \([0, T']\). |
required |
Returns:
| Type | Description |
|---|---|
|
Tuple of (position, velocity, acceleration) arrays. |