COPP C++ API
C++ interface for COPP trajectory optimization
Loading...
Searching...
No Matches
Objectives And Clarabel

COPP solvers optimize convex objectives in addition to satisfying TOPP-style constraints. Clarabel-backed solvers also expose raw solver settings and expert diagnostics.

Include

or:

Objective Descriptors

Objective factories live in copp::objective:

std::vector<copp::Objective> objectives{
};
Objective ThermalEnergy(double weight, Span< const double > normalize)
Objective Time(double weight=1.0)

The built-in objective support is:

Objective COPP2-SOCP COPP3-SOCP
Time yes yes
ThermalEnergy yes yes
Linear yes yes
TotalVariationTorque yes yes

For Linear, expected vector lengths depend on solver order:

  • COPP2: alpha.size() == s_len, beta.size() == s_len - 1
  • COPP3: alpha.size() == s_len, beta.size() == s_len

Torque-related objectives use the robot's inverse-dynamics callback when one is installed. Otherwise they use point-mass dynamics tau = ddq.

Clarabel Options

copp::clarabel::Options combines COPP's acceptance policy with raw Clarabel settings:

options.allow_almost_solved = true;
options.clarabel_settings.verbose = false;
Shared Clarabel options for COPP/TOPP SOCP-style solvers.
Definition clarabel.hpp:117
std::uint32_t max_iter
Definition clarabel.hpp:71

copp::clarabel::Settings mirrors the current raw Clarabel setting surface, so advanced users can tune tolerances, iteration limits, linear solver choices, and equilibration behavior without dropping down to Rust.

Expert Results

solve returns only an accepted profile:

auto a = copp::solver::copp2_socp::solve(problem, options);
COPP_API std::vector< double > solve(const Problem &problem, const clarabel::Options &options={})
Solve COPP2-SOCP and return an accepted node profile a(s).

solve_expert returns diagnostics even when no profile is accepted:

auto expert = copp::solver::copp2_socp::solve_expert(problem, options);
if (expert.a) {
std::cout << "accepted profile length = " << expert.a->size() << "\n";
} else {
std::cout << "Clarabel status = "
<< static_cast<int>(expert.solver_status)
<< ", iterations = "
<< expert.iterations
<< "\n";
}
COPP_API Result solve_expert(const Problem &problem, const clarabel::Options &options={})
Solve COPP2-SOCP and always return Clarabel diagnostics.

Expert results include raw Clarabel vectors, residuals, status, objective value where applicable, per-objective terms, and linear-solver metadata.

Complete COPP2-SOCP Example

std::vector<double> s{0.0, 0.5, 1.0};
std::vector<double> amax{1.0, 1.0, 1.0};
copp::Robot robot(1, s.size());
robot.append_s(s);
robot.constraints().add_constraint_1st(amax, 0);
namespace copp2 = copp::solver::copp2_socp;
copp2::Problem problem{
robot,
copp::IndexInterval{0, s.size() - 1},
copp::Boundary2{0.0, 0.0},
};
options.allow_almost_solved = true;
auto expert = copp2::solve_expert(problem, options);
if (expert.a) {
auto time = copp::interpolation::s_to_t_topp2(s, *expert.a);
}
Robot facade backed by Rust Robot<CppRobotModel>.
Definition robot.hpp:318
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).
Second-order convex-objective Clarabel SOCP backend with normal profile-returning APIs and expert dia...
Second-order endpoint boundary values.
Definition core.hpp:77
Closed station-index interval used by TOPP/COPP problem descriptors.
Definition core.hpp:67

Tutorial Sources