COPP C++ API
C++ interface for COPP trajectory optimization
Loading...
Searching...
No Matches
copp::Path Class Reference

Geometric path wrapper backed by Rust Path. More...

#include <path.hpp>

Public Member Functions

 Path (Path &&) noexcept
Pathoperator= (Path &&) noexcept
 ~Path ()
 Path (const Path &)=delete
Pathoperator= (const Path &)=delete
std::size_t dim () const
 Return the path dimension.
std::pair< double, double > s_range () const
 Return the valid path-parameter interval (s_min, s_max).
PathDerivatives evaluate_q (Span< const double > s) const
 Evaluate position samples only.
Expected< PathDerivativesevaluate_q (Span< const double > s, NoThrowTag) const
PathDerivatives evaluate_up_to_2nd (Span< const double > s) const
 Evaluate position, first derivative, and second derivative.
Expected< PathDerivativesevaluate_up_to_2nd (Span< const double > s, NoThrowTag) const
PathDerivatives evaluate_up_to_3rd (Span< const double > s) const
 Evaluate position, first derivative, second derivative, and third derivative.
Expected< PathDerivativesevaluate_up_to_3rd (Span< const double > s, NoThrowTag) const

Static Public Member Functions

static Path from_waypoints (MatrixView waypoints, SplineConfig config={})
 Build a spline path from waypoint positions.
static Expected< Pathfrom_waypoints (MatrixView waypoints, SplineConfig config, NoThrowTag)
static Expected< Pathfrom_waypoints (MatrixView waypoints, NoThrowTag)
static Path from_waypoints (std::initializer_list< std::initializer_list< double > > waypoints, SplineConfig config={})
 Build a spline path from waypoint-list notation.
static Expected< Pathfrom_waypoints (std::initializer_list< std::initializer_list< double > > waypoints, SplineConfig config, NoThrowTag)
static Expected< Pathfrom_waypoints (std::initializer_list< std::initializer_list< double > > waypoints, NoThrowTag)
static Path from_parametric (PathParametric parametric, double s_min, double s_max)
 Build a path from a scalar-parametric formula.
static Expected< Pathfrom_parametric (PathParametric parametric, double s_min, double s_max, NoThrowTag)
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 Expected< Pathfrom_parametric (std::size_t dim, double s_min, double s_max, PathParametricWriter parametric, NoThrowTag)
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.
static Expected< Pathfrom_evaluator_2nd (std::size_t dim, double s_min, double s_max, PathEvaluator2nd evaluator, NoThrowTag)
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.
static Expected< Pathfrom_evaluator_3rd (std::size_t dim, double s_min, double s_max, PathEvaluator3rd evaluator, NoThrowTag)

Friends

const void * detail::path_handle (const Path &path) noexcept

Detailed Description

Geometric path wrapper backed by Rust Path.

Path owns a Rust-side path handle through the cxx bridge. It is movable but not copyable. The C++ public API exposes RAII ownership and throws copp::Error on construction or evaluation failure.

Definition at line 352 of file path.hpp.

Constructor & Destructor Documentation

◆ Path() [1/2]

copp::Path::Path ( Path && )
noexcept

◆ ~Path()

copp::Path::~Path ( )

◆ Path() [2/2]

copp::Path::Path ( const Path & )
delete

Member Function Documentation

◆ from_waypoints() [1/6]

Path copp::Path::from_waypoints ( MatrixView waypoints,
SplineConfig config = {} )
static

Build a spline path from waypoint positions.

waypoints is a (dim x n_points) matrix where each column is one waypoint. At least one dimension and two waypoint columns are required.

Column-major views can cross the bridge directly. Row-major views are accepted for convenience and copied once into column-major storage before calling Rust.

The input view only needs to remain valid during this call; the returned Path owns the constructed Rust path.

Parameters
waypointsBorrowed waypoint matrix.
configSpline order, parameter range, and out-of-range policy.
Returns
Movable owning Path.
Exceptions
copp::Erroron invalid shape, invalid config, or Rust spline construction failure.
auto waypoints = copp::Matrix::from_columns({
{0.0, 0.0},
{0.5, 0.25},
{1.0, 1.0},
});
auto path = copp::Path::from_waypoints(waypoints.view());
static Matrix from_columns(std::initializer_list< std::initializer_list< double > > columns)
Build a matrix from column-major initializer-list notation.
Definition core.hpp:433
static Path from_waypoints(MatrixView waypoints, SplineConfig config={})
Build a spline path from waypoint positions.

◆ from_waypoints() [2/6]

Expected< Path > copp::Path::from_waypoints ( MatrixView waypoints,
SplineConfig config,
NoThrowTag  )
inlinestatic

Definition at line 558 of file path.hpp.

◆ from_waypoints() [3/6]

Expected< Path > copp::Path::from_waypoints ( MatrixView waypoints,
NoThrowTag tag )
inlinestatic

Definition at line 566 of file path.hpp.

◆ from_waypoints() [4/6]

Path copp::Path::from_waypoints ( std::initializer_list< std::initializer_list< double > > waypoints,
SplineConfig config = {} )
static

Build a spline path from waypoint-list notation.

Each inner list is one waypoint vector. The example below creates a two-dimensional path through three waypoints:

Parameters
waypointsOuter list of waypoint vectors, not matrix rows.
configSpline construction options.
Returns
Movable owning Path.
Exceptions
copp::Errorif the waypoint list is empty, ragged, or invalid.
{0.0, 0.0},
{0.5, 0.25},
{1.0, 1.0},
});

◆ from_waypoints() [5/6]

Expected< Path > copp::Path::from_waypoints ( std::initializer_list< std::initializer_list< double > > waypoints,
SplineConfig config,
NoThrowTag  )
inlinestatic

Definition at line 571 of file path.hpp.

◆ from_waypoints() [6/6]

Expected< Path > copp::Path::from_waypoints ( std::initializer_list< std::initializer_list< double > > waypoints,
NoThrowTag tag )
inlinestatic

Definition at line 579 of file path.hpp.

◆ from_parametric() [1/4]

Path copp::Path::from_parametric ( PathParametric parametric,
double s_min,
double s_max )
static

Build a path from a scalar-parametric formula.

The callback receives a seeded Jet3 value and returns one Jet3 per path dimension. The dimension is inferred by probing the callback once at the midpoint of [s_min, s_max]. Derivatives up to third order are propagated by Jet3 arithmetic.

Parameters
parametricFunction from scalar s to a vector-valued path.
s_minLower bound of the valid path range.
s_maxUpper bound of the valid path range.
Returns
Movable owning Path.
Exceptions
copp::Errorif the callback is empty, returns zero or inconsistent dimension, throws during probing/evaluation, or the range is invalid.

◆ from_parametric() [2/4]

Expected< Path > copp::Path::from_parametric ( PathParametric parametric,
double s_min,
double s_max,
NoThrowTag  )
inlinestatic

Definition at line 586 of file path.hpp.

◆ from_parametric() [3/4]

Path copp::Path::from_parametric ( std::size_t dim,
double s_min,
double s_max,
PathParametricWriter parametric )
static

Build a path from a scalar-parametric formula that writes into a buffer.

This overload avoids allocating a std::vector<Jet3> on each path sample. The callback must write exactly dim entries into q.

Parameters
dimPath dimension / number of entries written by the callback.
s_minLower bound of the valid path range.
s_maxUpper bound of the valid path range.
parametricAllocation-free writer callback.

◆ from_parametric() [4/4]

Expected< Path > copp::Path::from_parametric ( std::size_t dim,
double s_min,
double s_max,
PathParametricWriter parametric,
NoThrowTag  )
inlinestatic

Definition at line 596 of file path.hpp.

◆ from_evaluator_2nd() [1/2]

Path copp::Path::from_evaluator_2nd ( std::size_t dim,
double s_min,
double s_max,
PathEvaluator2nd evaluator )
static

Build a path from a batch evaluator with explicit derivatives up to second order.

The returned Path owns the callback. dim must be positive and remain consistent with the callback's output writes. The path range must satisfy finite s_min < s_max.

Parameters
dimPath dimension.
s_minLower range endpoint.
s_maxUpper range endpoint.
evaluatorBatch callback that fills q, dq, and ddq.
Returns
Movable owning Path.
Exceptions
copp::Erroron invalid dimensions/range or callback failure.

◆ from_evaluator_2nd() [2/2]

Expected< Path > copp::Path::from_evaluator_2nd ( std::size_t dim,
double s_min,
double s_max,
PathEvaluator2nd evaluator,
NoThrowTag  )
inlinestatic

Definition at line 607 of file path.hpp.

◆ from_evaluator_3rd() [1/2]

Path copp::Path::from_evaluator_3rd ( std::size_t dim,
double s_min,
double s_max,
PathEvaluator3rd evaluator )
static

Build a path from a batch evaluator with explicit derivatives up to third order.

The returned Path owns the callback. dim must be positive and remain consistent with the callback's output writes. The path range must satisfy finite s_min < s_max.

A third-order evaluator can also be used by TOPP2/COPP2 workflows; the facade requests only the derivatives that each solver needs.

◆ from_evaluator_3rd() [2/2]

Expected< Path > copp::Path::from_evaluator_3rd ( std::size_t dim,
double s_min,
double s_max,
PathEvaluator3rd evaluator,
NoThrowTag  )
inlinestatic

Definition at line 618 of file path.hpp.

◆ operator=() [1/2]

Path & copp::Path::operator= ( Path && )
noexcept

◆ operator=() [2/2]

Path & copp::Path::operator= ( const Path & )
delete

◆ dim()

std::size_t copp::Path::dim ( ) const

Return the path dimension.

Returns
Number of generalized coordinates in q(s).

◆ s_range()

std::pair< double, double > copp::Path::s_range ( ) const

Return the valid path-parameter interval (s_min, s_max).

Returns
Pair {s_min, s_max}.

◆ evaluate_q() [1/2]

PathDerivatives copp::Path::evaluate_q ( Span< const double > s) const

Evaluate position samples only.

Returns PathDerivatives with q populated and derivative fields empty.

Parameters
sQuery samples.
Returns
Column-major matrix q with shape (dim(), s.size()).
Exceptions
copp::Errorif samples are invalid or the underlying evaluator fails.

◆ evaluate_q() [2/2]

Expected< PathDerivatives > copp::Path::evaluate_q ( Span< const double > s,
NoThrowTag  ) const
inline

Definition at line 629 of file path.hpp.

◆ evaluate_up_to_2nd() [1/2]

PathDerivatives copp::Path::evaluate_up_to_2nd ( Span< const double > s) const

Evaluate position, first derivative, and second derivative.

Returns q, dq, and ddq, each with shape (dim, s.size()).

Parameters
sQuery samples.
Returns
PathDerivatives with q, dq, and ddq populated.

◆ evaluate_up_to_2nd() [2/2]

Expected< PathDerivatives > copp::Path::evaluate_up_to_2nd ( Span< const double > s,
NoThrowTag  ) const
inline

Definition at line 634 of file path.hpp.

◆ evaluate_up_to_3rd() [1/2]

PathDerivatives copp::Path::evaluate_up_to_3rd ( Span< const double > s) const

Evaluate position, first derivative, second derivative, and third derivative.

Returns q, dq, ddq, and dddq, each with shape (dim, s.size()).

Parameters
sQuery samples.
Returns
PathDerivatives with all derivative matrices populated.

◆ evaluate_up_to_3rd() [2/2]

Expected< PathDerivatives > copp::Path::evaluate_up_to_3rd ( Span< const double > s,
NoThrowTag  ) const
inline

Definition at line 639 of file path.hpp.

◆ detail::path_handle

const void * detail::path_handle ( const Path & path)
friend

The documentation for this class was generated from the following file: