5#include <initializer_list>
52 return Jet3{value, 0.0, 0.0, 0.0};
55 static constexpr Jet3 seed(
double value)
noexcept
57 return Jet3{value, 1.0, 0.0, 0.0};
73 return Jet3{lhs.v + rhs, lhs.d1, lhs.d2, lhs.d3};
93 return Jet3{lhs.v - rhs, lhs.d1, lhs.d2, lhs.d3};
98 return Jet3{lhs - rhs.v, -rhs.d1, -rhs.d2, -rhs.d3};
103 return Jet3{-value.v, -value.d1, -value.d2, -value.d3};
110 lhs.d1 * rhs.v + lhs.v * rhs.d1,
111 lhs.d2 * rhs.v + 2.0 * lhs.d1 * rhs.d1 + lhs.v * rhs.d2,
112 lhs.d3 * rhs.v + 3.0 * (lhs.d2 * rhs.d1 + lhs.d1 * rhs.d2) + lhs.v * rhs.d3,
133 const double inv = 1.0 / rhs.v;
134 const double inv2 = inv * inv;
135 const double inv3 = inv2 * inv;
136 const double inv4 = inv3 * inv;
137 const double d1sq = rhs.d1 * rhs.d1;
140 -lhs * inv2 * rhs.d1,
141 lhs * (2.0 * inv3 * d1sq - inv2 * rhs.d2),
142 lhs * (-6.0 * inv4 * d1sq * rhs.d1 + 6.0 * inv3 * rhs.d1 * rhs.d2 - inv2 * rhs.d3),
148 return lhs * (1.0 / rhs);
153 return lhs * (1.0 / rhs);
158 const double sv = std::sin(x.v);
159 const double cv = std::cos(x.v);
160 const double d1sq = x.d1 * x.d1;
164 -sv * d1sq + cv * x.d2,
165 -cv * d1sq * x.d1 - 3.0 * sv * x.d1 * x.d2 + cv * x.d3,
171 const double sv = std::sin(x.v);
172 const double cv = std::cos(x.v);
173 const double d1sq = x.d1 * x.d1;
177 -cv * d1sq - sv * x.d2,
178 sv * d1sq * x.d1 - 3.0 * cv * x.d1 * x.d2 - sv * x.d3,
184 const double ev = std::exp(x.v);
185 const double d1sq = x.d1 * x.d1;
190 ev * (d1sq * x.d1 + 3.0 * x.d1 * x.d2 + x.d3),
196 const double inv = 1.0 / x.v;
197 const double inv2 = inv * inv;
198 const double inv3 = inv2 * inv;
199 const double d1sq = x.d1 * x.d1;
203 -inv2 * d1sq + inv * x.d2,
204 2.0 * inv3 * d1sq * x.d1 - 3.0 * inv2 * x.d1 * x.d2 + inv * x.d3,
215 const double sqrtv = std::sqrt(x.v);
216 const double inv_sqrt = 1.0 / sqrtv;
217 const double inv_v_sqrt = inv_sqrt / x.v;
218 const double inv_v2_sqrt = inv_v_sqrt / x.v;
219 const double d1sq = x.d1 * x.d1;
222 0.5 * inv_sqrt * x.d1,
223 -0.25 * inv_v_sqrt * d1sq + 0.5 * inv_sqrt * x.d2,
224 0.375 * inv_v2_sqrt * d1sq * x.d1 - 0.75 * inv_v_sqrt * x.d1 * x.d2 +
225 0.5 * inv_sqrt * x.d3,
236 const double nf =
static_cast<double>(n);
237 const double coeff2 = nf * (nf - 1.0);
238 const double coeff3 = coeff2 * (nf - 2.0);
239 const double dv = nf * std::pow(x.v, nf - 1.0);
240 const double ddv = coeff2 == 0.0 ? 0.0 : coeff2 * std::pow(x.v, nf - 2.0);
241 const double dddv = coeff3 == 0.0 ? 0.0 : coeff3 * std::pow(x.v, nf - 3.0);
242 const double d1sq = x.d1 * x.d1;
246 ddv * d1sq + dv * x.d2,
247 dddv * d1sq * x.d1 + 3.0 * ddv * x.d1 * x.d2 + dv * x.d3,
342 std::optional<Matrix>
dq;
343 std::optional<Matrix>
ddq;
403 std::initializer_list<std::initializer_list<double>> waypoints,
406 std::initializer_list<std::initializer_list<double>> waypoints,
410 std::initializer_list<std::initializer_list<double>> waypoints,
551 explicit
Path(std::unique_ptr<Impl> impl);
553 std::unique_ptr<Impl> impl_;
572 std::initializer_list<std::initializer_list<double>> waypoints,
580 std::initializer_list<std::initializer_list<double>> waypoints,
Exception type thrown by the default C++ API.
Small C++17 expected-like result used by no-throw overloads.
Lightweight owned column-major matrix.
Mutable column-major matrix view used by callback APIs.
Non-owning view of a two-dimensional double matrix.
Geometric path wrapper backed by Rust Path.
static Path from_parametric(PathParametric parametric, double s_min, double s_max)
Build a path from a scalar-parametric formula.
std::size_t dim() const
Return the path dimension.
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.
PathDerivatives evaluate_q(Span< const double > s) const
Evaluate position samples only.
static Path from_parametric(std::size_t dim, double s_min, double s_max, PathParametricWriter parametric)
Build a path from a scalar-parametric formula that writes into a buffer.
static Path from_waypoints(std::initializer_list< std::initializer_list< double > > waypoints, SplineConfig config={})
Build a spline path from waypoint-list notation.
static Path from_waypoints(MatrixView waypoints, SplineConfig config={})
Build a spline path from waypoint positions.
PathDerivatives evaluate_up_to_3rd(Span< const double > s) const
Evaluate position, first derivative, second derivative, and third derivative.
friend const void * detail::path_handle(const Path &path) noexcept
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.
std::pair< double, double > s_range() const
Return the valid path-parameter interval (s_min, s_max).
PathDerivatives evaluate_up_to_2nd(Span< const double > s) const
Evaluate position, first derivative, and second derivative.
Non-owning view of a contiguous one-dimensional array.
Internal helpers for error conversion, no-throw overloads, and small implementation utilities used by...
auto expected_from(Fn &&fn) -> Expected< typename std::decay< decltype(fn())>::type >
COPP_API const void * path_handle(const Path &path) noexcept
Return the private bridge handle stored by Path.
Root namespace for the C++ facade: paths, robots, constraints, matrices, profiles,...
Jet3 sin(Jet3 x) noexcept
Jet3 powi(Jet3 x, int n) noexcept
std::function< void( Span< const double > s, MatrixRef q, MatrixRef dq, MatrixRef ddq, MatrixRef dddq)> PathEvaluator3rd
Batch third-order evaluator callback.
constexpr Jet3 operator-(Jet3 lhs, Jet3 rhs) noexcept
Jet3 sqrt(Jet3 x) noexcept
std::function< std::vector< Jet3 >(Jet3 s)> PathParametric
Scalar-parametric path callback that returns one Jet3 per dimension.
Jet3 log(Jet3 x) noexcept
std::function< void( Span< const double > s, MatrixRef q, MatrixRef dq, MatrixRef ddq)> PathEvaluator2nd
Batch second-order evaluator callback.
constexpr Jet3 operator+(Jet3 lhs, Jet3 rhs) noexcept
OutOfRangeMode
Policy for evaluating a path outside its configured s range.
@ Clamp
Clamp out-of-range query samples to the nearest endpoint.
@ Error
Throw copp::Error when any query sample is outside [s_min, s_max].
Jet3 exp(Jet3 x) noexcept
Jet3 cos(Jet3 x) noexcept
Jet3 operator/(double lhs, Jet3 rhs) noexcept
std::function< void(Jet3 s, Span< Jet3 > q)> PathParametricWriter
Allocation-free scalar-parametric path callback that writes one Jet3 per dimension.
constexpr Jet3 operator*(Jet3 lhs, Jet3 rhs) noexcept
Third-order forward-mode automatic-differentiation scalar.
static constexpr Jet3 seed(double value) noexcept
static constexpr Jet3 constant(double value) noexcept
Tag object selecting no-throw overloads.
Result of path evaluation.
std::optional< Matrix > dq
std::optional< Matrix > ddq
std::optional< Matrix > dddq
Configuration for waypoint spline construction.
std::optional< Matrix > end_state
Optional boundary derivatives at s_max; same shape convention as start_state.
OutOfRangeMode out_of_range
std::optional< Matrix > start_state
Optional boundary derivatives at s_min.