pub struct Path { /* private fields */ }Expand description
Unified path abstraction over parametric and spline representations.
Construct via Path::from_parametric or Path::from_waypoints, then
query a batch of parameter values with the evaluate_* family of methods.
The valid parameter domain is [s_min, s_max] (set at construction time).
Out-of-range behaviour is controlled by OutOfRangeMode: the default is to
return an error; it can be changed to silent clamping.
Implementations§
Source§impl Path
impl Path
Sourcepub fn from_parametric<F>(
q_fn: F,
s_min: f64,
s_max: f64,
) -> Result<Self, PathError>
pub fn from_parametric<F>( q_fn: F, s_min: f64, s_max: f64, ) -> Result<Self, PathError>
Build a parametric path from an analytic closure.
Derivatives up to third order are computed automatically via Jet3
forward-mode AD. The closure only needs to express q(s) symbolically;
no manual differentiation is required.
§Arguments
q_fn: closure mapping scalarsto adim-dimensional position vectors_min: lower bound of the path parameters_max: upper bound of the path parameter (s_max > s_minrequired)
§Errors
PathError::InvalidRange:s_min >= s_maxor either value is non-finitePathError::InvalidDimension: closure returned an empty vector
Sourcepub fn from_waypoints(
waypoints: &DMatrix<f64>,
cfg: SplineConfig,
) -> Result<Self, PathError>
pub fn from_waypoints( waypoints: &DMatrix<f64>, cfg: SplineConfig, ) -> Result<Self, PathError>
Build a spline path by interpolating a waypoint matrix.
Internally solves the Hermite spline system with an O(N) block-Thomas
algorithm; all dimensions are solved in parallel.
The default configuration (SplineConfig::default) uses a quintic
(order-5) spline with s ∈ [0, 1].
§Arguments
waypoints: matrix of shape(dim, n_points); each column is one waypointcfg: spline configuration (order, parameter range, boundary derivatives, out-of-range mode)
§Errors
PathError::InvalidDimension:waypointshas zero rowsPathError::NotEnoughWaypoints: fewer than 2 columnsPathError::InvalidOrder:order < 3PathError::InvalidRange: invalid parameter rangePathError::SingularSystem: spline system is singular (extremely rare)
Sourcepub fn evaluate_q(&self, s: &[f64]) -> Result<PathDerivatives, PathError>
pub fn evaluate_q(&self, s: &[f64]) -> Result<PathDerivatives, PathError>
Evaluate position q only at the query points (cheapest; no derivatives).
§Arguments
s: one-dimensional parameter samples (lengthN)
§Returns
PathDerivatives with dq / ddq / dddq all None;
q has shape (dim, N).
§Errors
PathError::OutOfRangeS: a query value is out of range (only inErrormode)
Sourcepub fn evaluate_up_to_2nd(
&self,
s: &[f64],
) -> Result<PathDerivatives, PathError>
pub fn evaluate_up_to_2nd( &self, s: &[f64], ) -> Result<PathDerivatives, PathError>
Evaluate position, velocity, and acceleration (q, dq, ddq); jerk is not computed.
§Arguments
s: one-dimensional parameter samples (lengthN)
§Returns
PathDerivatives with dddq = None;
q / dq / ddq each have shape (dim, N).
Sourcepub fn evaluate_up_to_3rd(
&self,
s: &[f64],
) -> Result<PathDerivatives, PathError>
pub fn evaluate_up_to_3rd( &self, s: &[f64], ) -> Result<PathDerivatives, PathError>
Evaluate position and all three derivative orders (q, dq, ddq, dddq).
This is the most expensive evaluation method. If jerk is not needed,
prefer evaluate_up_to_2nd.
§Arguments
s: one-dimensional parameter samples (lengthN)
§Returns
PathDerivatives with all four fields populated; each matrix has shape (dim, N).
§Errors
PathError::OutOfRangeS: a query value is out of range
§Example
let path = Path::from_parametric(
|s: Jet3| vec![sin(s), cos(s)],
0.0, 1.0,
).unwrap();
let s = [0.0, 0.25, 0.5, 0.75, 1.0];
let out = path.evaluate_up_to_3rd(&s).unwrap();
let dq = out.dq.as_ref().unwrap();
let dddq = out.dddq.as_ref().unwrap();
// dim 0 is sin(s); its first derivative is cos(s), evaluated at s[0]=0.0
assert!((dq[(0, 0)] - 0.0_f64.cos()).abs() < 1e-10);
// dim 1 is cos(s); its third derivative is sin(s), evaluated at s[0]=0.0
assert!((dddq[(1, 0)] - 0.0_f64.sin()).abs() < 1e-10);Auto Trait Implementations§
impl Freeze for Path
impl !RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl !UnwindSafe for Path
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.