COPP C ABI
C interface for COPP trajectory optimization
Loading...
Searching...
No Matches
core.h
Go to the documentation of this file.
1#ifndef COPP_CORE_H
2#define COPP_CORE_H
3
4/*
5 * Generated by bindings/c/scripts/generate_headers.ps1.
6 * Do not edit by hand; update src/ffi/c and regenerate.
7 */
8
14
15#include <stddef.h>
16#include <stdbool.h>
17#include <stdint.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
27
34typedef enum CoppStatus {
183} CoppStatus;
184
190const char *copp_status_message(enum CoppStatus status);
191
198
206const char *copp_last_error_message(void);
207
214
227enum CoppStatus copp_last_error_message_copy(char *buffer, size_t capacity, size_t *out_len);
228
233
244enum CoppStatus copp_set_last_error_message(enum CoppStatus status, const char *message);
245
257 const char *message,
258 size_t len);
259
265const char *copp_version(void);
266
288
314
368
394
561
595
606
628
647typedef struct CoppMatrixViewF64 {
651 const double *data;
655 size_t rows;
659 size_t cols;
674
680#ifdef __cplusplus
681#define COPP_MATRIX_VIEW_F64_COLUMN_MAJOR(data_, rows_, cols_) \
682 CoppMatrixViewF64{(data_), (rows_), (cols_), COPP_MATRIX_LAYOUT_COLUMN_MAJOR, (rows_)}
683#else
684#define COPP_MATRIX_VIEW_F64_COLUMN_MAJOR(data_, rows_, cols_) \
685 ((struct CoppMatrixViewF64){(data_), (rows_), (cols_), COPP_MATRIX_LAYOUT_COLUMN_MAJOR, (rows_)})
686#endif
687
694#ifdef __cplusplus
695#define COPP_MATRIX_VIEW_F64_ROW_MAJOR(data_, rows_, cols_) \
696 CoppMatrixViewF64{(data_), (rows_), (cols_), COPP_MATRIX_LAYOUT_ROW_MAJOR, (cols_)}
697#else
698#define COPP_MATRIX_VIEW_F64_ROW_MAJOR(data_, rows_, cols_) \
699 ((struct CoppMatrixViewF64){(data_), (rows_), (cols_), COPP_MATRIX_LAYOUT_ROW_MAJOR, (cols_)})
700#endif
701
708typedef struct CoppSliceF64 {
712 const double *data;
716 size_t len;
718
726typedef struct CoppSliceMutF64 {
730 double *data;
734 size_t len;
736
743typedef struct CoppVecF64 {
747 double *data;
751 size_t len;
755 size_t capacity;
756} CoppVecF64;
757
764typedef struct CoppVecUsize {
768 size_t *data;
772 size_t len;
776 size_t capacity;
778
785typedef struct CoppMatrixF64 {
789 double *data;
793 size_t rows;
797 size_t cols;
802 size_t capacity;
804
813
822
831
838struct CoppProfile3rd;
839
854 struct CoppSliceF64 x,
855 struct CoppVecF64 *out_a);
856
871 struct CoppSliceF64 x,
873 size_t num_stationary_end,
874 struct CoppProfile3rd *out_profile);
875
877
878#ifdef __cplusplus
879}
880#endif
881
882#endif /* COPP_CORE_H */
const char * copp_status_message(enum CoppStatus status)
Return a short static message for a COPP status code.
CoppClarabelSolverStatus
Clarabel solver status returned by SOCP expert results.
Definition core.h:318
const char * copp_version(void)
Return the COPP library version.
enum CoppStatus copp_clarabel_solution_to_profile_3rd(struct CoppSliceF64 s, struct CoppSliceF64 x, size_t num_stationary_start, size_t num_stationary_end, struct CoppProfile3rd *out_profile)
Extract a third-order COPP profile from a Clarabel primal solution.
void copp_vec_usize_free(struct CoppVecUsize vec)
Release a library-owned usize vector returned by COPP.
enum CoppStatus copp_last_error_code(void)
Return the status code associated with the current thread's last error.
CoppClarabelDirectSolveMethod
Direct linear solver method forwarded to Clarabel.
Definition core.h:292
CoppStatus
C ABI status code returned by COPP FFI functions.
Definition core.h:34
enum CoppStatus copp_set_last_error_message_n(enum CoppStatus status, const char *message, size_t len)
Set the current thread's last detailed error message from a byte slice.
void copp_clear_last_error(void)
Clear the current thread's last detailed error message.
enum CoppStatus copp_last_error_message_copy(char *buffer, size_t capacity, size_t *out_len)
Copy the current thread's last UTF-8 error message into a caller buffer.
enum CoppStatus copp_clarabel_solution_to_profile_2nd(size_t s_len, struct CoppSliceF64 x, struct CoppVecF64 *out_a)
Extract a second-order COPP profile from a Clarabel primal solution.
void copp_vec_f64_free(struct CoppVecF64 vec)
Release a library-owned f64 vector returned by COPP.
size_t copp_last_error_message_len(void)
Return the length in bytes of the current thread's last UTF-8 error message.
const char * copp_last_error_message(void)
Return the current thread's last detailed error message as UTF-8.
enum CoppStatus copp_clarabel_default_options(struct CoppClarabelOptions *out_options)
Write default shared Clarabel options into out_options.
void copp_matrix_f64_free(struct CoppMatrixF64 matrix)
Release a library-owned f64 matrix returned by COPP.
enum CoppStatus copp_set_last_error_message(enum CoppStatus status, const char *message)
Set the current thread's last detailed error message from a C string.
CoppMatrixLayout
Matrix memory layout used by CoppMatrixViewF64.
Definition core.h:616
CoppVerbosity
C ABI verbosity level for solver diagnostics.
Definition core.h:270
@ COPP_CLARABEL_SOLVER_STATUS_CALLBACK_TERMINATED
Solver terminated by callback.
Definition core.h:366
@ COPP_CLARABEL_SOLVER_STATUS_SOLVED
Solver terminated with a solution.
Definition core.h:326
@ COPP_CLARABEL_SOLVER_STATUS_ALMOST_DUAL_INFEASIBLE
Problem is dual infeasible with reduced accuracy.
Definition core.h:346
@ COPP_CLARABEL_SOLVER_STATUS_PRIMAL_INFEASIBLE
Problem is primal infeasible.
Definition core.h:330
@ COPP_CLARABEL_SOLVER_STATUS_INSUFFICIENT_PROGRESS
Solver terminated due to lack of progress.
Definition core.h:362
@ COPP_CLARABEL_SOLVER_STATUS_DUAL_INFEASIBLE
Problem is dual infeasible.
Definition core.h:334
@ COPP_CLARABEL_SOLVER_STATUS_ALMOST_SOLVED
Solver terminated with a reduced-accuracy solution.
Definition core.h:338
@ COPP_CLARABEL_SOLVER_STATUS_UNSOLVED
Solver has not run.
Definition core.h:322
@ COPP_CLARABEL_SOLVER_STATUS_MAX_ITERATIONS
Iteration limit reached before an accepted solution or certificate.
Definition core.h:350
@ COPP_CLARABEL_SOLVER_STATUS_NUMERICAL_ERROR
Solver terminated with a numerical error.
Definition core.h:358
@ COPP_CLARABEL_SOLVER_STATUS_MAX_TIME
Time limit reached before an accepted solution or certificate.
Definition core.h:354
@ COPP_CLARABEL_SOLVER_STATUS_ALMOST_PRIMAL_INFEASIBLE
Problem is primal infeasible with reduced accuracy.
Definition core.h:342
@ COPP_CLARABEL_DIRECT_SOLVE_METHOD_MKL
Use the optional MKL Pardiso backend when compiled into Clarabel.
Definition core.h:308
@ COPP_CLARABEL_DIRECT_SOLVE_METHOD_AUTO
Let Clarabel choose the direct solver.
Definition core.h:296
@ COPP_CLARABEL_DIRECT_SOLVE_METHOD_PANUA
Use the optional Panua Pardiso backend when compiled into Clarabel.
Definition core.h:312
@ COPP_CLARABEL_DIRECT_SOLVE_METHOD_FAER
Use the optional FAER sparse backend when compiled into Clarabel.
Definition core.h:304
@ COPP_CLARABEL_DIRECT_SOLVE_METHOD_QDLDL
Use Clarabel's QDLDL backend.
Definition core.h:300
@ COPP_STATUS_NULL_POINTER
A required pointer argument was null.
Definition core.h:42
@ COPP_STATUS_PATH_SINGULAR_SYSTEM
Internal spline/path linear system is singular.
Definition core.h:146
@ COPP_STATUS_INVALID_ARGUMENT
An unsupported enum value or option was provided through the C ABI.
Definition core.h:54
@ COPP_STATUS_CONSTRAINT_NO_MATCH_ORDER
Constraint input ordering does not match the expected contract.
Definition core.h:78
@ COPP_STATUS_CONSTRAINT_NO_MATCH_DIMENSIONS
Constraint input dimensions do not match the expected shape.
Definition core.h:74
@ COPP_STATUS_PATH_INVALID_DIMENSION
Path dimension is invalid.
Definition core.h:118
@ COPP_STATUS_SOLVER_INVALID_OPTIONS
Solver rejected the provided options.
Definition core.h:166
@ COPP_STATUS_PATH_NOT_ENOUGH_WAYPOINTS
Not enough waypoints were supplied to build a path.
Definition core.h:134
@ COPP_STATUS_PANIC
COPP caught an internal panic at the C ABI boundary.
Definition core.h:58
@ COPP_STATUS_CONSTRAINT_INFEASIBLE_REFERENCE
Reference profile is infeasible under current constraints.
Definition core.h:110
@ COPP_STATUS_CONSTRAINT_NO_GIVEN_Q_INFO
Required path derivative data is missing.
Definition core.h:98
@ COPP_STATUS_CONSTRAINT_OUT_OF_S_BOUNDS
Requested station interval is outside the stored constraint range.
Definition core.h:86
@ COPP_STATUS_PATH_UNSUPPORTED_DERIVATIVE_ORDER
Requested path derivative order is not supported by this path.
Definition core.h:150
@ COPP_STATUS_CONSTRAINT_NON_POSITIVE_LINEARIZATION_FLOOR
Linearization floor is not strictly positive.
Definition core.h:94
@ COPP_STATUS_CONSTRAINT_INVALID_SIGNED_BOUNDS
Signed upper/lower bounds do not satisfy strict feasibility rules.
Definition core.h:82
@ COPP_STATUS_CONSTRAINT_NON_POSITIVE_A
Profile a violates positivity requirements.
Definition core.h:90
@ COPP_STATUS_IO_ERROR
Filesystem or OS I/O failure.
Definition core.h:66
@ COPP_STATUS_INVALID_SHAPE
A matrix/vector shape was invalid.
Definition core.h:50
@ COPP_STATUS_ALLOCATION_FAILED
A memory allocation failed or an output buffer could not be created.
Definition core.h:62
@ COPP_STATUS_PATH_UNSUPPORTED_BOUNDARY
Requested spline boundary condition is unsupported.
Definition core.h:142
@ COPP_STATUS_INVALID_LENGTH
A slice length or vector length was invalid.
Definition core.h:46
@ COPP_STATUS_SOLVER_UNBOUNDED
Solver reported unboundedness.
Definition core.h:158
@ COPP_STATUS_PATH_DIMENSION_MISMATCH
Path matrix/tensor dimensions are incompatible.
Definition core.h:130
@ COPP_STATUS_CONSTRAINT_EMPTY_INTERVAL
Requested constraint interval is empty.
Definition core.h:114
@ COPP_STATUS_SOLVER_OTHER
Backend-specific or uncategorized solver/runtime error.
Definition core.h:178
@ COPP_STATUS_CONSTRAINT_NO_DYNAMIC
Required dynamic-model data is unavailable.
Definition core.h:106
@ COPP_STATUS_OK
Operation completed successfully.
Definition core.h:38
@ COPP_STATUS_CONSTRAINT_NON_INCREASING_S
Constraint input s is not strictly increasing.
Definition core.h:70
@ COPP_STATUS_CLARABEL_SOLVER_ERROR
Clarabel returned an internal solver error.
Definition core.h:170
@ COPP_STATUS_CLARABEL_SOLVER_STATUS
Clarabel terminated with a non-success status.
Definition core.h:174
@ COPP_STATUS_PATH_OUT_OF_RANGE_S
Query parameter is outside the configured path range.
Definition core.h:138
@ COPP_STATUS_PATH_INVALID_ORDER
Spline order is invalid.
Definition core.h:126
@ COPP_STATUS_ROBOT_DYNAMICS_ERROR
User-provided robot inverse dynamics failed.
Definition core.h:182
@ COPP_STATUS_SOLVER_INVALID_INPUT
Solver rejected the input model or data.
Definition core.h:162
@ COPP_STATUS_SOLVER_INFEASIBLE
Solver reported infeasibility.
Definition core.h:154
@ COPP_STATUS_PATH_INVALID_RANGE
Path parameter range is invalid.
Definition core.h:122
@ COPP_STATUS_CONSTRAINT_LINEAR_JERK_NOT_AVAILABLE
Linearized jerk constraints are unavailable for the requested station.
Definition core.h:102
@ COPP_MATRIX_LAYOUT_COLUMN_MAJOR
Column-major storage: element (row, col) is at data[row + col * leading_dim].
Definition core.h:621
@ COPP_MATRIX_LAYOUT_ROW_MAJOR
Row-major storage: element (row, col) is at data[col + row * leading_dim].
Definition core.h:626
@ COPP_VERBOSITY_DEBUG
Detailed debug information will be emitted.
Definition core.h:282
@ COPP_VERBOSITY_SILENT
No log will be emitted.
Definition core.h:274
@ COPP_VERBOSITY_SUMMARY
Only summary information will be emitted.
Definition core.h:278
@ COPP_VERBOSITY_TRACE
Very detailed trace information will be emitted.
Definition core.h:286
Linear solver metadata reported by Clarabel.
Definition core.h:372
bool direct
Whether the linear solver used a direct factorization method.
Definition core.h:384
size_t nnz_a
Number of nonzeros in the linear system.
Definition core.h:388
size_t threads
Number of threads used by the linear solver.
Definition core.h:380
enum CoppClarabelDirectSolveMethod method
Linear solver method name mapped to COPP's stable enum.
Definition core.h:376
size_t nnz_l
Number of nonzeros in the factored system.
Definition core.h:392
Shared Clarabel options for COPP SOCP solvers.
Definition core.h:565
struct CoppClarabelSettings clarabel_settings
Advanced raw Clarabel solver settings.
Definition core.h:593
bool allow_callback_terminated
Accept Clarabel status CallbackTerminated as usable.
Definition core.h:585
bool allow_insufficient_progress
Accept Clarabel status InsufficientProgress as usable.
Definition core.h:589
enum CoppVerbosity verbosity
Crate-level verbosity for COPP assembly diagnostics.
Definition core.h:569
bool allow_almost_solved
Accept Clarabel status AlmostSolved as usable.
Definition core.h:573
bool allow_max_iterations
Accept Clarabel status MaxIterations as usable.
Definition core.h:577
bool allow_max_time
Accept Clarabel status MaxTime as usable.
Definition core.h:581
Advanced raw Clarabel solver settings.
Definition core.h:403
double reduced_tol_infeas_rel
Reduced relative infeasibility tolerance for almost-solved status.
Definition core.h:463
double tol_ktratio
Kappa/tau tolerance.
Definition core.h:443
double min_switch_step_length
Minimum step length for asymmetric-cone switching.
Definition core.h:491
bool equilibrate_enable
Enable data equilibration before solving.
Definition core.h:471
double min_terminate_step_length
Minimum step length for termination checks.
Definition core.h:495
double reduced_tol_infeas_abs
Reduced absolute infeasibility tolerance for almost-solved status.
Definition core.h:459
bool dynamic_regularization_enable
Enable dynamic KKT regularization.
Definition core.h:523
double dynamic_regularization_eps
Dynamic regularization threshold.
Definition core.h:527
uint32_t equilibrate_max_iter
Maximum number of equilibration iterations.
Definition core.h:475
uint32_t iterative_refinement_max_iter
Iterative-refinement maximum iterations.
Definition core.h:547
bool presolve_enable
Enable Clarabel presolve.
Definition core.h:555
bool input_sparse_dropzeros
Drop structural zeros from sparse inputs before solving.
Definition core.h:559
uint32_t max_threads
Maximum solver threads.
Definition core.h:499
double reduced_tol_feas
Reduced feasibility tolerance for almost-solved status.
Definition core.h:455
double equilibrate_max_scaling
Maximum equilibration scaling.
Definition core.h:483
bool direct_kkt_solver
Whether to use a direct KKT solver.
Definition core.h:503
double tol_infeas_rel
Relative infeasibility tolerance.
Definition core.h:439
double time_limit
Maximum solve time in seconds.
Definition core.h:411
double static_regularization_proportional
Static KKT regularization proportional term.
Definition core.h:519
double equilibrate_min_scaling
Minimum equilibration scaling.
Definition core.h:479
enum CoppClarabelDirectSolveMethod direct_solve_method
Direct linear solver method.
Definition core.h:507
double iterative_refinement_reltol
Iterative-refinement relative tolerance.
Definition core.h:539
uint32_t max_iter
Maximum number of interior-point iterations.
Definition core.h:407
double iterative_refinement_stop_ratio
Iterative-refinement stalling ratio.
Definition core.h:551
double linesearch_backtrack_step
Backtracking factor used by the line search.
Definition core.h:487
double tol_feas
Primal/dual feasibility tolerance.
Definition core.h:431
bool iterative_refinement_enable
Enable iterative refinement for direct solves.
Definition core.h:535
double tol_gap_rel
Relative duality-gap tolerance.
Definition core.h:427
double tol_gap_abs
Absolute duality-gap tolerance.
Definition core.h:423
double iterative_refinement_abstol
Iterative-refinement absolute tolerance.
Definition core.h:543
double reduced_tol_gap_rel
Reduced relative duality-gap tolerance for almost-solved status.
Definition core.h:451
double max_step_fraction
Maximum interior-point step length.
Definition core.h:419
double dynamic_regularization_delta
Dynamic regularization shift.
Definition core.h:531
double reduced_tol_gap_abs
Reduced absolute duality-gap tolerance for almost-solved status.
Definition core.h:447
bool static_regularization_enable
Enable static KKT regularization.
Definition core.h:511
double tol_infeas_abs
Absolute infeasibility tolerance.
Definition core.h:435
double static_regularization_constant
Static KKT regularization constant.
Definition core.h:515
double reduced_tol_ktratio
Reduced kappa/tau tolerance for almost-solved status.
Definition core.h:467
bool verbose
Enable Clarabel's internal solver log.
Definition core.h:415
Library-owned column-major f64 matrix returned to C.
Definition core.h:785
size_t cols
Number of matrix columns.
Definition core.h:797
size_t rows
Number of matrix rows.
Definition core.h:793
double * data
Pointer to the first column-major element, or null for an empty matrix.
Definition core.h:789
size_t capacity
Allocation capacity in number of double elements, used only by copp_matrix_f64_free.
Definition core.h:802
Borrowed immutable f64 matrix passed from C to COPP.
Definition core.h:647
size_t leading_dim
Leading dimension / physical stride.
Definition core.h:672
enum CoppMatrixLayout layout
Matrix memory layout.
Definition core.h:663
const double * data
Pointer to the first matrix element.
Definition core.h:651
size_t rows
Number of matrix rows.
Definition core.h:655
size_t cols
Number of matrix columns.
Definition core.h:659
Owned third-order profile returned by TOPP3/COPP3 C ABI solvers.
Definition formulation.h:168
size_t num_stationary_end
Effective stationary interval count at the end.
Definition formulation.h:184
size_t num_stationary_start
Effective stationary interval count at the start.
Definition formulation.h:180
Borrowed immutable f64 slice passed from C to COPP.
Definition core.h:708
const double * data
Pointer to the first element.
Definition core.h:712
size_t len
Number of elements.
Definition core.h:716
Borrowed mutable f64 slice passed from C to COPP.
Definition core.h:726
double * data
Pointer to the first mutable element.
Definition core.h:730
size_t len
Number of elements.
Definition core.h:734
Library-owned f64 vector returned to C.
Definition core.h:743
size_t capacity
Allocation capacity, used only by copp_vec_f64_free.
Definition core.h:755
size_t len
Number of initialized elements.
Definition core.h:751
double * data
Pointer to the first element, or null for an empty vector.
Definition core.h:747
Library-owned usize vector returned to C.
Definition core.h:764
size_t len
Number of initialized elements.
Definition core.h:772
size_t capacity
Allocation capacity, used only by copp_vec_usize_free.
Definition core.h:776
size_t * data
Pointer to the first element, or null for an empty vector.
Definition core.h:768