11#include <acados/utils/math.h>
12#include <acados/utils/print.h>
13#include <acados_c/external_function_interface.h>
14#include <acados_c/ocp_nlp_interface.h>
15#include <blasfeo_d_aux_ext_dep.h>
18#include <trajectory_optimization_ocp/acados_solver_karl.h>
19#include <trajectory_optimization_ocp/acados_solver_shuttle.h>
33 if (model_name ==
"karl") {
34 return karl_acados_create_capsule();
35 }
else if (model_name ==
"shuttle") {
36 return shuttle_acados_create_capsule();
38 throw std::invalid_argument(
"Invalid model name: " + model_name);
42#define ACADOS_DISPATCH(function_name, ...) \
43 if (std::holds_alternative<karl_solver_capsule*>(capsule)) { \
44 return karl_##function_name(std::get<karl_solver_capsule*>(capsule), ##__VA_ARGS__); \
45 } else if (std::holds_alternative<shuttle_solver_capsule*>(capsule)) { \
46 return shuttle_##function_name(std::get<shuttle_solver_capsule*>(capsule), ##__VA_ARGS__); \
48 throw std::invalid_argument("Invalid capsule type."); \
105 std::array<ext_fun_arg_t, 2> input_types = {COLMAJ, COLMAJ};
106 std::array<void*, 2> inputs = {x, u};
107 std::array<ext_fun_arg_t, 1> output_types = {COLMAJ};
108 std::array<void*, 1> outputs = {x_dot};
110 external_function_external_param_casadi* function =
nullptr;
112 if (std::holds_alternative<karl_solver_capsule*>(capsule)) {
113 function = &std::get<karl_solver_capsule*>(capsule)->expl_ode_fun[stage];
114 }
else if (std::holds_alternative<shuttle_solver_capsule*>(capsule)) {
115 function = &std::get<shuttle_solver_capsule*>(capsule)->expl_ode_fun[stage];
117 throw std::invalid_argument(
"Invalid capsule type.");
119 function->evaluate(function, input_types.data(), inputs.data(), output_types.data(), outputs.data());
126 int reset_qp_solver_mem,
127 int reset_numerical_values,
128 int reset_solver_options,
129 int reset_x_to_x0_bar) {
Namespace for trajectory_optimization package.
int acados_solve(ocp_model_capsule_t capsule)
Wrapper around the generated acados solve function.
void acados_print_stats(ocp_model_capsule_t capsule)
Wrapper around the generated acados statistics printer.
int acados_free(ocp_model_capsule_t capsule)
Wrapper around the generated acados solver cleanup function.
ocp_nlp_solver * acados_get_nlp_solver(ocp_model_capsule_t capsule)
Wrapper around the generated accessor for the OCP solver instance.
ocp_nlp_out * acados_get_nlp_out(ocp_model_capsule_t capsule)
Wrapper around the generated accessor for the OCP output structure.
ocp_nlp_config * acados_get_nlp_config(ocp_model_capsule_t capsule)
Wrapper around the generated accessor for the OCP configuration.
int acados_create(ocp_model_capsule_t capsule)
Wrapper around the generated acados create function for the selected model.
int acados_create_with_discretization(ocp_model_capsule_t capsule, int n_time_steps, double *new_time_steps)
Wrapper around the generated acados create function with custom discretization.
void * acados_get_nlp_opts(ocp_model_capsule_t capsule)
Wrapper around the generated accessor for the OCP solver options.
int acados_free_capsule(ocp_model_capsule_t capsule)
Wrapper around the generated acados capsule cleanup function.
int acados_update_params_sparse(ocp_model_capsule_t capsule, int stage, int *idx, double *p, int n_update)
Wrapper around the generated sparse parameter update function.
ocp_model_capsule_t acados_create_capsule(const std::string &model_name)
Creates the model-specific acados capsule selected by the configured model name.
ocp_nlp_dims * acados_get_nlp_dims(ocp_model_capsule_t capsule)
Wrapper around the generated accessor for the OCP dimensions.
int acados_reset(ocp_model_capsule_t capsule, int reset_qp_solver_mem, int reset_numerical_values, int reset_solver_options, int reset_x_to_x0_bar)
Resets selected solver memory without freeing and recreating the capsule.
ocp_nlp_in * acados_get_nlp_in(ocp_model_capsule_t capsule)
Wrapper around the generated accessor for the OCP input structure.
std::variant< karl_solver_capsule *, shuttle_solver_capsule * > ocp_model_capsule_t
void acados_evaluate_dynamics(ocp_model_capsule_t capsule, int stage, double *x, double *u, double *x_dot)
Evaluates the explicit model dynamics for a shooting stage.
int acados_set_p_global_and_precompute_dependencies(ocp_model_capsule_t capsule, double *data, int data_len)
Wrapper around the generated global-parameter update function.
#define ACADOS_DISPATCH(function_name,...)