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

Robot facade backed by Rust Robot<CppRobotModel>. More...

#include <robot.hpp>

Public Member Functions

 Robot (std::size_t dim, std::size_t capacity=0)
 Robot (std::size_t dim, InverseDynamics inverse_dynamics, std::size_t capacity=0)
 Robot (Robot &&) noexcept
Robotoperator= (Robot &&) noexcept
 ~Robot ()
 Robot (const Robot &)=delete
Robotoperator= (const Robot &)=delete
ConstraintsRef constraints () noexcept
 Return a borrowed raw constraint-buffer facade.
std::size_t dim () const
std::size_t len () const
std::size_t size () const
std::size_t capacity () const
bool is_empty () const
std::pair< std::size_t, std::size_t > idx_s_range () const
bool has_inverse_dynamics () const
 Return whether a user inverse-dynamics callback is installed.
Robotset_inverse_dynamics (InverseDynamics inverse_dynamics)
 Replace the inverse-dynamics callback.
Robotclear_inverse_dynamics ()
 Restore point-mass torque evaluation (tau = ddq).
Robotappend_s (Span< const double > s)
 Append strictly increasing path station samples.
Robotset_q_2nd (MatrixView q, MatrixView dq, MatrixView ddq, std::size_t idx_s)
 Store path derivatives up to second order over an existing station interval.
Robotset_q_3rd (MatrixView q, MatrixView dq, MatrixView ddq, MatrixView dddq, std::size_t idx_s)
 Store path derivatives up to third order over an existing station interval.
Robotset_q_from_path_2nd (const Path &path, std::size_t idx_s_from, std::size_t idx_s_to)
 Sample a path and store derivatives up to second order.
Robotset_q_from_path_3rd (const Path &path, std::size_t idx_s_from, std::size_t idx_s_to)
 Sample a path and store derivatives up to third order.
Robotadd_velocity_limits (Span< const double > upper, Span< const double > lower, std::size_t start_idx_s, std::size_t length=0)
 Add velocity limits from broadcast vectors.
Robotadd_velocity_limits (MatrixView upper, MatrixView lower, std::size_t start_idx_s)
 Add velocity limits from explicit (dim x n) matrices.
Robotadd_acceleration_limits (Span< const double > upper, Span< const double > lower, std::size_t start_idx_s, std::size_t length=0)
 Add acceleration limits from broadcast vectors.
Robotadd_acceleration_limits (MatrixView upper, MatrixView lower, std::size_t start_idx_s)
 Add acceleration limits from explicit (dim x n) matrices.
Robotadd_jerk_limits (Span< const double > upper, Span< const double > lower, std::size_t start_idx_s, std::size_t length=0)
 Add jerk limits from broadcast vectors.
Robotadd_jerk_limits (MatrixView upper, MatrixView lower, std::size_t start_idx_s)
 Add jerk limits from explicit (dim x n) matrices.
Robotadd_torque_limits (Span< const double > upper, Span< const double > lower, std::size_t start_idx_s, std::size_t length=0)
 Add torque limits from broadcast vectors.
Robotadd_torque_limits (MatrixView upper, MatrixView lower, std::size_t start_idx_s)
 Add torque limits from explicit (dim x n) matrices.

Friends

const void * detail::robot_handle (const Robot &robot) noexcept
void * detail::robot_handle_mut (Robot &robot) noexcept

Detailed Description

Robot facade backed by Rust Robot<CppRobotModel>.

By default, torque evaluation uses point-mass dynamics (tau = ddq). Passing or setting an inverse-dynamics callback enables robot-specific torque limits and torque objectives. The callback is owned by Robot and may be replaced or cleared later; any state captured by reference must outlive the robot or the period in which torque-related operations run.

A typical TOPP/COPP setup is:

copp::Robot robot(2, s.size());
robot.append_s(s)
.set_q_from_path_2nd(path, 0, s.size())
.add_velocity_limits(upper, lower, 0, s.size())
.add_acceleration_limits(upper, lower, 0, s.size());
Robot facade backed by Rust Robot<CppRobotModel>.
Definition robot.hpp:318

Definition at line 317 of file robot.hpp.

Constructor & Destructor Documentation

◆ Robot() [1/4]

copp::Robot::Robot ( std::size_t dim,
std::size_t capacity = 0 )
explicit

◆ Robot() [2/4]

copp::Robot::Robot ( std::size_t dim,
InverseDynamics inverse_dynamics,
std::size_t capacity = 0 )

◆ Robot() [3/4]

copp::Robot::Robot ( Robot && )
noexcept

◆ ~Robot()

copp::Robot::~Robot ( )

◆ Robot() [4/4]

copp::Robot::Robot ( const Robot & )
delete

Member Function Documentation

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ constraints()

ConstraintsRef copp::Robot::constraints ( )
noexcept

Return a borrowed raw constraint-buffer facade.

◆ dim()

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

◆ len()

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

◆ size()

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

◆ capacity()

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

◆ is_empty()

bool copp::Robot::is_empty ( ) const

◆ idx_s_range()

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

◆ has_inverse_dynamics()

bool copp::Robot::has_inverse_dynamics ( ) const

Return whether a user inverse-dynamics callback is installed.

◆ set_inverse_dynamics()

Robot & copp::Robot::set_inverse_dynamics ( InverseDynamics inverse_dynamics)

Replace the inverse-dynamics callback.

Existing station and constraint data are preserved. Future torque-limit construction and torque objectives use the new callback.

◆ clear_inverse_dynamics()

Robot & copp::Robot::clear_inverse_dynamics ( )

Restore point-mass torque evaluation (tau = ddq).

◆ append_s()

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

Append strictly increasing path station samples.

◆ set_q_2nd()

Robot & copp::Robot::set_q_2nd ( MatrixView q,
MatrixView dq,
MatrixView ddq,
std::size_t idx_s )

Store path derivatives up to second order over an existing station interval.

Matrices must have shape (dim, n) where n is the number of station columns starting at idx_s. These are the geometric derivatives q(s), dq/ds, and d2q/ds2.

◆ set_q_3rd()

Robot & copp::Robot::set_q_3rd ( MatrixView q,
MatrixView dq,
MatrixView ddq,
MatrixView dddq,
std::size_t idx_s )

Store path derivatives up to third order over an existing station interval.

Adds d3q/ds3, which is required by TOPP3/COPP3 jerk constraints.

◆ set_q_from_path_2nd()

Robot & copp::Robot::set_q_from_path_2nd ( const Path & path,
std::size_t idx_s_from,
std::size_t idx_s_to )

Sample a path and store derivatives up to second order.

The station samples must already be stored in [idx_s_from, idx_s_to). The path is evaluated at those station values and copied into the robot constraint buffer.

◆ set_q_from_path_3rd()

Robot & copp::Robot::set_q_from_path_3rd ( const Path & path,
std::size_t idx_s_from,
std::size_t idx_s_to )

Sample a path and store derivatives up to third order.

Use this before adding jerk limits or constructing third-order solver problems.

◆ add_velocity_limits() [1/2]

Robot & copp::Robot::add_velocity_limits ( Span< const double > upper,
Span< const double > lower,
std::size_t start_idx_s,
std::size_t length = 0 )

Add velocity limits from broadcast vectors.

upper and lower must have length dim. length == 0 means "infer from the currently stored station window starting at `start_idx_s`".

Parameters
upperPer-axis positive upper limits, length dim.
lowerPer-axis negative lower limits, length dim.
start_idx_sGlobal station id where the limits start.
lengthNumber of station columns to fill; 0 means infer.

◆ add_velocity_limits() [2/2]

Robot & copp::Robot::add_velocity_limits ( MatrixView upper,
MatrixView lower,
std::size_t start_idx_s )

Add velocity limits from explicit (dim x n) matrices.

◆ add_acceleration_limits() [1/2]

Robot & copp::Robot::add_acceleration_limits ( Span< const double > upper,
Span< const double > lower,
std::size_t start_idx_s,
std::size_t length = 0 )

Add acceleration limits from broadcast vectors.

Limits are physical joint-space bounds. COPP maps them into second-order path constraints using the stored q, dq, and ddq.

◆ add_acceleration_limits() [2/2]

Robot & copp::Robot::add_acceleration_limits ( MatrixView upper,
MatrixView lower,
std::size_t start_idx_s )

Add acceleration limits from explicit (dim x n) matrices.

◆ add_jerk_limits() [1/2]

Robot & copp::Robot::add_jerk_limits ( Span< const double > upper,
Span< const double > lower,
std::size_t start_idx_s,
std::size_t length = 0 )

Add jerk limits from broadcast vectors.

Requires third-order path derivatives already stored by set_q_3rd or set_q_from_path_3rd.

◆ add_jerk_limits() [2/2]

Robot & copp::Robot::add_jerk_limits ( MatrixView upper,
MatrixView lower,
std::size_t start_idx_s )

Add jerk limits from explicit (dim x n) matrices.

◆ add_torque_limits() [1/2]

Robot & copp::Robot::add_torque_limits ( Span< const double > upper,
Span< const double > lower,
std::size_t start_idx_s,
std::size_t length = 0 )

Add torque limits from broadcast vectors.

Uses the installed inverse-dynamics callback when present; otherwise uses point-mass dynamics (tau = ddq).

Note
This operation can be substantially more expensive than velocity/acceleration/jerk limits when a user callback is installed, because Rust evaluates inverse dynamics while constructing station-indexed torque constraints.

◆ add_torque_limits() [2/2]

Robot & copp::Robot::add_torque_limits ( MatrixView upper,
MatrixView lower,
std::size_t start_idx_s )

Add torque limits from explicit (dim x n) matrices.

◆ detail::robot_handle

const void * detail::robot_handle ( const Robot & robot)
friend

◆ detail::robot_handle_mut

void * detail::robot_handle_mut ( Robot & robot)
friend

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