copp::Path represents the geometric path q = q(s). Solvers do not optimize geometry; they optimize how quickly this already-defined path is traversed.
Include
or:
Output Shapes
Every batch evaluation uses a station vector s of length N and returns column-major matrices with shape (dim x N):
std::vector<double> samples{0.0, 0.5, 1.0};
auto out = path.evaluate_up_to_2nd(samples);
double q_axis0_at_mid = out.q(0, 1);
double dq_axis0_at_mid = out.dq.value()(0, 1);
double ddq_axis0_at_mid = out.ddq.value()(0, 1);
Waypoint Splines
Waypoint paths are the easiest entry point. Each inner initializer-list is one waypoint vector:
{0.0, 0.0},
{0.5, 0.25},
{1.0, 1.0},
});
auto dim = path.dim();
static Path from_waypoints(MatrixView waypoints, SplineConfig config={})
Build a spline path from waypoint positions.
std::pair< double, double > s_range() const
Return the valid path-parameter interval (s_min, s_max).
If you already have a matrix, use the native COPP shape (dim x n_points):
{0.0, 0.0},
{0.5, 0.25},
{1.0, 1.0},
});
static Matrix from_columns(std::initializer_list< std::initializer_list< double > > columns)
Build a matrix from column-major initializer-list notation.
The default spline configuration follows Rust/Python:
- order 5
- range [0, 1]
- out-of-range behavior: error
- zero boundary derivative states
Custom range and clamping:
@ Clamp
Clamp out-of-range query samples to the nearest endpoint.
Configuration for waypoint spline construction.
OutOfRangeMode out_of_range
Scalar Parametric Paths
Path::from_parametric uses copp::Jet3 automatic differentiation. The callback receives a seeded scalar s; ordinary arithmetic and COPP math helpers propagate derivatives up to third order.
return std::vector<copp::Jet3>{
};
},
0.0,
1.0);
std::vector<double> samples{0.0, 0.5, 1.0};
static Path from_parametric(PathParametric parametric, double s_min, double s_max)
Build a path from a scalar-parametric formula.
PathDerivatives evaluate_up_to_3rd(Span< const double > s) const
Evaluate position, first derivative, second derivative, and third derivative.
Jet3 sin(Jet3 x) noexcept
Jet3 cos(Jet3 x) noexcept
Third-order forward-mode automatic-differentiation scalar.
For tighter loops, avoid allocating a vector inside every callback invocation by using the writer overload:
2,
0.0,
1.0,
});
Non-owning view of a contiguous one-dimensional array.
Jet3 powi(Jet3 x, int n) noexcept
Supported helpers include sin, cos, exp, log/ln, sqrt, and powi.
Batch Evaluator Paths
Use evaluator paths when the path comes from an external model or when you already know analytic derivatives. The callback is batch-oriented to avoid crossing the C++/Rust bridge once per station.
2,
0.0,
1.0,
for (std::size_t j = 0; j < s.
size(); ++j) {
const double x = s[j];
q(0, j) = x;
dq(0, j) = 1.0;
ddq(0, j) = 0.0;
q(1, j) = x * x;
dq(1, j) = 2.0 * x;
ddq(1, j) = 2.0;
}
});
Mutable column-major matrix view used by callback APIs.
static Path from_evaluator_2nd(std::size_t dim, double s_min, double s_max, PathEvaluator2nd evaluator)
Build a path from a batch evaluator with explicit derivatives up to second order.
constexpr std::size_t size() const noexcept
Third-order evaluators add dddq:
1,
0.0,
1.0,
for (std::size_t j = 0; j < s.
size(); ++j) {
const double x = s[j];
q(0, j) = x * x * x;
dq(0, j) = 3.0 * x * x;
ddq(0, j) = 6.0 * x;
dddq(0, j) = 6.0;
}
});
static Path from_evaluator_3rd(std::size_t dim, double s_min, double s_max, PathEvaluator3rd evaluator)
Build a path from a batch evaluator with explicit derivatives up to third order.
The path owns the callback object. Throw copp::Error or another std::exception from the callback to report evaluator failure.
Tutorial Sources