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

Non-owning view of a Rust-backed constraint buffer. More...

#include <robot.hpp>

Public Member Functions

 ConstraintsRef () noexcept=default
bool valid () const noexcept
 Return whether this reference points to a live bridge handle.
std::size_t dim () const
 Return the robot/path dimension.
std::size_t len () const
 Return the number of stored path stations.
std::size_t size () const
 Alias for len(), useful for STL-style code.
std::size_t capacity () const
 Return the allocated station-buffer capacity.
bool is_empty () const
 Return whether no path stations are stored.
std::pair< std::size_t, std::size_t > idx_s_range () const
 Return the active global station-id interval [first, second).
ConstraintsRefappend_s (Span< const double > s)
 Append strictly increasing path station samples.
std::vector< double > s_values (std::size_t idx_s_from, std::size_t idx_s_to) const
 Export stored station samples over [idx_s_from, idx_s_to).
std::vector< double > amax_values (std::size_t idx_s_from, std::size_t idx_s_to) const
 Export first-order upper bounds over [idx_s_from, idx_s_to).
double s_value (std::size_t idx_s) const
 Read one stored station sample by global station id.
double amax_value (std::size_t idx_s) const
 Read one first-order upper bound by global station id.
ConstraintsRefamax_substitute (Span< const double > amax, std::size_t idx_s)
 Overwrite first-order upper bounds starting at idx_s.
ConstraintsRefclear (bool keep_idx_s=false)
 Clear all stored stations and constraints.
ConstraintsRefpop_front_n (std::size_t n_cols)
 Remove n_cols logical stations from the front.
ConstraintsRefpop_back_n (std::size_t n_cols)
 Remove n_cols logical stations from the back.
ConstraintsRefpop_front_until (std::size_t idx_s_cut)
 Remove front stations until the kept window starts at idx_s_cut.
ConstraintsRefpop_back_until (std::size_t idx_s_cut)
 Remove back stations until the kept window ends at or before idx_s_cut.
ConstraintsRefadd_constraint_1st (Span< const double > amax, std::size_t idx_s)
 Add or tighten first-order constraints from a vector.
ConstraintsRefadd_constraint_1st (MatrixView amax, std::size_t idx_s)
 Add or tighten first-order constraints from an R x N matrix.
ConstraintsRefadd_constraint_2nd (MatrixView acc_a, MatrixView acc_b, MatrixView acc_max, std::size_t idx_s, bool is_negative=false)
 Append second-order raw constraint rows.
ConstraintsRefadd_constraint_3rd (MatrixView jerk_a, MatrixView jerk_b, MatrixView jerk_c, MatrixView jerk_d, MatrixView jerk_max, std::size_t idx_s, bool is_negative=false)
 Append third-order raw constraint rows.

Friends

class Robot
class Constraints
const void * detail::constraints_handle (ConstraintsRef constraints) noexcept
void * detail::constraints_handle_mut (ConstraintsRef constraints) noexcept

Detailed Description

Non-owning view of a Rust-backed constraint buffer.

ConstraintsRef is returned by Robot::constraints() and by Constraints::ref(). It is intentionally lightweight and copyable: it only stores a borrowed pointer to an owning C++ facade object. The owner must outlive every copied reference.

The first C++ milestone mirrors the Python Constraints surface for raw TOPP constraints: station management, first-order bound replacement, and raw first-/second-/third-order constraint rows. Physical velocity, acceleration, jerk, and torque limits live on Robot, because they need path derivative data and robot semantics.

Definition at line 85 of file robot.hpp.

Constructor & Destructor Documentation

◆ ConstraintsRef()

copp::ConstraintsRef::ConstraintsRef ( )
defaultnoexcept

Member Function Documentation

◆ valid()

bool copp::ConstraintsRef::valid ( ) const
noexcept

Return whether this reference points to a live bridge handle.

◆ dim()

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

Return the robot/path dimension.

◆ len()

std::size_t copp::ConstraintsRef::len ( ) const

Return the number of stored path stations.

◆ size()

std::size_t copp::ConstraintsRef::size ( ) const

Alias for len(), useful for STL-style code.

◆ capacity()

std::size_t copp::ConstraintsRef::capacity ( ) const

Return the allocated station-buffer capacity.

◆ is_empty()

bool copp::ConstraintsRef::is_empty ( ) const

Return whether no path stations are stored.

◆ idx_s_range()

std::pair< std::size_t, std::size_t > copp::ConstraintsRef::idx_s_range ( ) const

Return the active global station-id interval [first, second).

◆ append_s()

ConstraintsRef & copp::ConstraintsRef::append_s ( Span< const double > s)

Append strictly increasing path station samples.

The values are borrowed only for this call. If the buffer is not empty, the first new sample must be greater than the current last stored station.

Parameters
sNew station samples in strictly increasing order.
Returns
*this for chaining.
Exceptions
copp::Errorif station order or range validation fails.

◆ s_values()

std::vector< double > copp::ConstraintsRef::s_values ( std::size_t idx_s_from,
std::size_t idx_s_to ) const

Export stored station samples over [idx_s_from, idx_s_to).

◆ amax_values()

std::vector< double > copp::ConstraintsRef::amax_values ( std::size_t idx_s_from,
std::size_t idx_s_to ) const

Export first-order upper bounds over [idx_s_from, idx_s_to).

◆ s_value()

double copp::ConstraintsRef::s_value ( std::size_t idx_s) const

Read one stored station sample by global station id.

◆ amax_value()

double copp::ConstraintsRef::amax_value ( std::size_t idx_s) const

Read one first-order upper bound by global station id.

◆ amax_substitute()

ConstraintsRef & copp::ConstraintsRef::amax_substitute ( Span< const double > amax,
std::size_t idx_s )

Overwrite first-order upper bounds starting at idx_s.

Unlike add_constraint_1st, this replaces amax values instead of taking the elementwise minimum. It is mainly used by reachability algorithms that refine an existing profile.

◆ clear()

ConstraintsRef & copp::ConstraintsRef::clear ( bool keep_idx_s = false)

Clear all stored stations and constraints.

If keep_idx_s is true, the current global station origin is kept; otherwise it is reset to zero.

◆ pop_front_n()

ConstraintsRef & copp::ConstraintsRef::pop_front_n ( std::size_t n_cols)

Remove n_cols logical stations from the front.

◆ pop_back_n()

ConstraintsRef & copp::ConstraintsRef::pop_back_n ( std::size_t n_cols)

Remove n_cols logical stations from the back.

◆ pop_front_until()

ConstraintsRef & copp::ConstraintsRef::pop_front_until ( std::size_t idx_s_cut)

Remove front stations until the kept window starts at idx_s_cut.

◆ pop_back_until()

ConstraintsRef & copp::ConstraintsRef::pop_back_until ( std::size_t idx_s_cut)

Remove back stations until the kept window ends at or before idx_s_cut.

◆ add_constraint_1st() [1/2]

ConstraintsRef & copp::ConstraintsRef::add_constraint_1st ( Span< const double > amax,
std::size_t idx_s )

Add or tighten first-order constraints from a vector.

The input represents one amax value per station. Stored amax is updated as the elementwise minimum of the existing and new values.

Parameters
amaxNode-based upper bounds for a = (ds/dt)^2.
idx_sGlobal station id of amax[0].

◆ add_constraint_1st() [2/2]

ConstraintsRef & copp::ConstraintsRef::add_constraint_1st ( MatrixView amax,
std::size_t idx_s )

Add or tighten first-order constraints from an R x N matrix.

Each matrix column is reduced to its minimum before being fused into the stored amax row. This matches Rust/Python raw constraint semantics.

◆ add_constraint_2nd()

ConstraintsRef & copp::ConstraintsRef::add_constraint_2nd ( MatrixView acc_a,
MatrixView acc_b,
MatrixView acc_max,
std::size_t idx_s,
bool is_negative = false )

Append second-order raw constraint rows.

For every station column, each row encodes acc_a * a + acc_b * b <= acc_max. If is_negative is true, the row is inserted with signs flipped; this is how lower bounds are represented internally.

Parameters
acc_aMatrix of a coefficients.
acc_bMatrix of b = dds/dt coefficients.
acc_maxMatrix of right-hand sides.
idx_sGlobal station id of the first column.
is_negativeWhether to insert the sign-flipped lower-bound row.

◆ add_constraint_3rd()

ConstraintsRef & copp::ConstraintsRef::add_constraint_3rd ( MatrixView jerk_a,
MatrixView jerk_b,
MatrixView jerk_c,
MatrixView jerk_d,
MatrixView jerk_max,
std::size_t idx_s,
bool is_negative = false )

Append third-order raw constraint rows.

For every station column, each row encodes sqrt(a) * (jerk_a*a + jerk_b*b + jerk_c*c + jerk_d) <= jerk_max. Linearization is performed later by TOPP3/COPP3 problem builders.

Parameters
jerk_aCoefficient matrix multiplying a.
jerk_bCoefficient matrix multiplying b.
jerk_cCoefficient matrix multiplying third-order control c.
jerk_dConstant term matrix.
jerk_maxRight-hand-side matrix.
idx_sGlobal station id of the first column.
is_negativeWhether to insert the sign-flipped lower-bound row.

◆ Robot

friend class Robot
friend

Definition at line 221 of file robot.hpp.

◆ Constraints

friend class Constraints
friend

Definition at line 222 of file robot.hpp.

◆ detail::constraints_handle

const void * detail::constraints_handle ( ConstraintsRef constraints)
friend

◆ detail::constraints_handle_mut

void * detail::constraints_handle_mut ( ConstraintsRef constraints)
friend

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