ocp_nlp_interface

Typedefs

typedef struct ocp_nlp_plan_t ocp_nlp_plan_t

Structure to store the configuration of a non-linear program.

typedef struct ocp_nlp_solver ocp_nlp_solver

Structure to store the state/configuration for the non-linear programming solver.

Enums

enum ocp_nlp_solver_t

Solution methods for optimal control problems.

Values:

enumerator SQP
enumerator SQP_RTI
enumerator INVALID_NLP_SOLVER
enum ocp_nlp_cost_t

Types of the cost function.

Values:

enumerator LINEAR_LS
enumerator NONLINEAR_LS
enumerator CONVEX_OVER_NONLINEAR
enumerator EXTERNAL
enumerator INVALID_COST
enum ocp_nlp_dynamics_t

Types of the system dynamics, discrete or continuous time.

Values:

enumerator CONTINUOUS_MODEL
enumerator DISCRETE_MODEL
enumerator INVALID_DYNAMICS
enum ocp_nlp_constraints_t

Constraint types.

Values:

enumerator BGH

Comprises simple bounds, polytopic constraints, general non-linear constraints.

enumerator BGP

Comprises simple bounds, polytopic constraints, general non-linear constraints, and positive definite constraints.

enumerator INVALID_CONSTRAINT
enum ocp_nlp_reg_t

Regularization types.

Values:

enumerator NO_REGULARIZE
enumerator MIRROR
enumerator PROJECT
enumerator PROJECT_REDUC_HESS
enumerator CONVEXIFY
enumerator INVALID_REGULARIZE

Functions

ACADOS_SYMBOL_EXPORT ocp_nlp_plan_t * ocp_nlp_plan_create (int N)

Constructs an empty plan struct (user nlp configuration), all fields are set to a default/invalid state.

Parameters
  • N: Horizon length

ACADOS_SYMBOL_EXPORT void ocp_nlp_plan_destroy (void *plan_)

Destructor for plan struct, frees memory.

Parameters
  • plan_: The plan struct to destroy.

ACADOS_SYMBOL_EXPORT ocp_nlp_config * ocp_nlp_config_create (ocp_nlp_plan_t plan)

Constructs an nlp configuration struct from a plan.

Parameters
  • plan: The plan (user nlp configuration).

ACADOS_SYMBOL_EXPORT void ocp_nlp_config_destroy (void *config_)

Desctructor of the nlp configuration.

Parameters
  • config_: The configuration struct.

ACADOS_SYMBOL_EXPORT ocp_nlp_dims * ocp_nlp_dims_create (void *config_)

Constructs an struct that contains the dimensions of the variables.

Parameters
  • config_: The configuration struct.

ACADOS_SYMBOL_EXPORT void ocp_nlp_dims_destroy (void *dims_)

Destructor of The dimension struct.

Parameters
  • dims_: The dimension struct.

ACADOS_SYMBOL_EXPORT ocp_nlp_in * ocp_nlp_in_create (ocp_nlp_config *config, ocp_nlp_dims *dims)

Constructs an input struct for a non-linear programs.

Parameters
  • config: The configuration struct.

  • dims: The dimension struct.

ACADOS_SYMBOL_EXPORT void ocp_nlp_in_destroy (void *in)

Destructor of the inputs struct.

Parameters
  • in: The inputs struct.

ACADOS_SYMBOL_EXPORT void ocp_nlp_in_set (ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, int stage, const char *field, void *value)

Sets the sampling times for the given stage.

Parameters
  • config: The configuration struct.

  • dims: The dimension struct.

  • in: The inputs struct.

  • stage: Stage number.

  • field: Has to be “Ts” (TBC other options).

  • value: The sampling times (floating point).

ACADOS_SYMBOL_EXPORT int ocp_nlp_dynamics_model_set (ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, int stage, const char *fun_type, void *fun_ptr)

Sets the function pointers to the dynamics functions for the given stage.

Parameters
  • config: The configuration struct.

  • dims: The dimension struct.

  • in: The inputs struct.

  • stage: Stage number.

  • fun_type: The name of the function type, either impl_ode_fun, impl_ode_fun_jac_x_xdot, impl_ode_jac_x_xdot_u (TBC)

  • fun_ptr: Function pointer to the dynamics function.

ACADOS_SYMBOL_EXPORT int ocp_nlp_cost_model_set (ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, int stage, const char *field, void *value)

Sets the function pointers to the cost functions for the given stage.

Parameters
  • config: The configuration struct.

  • dims: The dimension struct.

  • in: The inputs struct.

  • stage: Stage number.

  • field: The name of the field, either nls_res_jac, y_ref, W (others TBC)

  • value: Cost values.

ACADOS_SYMBOL_EXPORT int ocp_nlp_constraints_model_set (ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, int stage, const char *field, void *value)

Sets the function pointers to the constraints functions for the given stage.

Parameters
  • config: The configuration struct.

  • dims: The dimension struct.

  • in: The inputs struct.

  • stage: Stage number.

  • field: The name of the field, either lb, ub (others TBC)

  • value: Constraints function or values.

ACADOS_SYMBOL_EXPORT void ocp_nlp_constraints_model_get (ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *in, int stage, const char *field, void *value)
ACADOS_SYMBOL_EXPORT ocp_nlp_out * ocp_nlp_out_create (ocp_nlp_config *config, ocp_nlp_dims *dims)

Constructs an output struct for the non-linear program.

Parameters
  • config: The configuration struct.

  • dims: The dimension struct.

ACADOS_SYMBOL_EXPORT void ocp_nlp_out_destroy (void *out)

Destructor of the output struct.

Parameters
  • out: The output struct.

ACADOS_SYMBOL_EXPORT void ocp_nlp_out_set (ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, int stage, const char *field, void *value)

Sets fields in the output struct of an nlp solver, used to initialize the solver.

Parameters
  • config: The configuration struct.

  • dims: The dimension struct.

  • out: The output struct.

  • stage: Stage number.

  • field: The name of the field, either x, u, pi.

  • value: Initialization values.

ACADOS_SYMBOL_EXPORT void ocp_nlp_out_get (ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, int stage, const char *field, void *value)

Gets values of fields in the output struct of an nlp solver.

Parameters
  • config: The configuration struct.

  • dims: The dimension struct.

  • out: The output struct.

  • stage: Stage number.

  • field: The name of the field, either x, u, z, pi.

  • value: Pointer to the output memory.

ACADOS_SYMBOL_EXPORT void ocp_nlp_get_at_stage (ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_solver *solver, int stage, const char *field, void *value)
ACADOS_SYMBOL_EXPORT int ocp_nlp_dims_get_from_attr (ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, int stage, const char *field)
ACADOS_SYMBOL_EXPORT void ocp_nlp_constraint_dims_get_from_attr (ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, int stage, const char *field, int *dims_out)
ACADOS_SYMBOL_EXPORT void ocp_nlp_cost_dims_get_from_attr (ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, int stage, const char *field, int *dims_out)
ACADOS_SYMBOL_EXPORT void ocp_nlp_qp_dims_get_from_attr (ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_out *out, int stage, const char *field, int *dims_out)
ACADOS_SYMBOL_EXPORT void * ocp_nlp_solver_opts_create (ocp_nlp_config *config, ocp_nlp_dims *dims)

Creates an options struct for the non-linear program.

Parameters
  • config: The configuration struct.

  • dims: The dimension struct.

ACADOS_SYMBOL_EXPORT void ocp_nlp_solver_opts_destroy (void *opts)

Destructor of the options.

Parameters
  • opts: The options struct.

ACADOS_SYMBOL_EXPORT void ocp_nlp_solver_opts_set (ocp_nlp_config *config, void *opts_, const char *field, void *value)

Sets an option.

Parameters
  • config: The configuration struct.

  • opts_: The options struct.

  • field: Name of the option.

  • value: Value of the option.

ACADOS_SYMBOL_EXPORT void ocp_nlp_solver_opts_set_at_stage (ocp_nlp_config *config, void *opts_, int stage, const char *field, void *value)
ACADOS_SYMBOL_EXPORT void ocp_nlp_solver_opts_update (ocp_nlp_config *config, ocp_nlp_dims *dims, void *opts_)

TBC Updates the options.

Parameters
  • config: The configuration struct.

  • dims: The dimension struct.

  • opts_: The options struct.

ACADOS_SYMBOL_EXPORT ocp_nlp_solver * ocp_nlp_solver_create (ocp_nlp_config *config, ocp_nlp_dims *dims, void *opts_)

Creates an ocp solver.

Return

The solver.

Parameters
  • config: The configuration struct.

  • dims: The dimension struct.

  • opts_: The options struct.

ACADOS_SYMBOL_EXPORT void ocp_nlp_solver_destroy (void *solver)

Destructor of the solver.

Parameters
  • solver: The solver struct.

ACADOS_SYMBOL_EXPORT int ocp_nlp_solve (ocp_nlp_solver *solver, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out)

Solves the optimal control problem.

Call ocp_nlp_precompute before calling this functions (TBC).

Parameters
  • solver: The solver struct.

  • nlp_in: The inputs struct.

  • nlp_out: The output struct.

ACADOS_SYMBOL_EXPORT void ocp_nlp_solver_reset_qp_memory (ocp_nlp_solver *solver, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out)

Resets the memory of the QP solver.

Parameters
  • solver: The solver struct.

  • nlp_in: The inputs struct.

  • nlp_out: The output struct.

ACADOS_SYMBOL_EXPORT int ocp_nlp_precompute (ocp_nlp_solver *solver, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out)

Performs precomputations for the solver.

Needs to be called before ocl_nlp_solve (TBC).

Parameters
  • solver: The solver struct.

  • nlp_in: The inputs struct.

  • nlp_out: The output struct.

ACADOS_SYMBOL_EXPORT void ocp_nlp_eval_cost (ocp_nlp_solver *solver, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out)

Computes cost function value.

Parameters
  • solver: The solver struct.

  • nlp_in: The inputs struct.

  • nlp_out: The output struct.

ACADOS_SYMBOL_EXPORT void ocp_nlp_eval_residuals (ocp_nlp_solver *solver, ocp_nlp_in *nlp_in, ocp_nlp_out *nlp_out)

Computes the residuals.

Parameters
  • solver: The solver struct.

  • nlp_in: The inputs struct.

  • nlp_out: The output struct.

ACADOS_SYMBOL_EXPORT void ocp_nlp_eval_param_sens (ocp_nlp_solver *solver, char *field, int stage, int index, ocp_nlp_out *sens_nlp_out)
ACADOS_SYMBOL_EXPORT void ocp_nlp_get (ocp_nlp_config *config, ocp_nlp_solver *solver, const char *field, void *return_value_)

Parameters
  • config: The configuration struct.

  • solver: The solver struct.

  • field: Supports “sqp_iter”, “status”, “nlp_res”, “time_tot”, …

  • return_value_: Pointer to the output memory.

ACADOS_SYMBOL_EXPORT void ocp_nlp_set (ocp_nlp_config *config, ocp_nlp_solver *solver, int stage, const char *field, void *value)

Sets the initial guesses for the integrator for the given stage.

Parameters
  • config: The configuration struct.

  • solver: The ocp_nlp_solver struct.

  • stage: Stage number.

  • field: Supports “z_guess”, “xdot_guess” (IRK), “phi_guess” (GNSF-IRK)

  • value: The initial guess for the algebraic variables in the integrator (if continuous model is used).

struct ocp_nlp_plan_t
#include <ocp_nlp_interface.h>

Structure to store the configuration of a non-linear program.

Public Members

ocp_qp_solver_plan_t ocp_qp_solver_plan

QP solver configuration.

sim_solver_plan_t *sim_solver_plan

Simulation solver configuration for each stage.

ocp_nlp_solver_t nlp_solver

Nlp solver type.

ocp_nlp_reg_t regularization

Regularization type, defaults to no regularization.

ocp_nlp_cost_t *nlp_cost

Cost type for each stage.

ocp_nlp_dynamics_t *nlp_dynamics

Dynamics type for each stage.

ocp_nlp_constraints_t *nlp_constraints

Constraints type for each stage.

int N

Horizon length.

struct ocp_nlp_solver
#include <ocp_nlp_interface.h>

Structure to store the state/configuration for the non-linear programming solver.

Public Members

ocp_nlp_config *config
void *dims
void *opts
void *mem
void *work