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

Time-conversion helpers for TOPP2/TOPP3 profiles, including s -> t, uniform t -> s, explicit-sample t -> s, and third-order profile slicing. More...

Classes

struct  TimeProfile
 Cumulative time profile returned by s_to_t_topp2. More...
struct  TimeGridOptions
 Options for generating a uniform s(t) sampling grid. More...

Functions

COPP_API std::vector< double > a_to_b_topp2 (Span< const double > s, Span< const double > a)
 Compute segment profile b from node profile a.
Expected< std::vector< double > > a_to_b_topp2 (Span< const double > s, Span< const double > a, NoThrowTag)
COPP_API TimeProfile s_to_t_topp2 (Span< const double > s, Span< const double > a, double t0=0.0)
 Convert a second-order path profile a(s) = ds/dt squared to t(s).
Expected< TimeProfiles_to_t_topp2 (Span< const double > s, Span< const double > a, double t0, NoThrowTag)
Expected< TimeProfiles_to_t_topp2 (Span< const double > s, Span< const double > a, NoThrowTag tag)
COPP_API std::vector< double > t_to_s_topp2_uniform (Span< const double > s, Span< const double > a, Span< const double > t_s, double dt, TimeGridOptions options={})
 Sample the inverse TOPP2 mapping s(t) on a uniform time grid.
Expected< std::vector< double > > t_to_s_topp2_uniform (Span< const double > s, Span< const double > a, Span< const double > t_s, double dt, TimeGridOptions options, NoThrowTag)
Expected< std::vector< double > > t_to_s_topp2_uniform (Span< const double > s, Span< const double > a, Span< const double > t_s, double dt, NoThrowTag tag)
COPP_API std::vector< double > t_to_s_topp2_samples (Span< const double > s, Span< const double > a, Span< const double > t_s, Span< const double > t_sample)
 Sample the inverse TOPP2 mapping s(t) at explicit query times.
Expected< std::vector< double > > t_to_s_topp2_samples (Span< const double > s, Span< const double > a, Span< const double > t_s, Span< const double > t_sample, NoThrowTag)
COPP_API TimeProfile s_to_t_topp3 (Span< const double > s, const Profile3rd &profile, double t0=0.0)
 Convert a third-order profile to cumulative time t(s).
COPP_API TimeProfile s_to_t_topp3 (Span< const double > s, Profile3rdRef profile, double t0=0.0)
Expected< TimeProfiles_to_t_topp3 (Span< const double > s, const Profile3rd &profile, double t0, NoThrowTag)
Expected< TimeProfiles_to_t_topp3 (Span< const double > s, const Profile3rd &profile, NoThrowTag tag)
Expected< TimeProfiles_to_t_topp3 (Span< const double > s, Profile3rdRef profile, double t0, NoThrowTag)
Expected< TimeProfiles_to_t_topp3 (Span< const double > s, Profile3rdRef profile, NoThrowTag tag)
COPP_API std::vector< double > t_to_s_topp3_uniform (Span< const double > s, const Profile3rd &profile, Span< const double > t_s, double dt, TimeGridOptions options={})
 Sample the inverse TOPP3 mapping s(t) on a uniform time grid.
COPP_API std::vector< double > t_to_s_topp3_uniform (Span< const double > s, Profile3rdRef profile, Span< const double > t_s, double dt, TimeGridOptions options={})
Expected< std::vector< double > > t_to_s_topp3_uniform (Span< const double > s, const Profile3rd &profile, Span< const double > t_s, double dt, TimeGridOptions options, NoThrowTag)
Expected< std::vector< double > > t_to_s_topp3_uniform (Span< const double > s, const Profile3rd &profile, Span< const double > t_s, double dt, NoThrowTag tag)
Expected< std::vector< double > > t_to_s_topp3_uniform (Span< const double > s, Profile3rdRef profile, Span< const double > t_s, double dt, TimeGridOptions options, NoThrowTag)
Expected< std::vector< double > > t_to_s_topp3_uniform (Span< const double > s, Profile3rdRef profile, Span< const double > t_s, double dt, NoThrowTag tag)
COPP_API std::vector< double > t_to_s_topp3_samples (Span< const double > s, const Profile3rd &profile, Span< const double > t_s, Span< const double > t_sample)
 Sample the inverse TOPP3 mapping s(t) at explicit query times.
COPP_API std::vector< double > t_to_s_topp3_samples (Span< const double > s, Profile3rdRef profile, Span< const double > t_s, Span< const double > t_sample)
Expected< std::vector< double > > t_to_s_topp3_samples (Span< const double > s, const Profile3rd &profile, Span< const double > t_s, Span< const double > t_sample, NoThrowTag)
Expected< std::vector< double > > t_to_s_topp3_samples (Span< const double > s, Profile3rdRef profile, Span< const double > t_s, Span< const double > t_sample, NoThrowTag)

Detailed Description

Time-conversion helpers for TOPP2/TOPP3 profiles, including s -> t, uniform t -> s, explicit-sample t -> s, and third-order profile slicing.

Function Documentation

◆ a_to_b_topp2() [1/2]

COPP_API std::vector< double > copp::interpolation::a_to_b_topp2 ( Span< const double > s,
Span< const double > a )

Compute segment profile b from node profile a.

For every segment [s[k], s[k + 1]], this returns b[k] = 0.5 * (a[k + 1] - a[k]) / (s[k + 1] - s[k]).

Parameters
sStrictly increasing station grid of length N.
aNode profile of length N.
Returns
Segment acceleration profile of length N - 1.
Exceptions
copp::Errorif lengths, station ordering, or finite-value checks fail.

◆ a_to_b_topp2() [2/2]

Expected< std::vector< double > > copp::interpolation::a_to_b_topp2 ( Span< const double > s,
Span< const double > a,
NoThrowTag  )
inline

Definition at line 140 of file interpolation.hpp.

◆ s_to_t_topp2() [1/3]

COPP_API TimeProfile copp::interpolation::s_to_t_topp2 ( Span< const double > s,
Span< const double > a,
double t0 = 0.0 )

Convert a second-order path profile a(s) = ds/dt squared to t(s).

Input requirements mirror the Rust/Python APIs:

  • s.size() >= 2
  • a.size() == s.size()
  • s is strictly increasing
  • all values are finite
  • each segment has a positive finite speed denominator

The default API throws copp::Error when validation or interpolation fails. The returned vector owns its data.

Parameters
sStrictly increasing station grid.
aNode profile a[k] = (ds/dt)^2.
t0Initial time offset.
Returns
Cumulative time samples t_s and final time.
auto s_t = copp::interpolation::t_to_s_topp2_uniform(s, a, time.t_s, 1.0e-3);
COPP_API std::vector< double > t_to_s_topp2_uniform(Span< const double > s, Span< const double > a, Span< const double > t_s, double dt, TimeGridOptions options={})
Sample the inverse TOPP2 mapping s(t) on a uniform time grid.
COPP_API TimeProfile s_to_t_topp2(Span< const double > s, Span< const double > a, double t0=0.0)
Convert a second-order path profile a(s) = ds/dt squared to t(s).

◆ s_to_t_topp2() [2/3]

Expected< TimeProfile > copp::interpolation::s_to_t_topp2 ( Span< const double > s,
Span< const double > a,
double t0,
NoThrowTag  )
inline

Definition at line 171 of file interpolation.hpp.

◆ s_to_t_topp2() [3/3]

Expected< TimeProfile > copp::interpolation::s_to_t_topp2 ( Span< const double > s,
Span< const double > a,
NoThrowTag tag )
inline

Definition at line 180 of file interpolation.hpp.

◆ t_to_s_topp2_uniform() [1/3]

COPP_API std::vector< double > copp::interpolation::t_to_s_topp2_uniform ( Span< const double > s,
Span< const double > a,
Span< const double > t_s,
double dt,
TimeGridOptions options = {} )

Sample the inverse TOPP2 mapping s(t) on a uniform time grid.

t_s is normally returned by s_to_t_topp2. Out-of-range generated samples are represented as NaN by the Rust core. If options.include_final is true, the final station is appended when the uniform grid does not land exactly on it.

◆ t_to_s_topp2_uniform() [2/3]

Expected< std::vector< double > > copp::interpolation::t_to_s_topp2_uniform ( Span< const double > s,
Span< const double > a,
Span< const double > t_s,
double dt,
TimeGridOptions options,
NoThrowTag  )
inline

Definition at line 200 of file interpolation.hpp.

◆ t_to_s_topp2_uniform() [3/3]

Expected< std::vector< double > > copp::interpolation::t_to_s_topp2_uniform ( Span< const double > s,
Span< const double > a,
Span< const double > t_s,
double dt,
NoThrowTag tag )
inline

Definition at line 211 of file interpolation.hpp.

◆ t_to_s_topp2_samples() [1/2]

COPP_API std::vector< double > copp::interpolation::t_to_s_topp2_samples ( Span< const double > s,
Span< const double > a,
Span< const double > t_s,
Span< const double > t_sample )

Sample the inverse TOPP2 mapping s(t) at explicit query times.

t_sample must be finite, non-empty, and strictly increasing. Values outside the range of t_s are returned as NaN.

◆ t_to_s_topp2_samples() [2/2]

Expected< std::vector< double > > copp::interpolation::t_to_s_topp2_samples ( Span< const double > s,
Span< const double > a,
Span< const double > t_s,
Span< const double > t_sample,
NoThrowTag  )
inline

Definition at line 230 of file interpolation.hpp.

◆ s_to_t_topp3() [1/6]

COPP_API TimeProfile copp::interpolation::s_to_t_topp3 ( Span< const double > s,
const Profile3rd & profile,
double t0 = 0.0 )

Convert a third-order profile to cumulative time t(s).

The public profile object owns a and b; the Profile3rdRef overload is the zero-copy advanced form used for slicing or external storage. No raw (a, b, num_stationary) overload is exposed publicly.

Parameters
sStrictly increasing station grid.
profileNode-based third-order profile.
t0Initial time offset.
Returns
Cumulative time samples and final time.
copp::Profile3rd profile{a_values, b_values, {1, 1}};
auto whole = copp::interpolation::s_to_t_topp3(s, profile);
auto first_segment = copp::interpolation::s_to_t_topp3(
profile.segment(0));
Non-owning view of a contiguous one-dimensional array.
Definition core.hpp:139
COPP_API TimeProfile s_to_t_topp3(Span< const double > s, const Profile3rd &profile, double t0=0.0)
Convert a third-order profile to cumulative time t(s).
Owned third-order TOPP/COPP profile.
Profile3rdRef segment(std::size_t idx_s) const
Borrow one segment as the two-node profile idx_s..=idx_s+1.

◆ s_to_t_topp3() [2/6]

COPP_API TimeProfile copp::interpolation::s_to_t_topp3 ( Span< const double > s,
Profile3rdRef profile,
double t0 = 0.0 )

◆ s_to_t_topp3() [3/6]

Expected< TimeProfile > copp::interpolation::s_to_t_topp3 ( Span< const double > s,
const Profile3rd & profile,
double t0,
NoThrowTag  )
inline

Definition at line 266 of file interpolation.hpp.

◆ s_to_t_topp3() [4/6]

Expected< TimeProfile > copp::interpolation::s_to_t_topp3 ( Span< const double > s,
const Profile3rd & profile,
NoThrowTag tag )
inline

Definition at line 275 of file interpolation.hpp.

◆ s_to_t_topp3() [5/6]

Expected< TimeProfile > copp::interpolation::s_to_t_topp3 ( Span< const double > s,
Profile3rdRef profile,
double t0,
NoThrowTag  )
inline

Definition at line 283 of file interpolation.hpp.

◆ s_to_t_topp3() [6/6]

Expected< TimeProfile > copp::interpolation::s_to_t_topp3 ( Span< const double > s,
Profile3rdRef profile,
NoThrowTag tag )
inline

Definition at line 292 of file interpolation.hpp.

◆ t_to_s_topp3_uniform() [1/6]

COPP_API std::vector< double > copp::interpolation::t_to_s_topp3_uniform ( Span< const double > s,
const Profile3rd & profile,
Span< const double > t_s,
double dt,
TimeGridOptions options = {} )

Sample the inverse TOPP3 mapping s(t) on a uniform time grid.

t_s is normally returned by s_to_t_topp3. Generated out-of-range samples are represented as NaN by the Rust core.

◆ t_to_s_topp3_uniform() [2/6]

COPP_API std::vector< double > copp::interpolation::t_to_s_topp3_uniform ( Span< const double > s,
Profile3rdRef profile,
Span< const double > t_s,
double dt,
TimeGridOptions options = {} )

◆ t_to_s_topp3_uniform() [3/6]

Expected< std::vector< double > > copp::interpolation::t_to_s_topp3_uniform ( Span< const double > s,
const Profile3rd & profile,
Span< const double > t_s,
double dt,
TimeGridOptions options,
NoThrowTag  )
inline

Definition at line 316 of file interpolation.hpp.

◆ t_to_s_topp3_uniform() [4/6]

Expected< std::vector< double > > copp::interpolation::t_to_s_topp3_uniform ( Span< const double > s,
const Profile3rd & profile,
Span< const double > t_s,
double dt,
NoThrowTag tag )
inline

Definition at line 328 of file interpolation.hpp.

◆ t_to_s_topp3_uniform() [5/6]

Expected< std::vector< double > > copp::interpolation::t_to_s_topp3_uniform ( Span< const double > s,
Profile3rdRef profile,
Span< const double > t_s,
double dt,
TimeGridOptions options,
NoThrowTag  )
inline

Definition at line 338 of file interpolation.hpp.

◆ t_to_s_topp3_uniform() [6/6]

Expected< std::vector< double > > copp::interpolation::t_to_s_topp3_uniform ( Span< const double > s,
Profile3rdRef profile,
Span< const double > t_s,
double dt,
NoThrowTag tag )
inline

Definition at line 350 of file interpolation.hpp.

◆ t_to_s_topp3_samples() [1/4]

COPP_API std::vector< double > copp::interpolation::t_to_s_topp3_samples ( Span< const double > s,
const Profile3rd & profile,
Span< const double > t_s,
Span< const double > t_sample )

Sample the inverse TOPP3 mapping s(t) at explicit query times.

Parameters
sStrictly increasing station grid.
profileNode-based third-order profile.
t_sCumulative time samples returned by s_to_t_topp3.
t_sampleExplicit query times. Values outside the interpolation domain are returned as NaN, matching Rust/Python.
Returns
Interpolated station samples s(t_sample).

◆ t_to_s_topp3_samples() [2/4]

COPP_API std::vector< double > copp::interpolation::t_to_s_topp3_samples ( Span< const double > s,
Profile3rdRef profile,
Span< const double > t_s,
Span< const double > t_sample )

◆ t_to_s_topp3_samples() [3/4]

Expected< std::vector< double > > copp::interpolation::t_to_s_topp3_samples ( Span< const double > s,
const Profile3rd & profile,
Span< const double > t_s,
Span< const double > t_sample,
NoThrowTag  )
inline

Definition at line 378 of file interpolation.hpp.

◆ t_to_s_topp3_samples() [4/4]

Expected< std::vector< double > > copp::interpolation::t_to_s_topp3_samples ( Span< const double > s,
Profile3rdRef profile,
Span< const double > t_s,
Span< const double > t_sample,
NoThrowTag  )
inline

Definition at line 388 of file interpolation.hpp.