-
Notifications
You must be signed in to change notification settings - Fork 0
/
acados_solver_back.h
183 lines (143 loc) · 6.55 KB
/
acados_solver_back.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
* Copyright (c) The acados authors.
*
* This file is part of acados.
*
* The 2-Clause BSD License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.;
*/
#ifndef ACADOS_SOLVER_back_H_
#define ACADOS_SOLVER_back_H_
#include "acados/utils/types.h"
#include "acados_c/ocp_nlp_interface.h"
#include "acados_c/external_function_interface.h"
#define BACK_NX 25
#define BACK_NZ 0
#define BACK_NU 18
#define BACK_NP 51
#define BACK_NBX 0
#define BACK_NBX0 25
#define BACK_NBU 0
#define BACK_NSBX 0
#define BACK_NSBU 0
#define BACK_NSH 6
#define BACK_NSH0 0
#define BACK_NSG 0
#define BACK_NSPHI 0
#define BACK_NSHN 0
#define BACK_NSGN 0
#define BACK_NSPHIN 0
#define BACK_NSPHI0 0
#define BACK_NSBXN 0
#define BACK_NS 6
#define BACK_NS0 0
#define BACK_NSN 0
#define BACK_NG 0
#define BACK_NBXN 0
#define BACK_NGN 0
#define BACK_NY0 74
#define BACK_NY 74
#define BACK_NYN 30
#define BACK_N 30
#define BACK_NH 6
#define BACK_NHN 0
#define BACK_NH0 0
#define BACK_NPHI0 0
#define BACK_NPHI 0
#define BACK_NPHIN 0
#define BACK_NR 0
#ifdef __cplusplus
extern "C" {
#endif
// ** capsule for solver data **
typedef struct back_solver_capsule
{
// acados objects
ocp_nlp_in *nlp_in;
ocp_nlp_out *nlp_out;
ocp_nlp_out *sens_out;
ocp_nlp_solver *nlp_solver;
void *nlp_opts;
ocp_nlp_plan_t *nlp_solver_plan;
ocp_nlp_config *nlp_config;
ocp_nlp_dims *nlp_dims;
// number of expected runtime parameters
unsigned int nlp_np;
/* external functions */
// dynamics
external_function_external_param_casadi *discr_dyn_phi_fun;
external_function_external_param_casadi *discr_dyn_phi_fun_jac_ut_xt;
// cost
external_function_external_param_casadi *cost_y_fun;
external_function_external_param_casadi *cost_y_fun_jac_ut_xt;
external_function_external_param_casadi *cost_y_hess;
external_function_external_param_casadi cost_y_0_fun;
external_function_external_param_casadi cost_y_0_fun_jac_ut_xt;
external_function_external_param_casadi cost_y_0_hess;
external_function_external_param_casadi cost_y_e_fun;
external_function_external_param_casadi cost_y_e_fun_jac_ut_xt;
external_function_external_param_casadi cost_y_e_hess;
// constraints
external_function_external_param_casadi *nl_constr_h_fun_jac;
external_function_external_param_casadi *nl_constr_h_fun;
} back_solver_capsule;
ACADOS_SYMBOL_EXPORT back_solver_capsule * back_acados_create_capsule(void);
ACADOS_SYMBOL_EXPORT int back_acados_free_capsule(back_solver_capsule *capsule);
ACADOS_SYMBOL_EXPORT int back_acados_create(back_solver_capsule * capsule);
ACADOS_SYMBOL_EXPORT int back_acados_reset(back_solver_capsule* capsule, int reset_qp_solver_mem);
/**
* Generic version of back_acados_create which allows to use a different number of shooting intervals than
* the number used for code generation. If new_time_steps=NULL and n_time_steps matches the number used for code
* generation, the time-steps from code generation is used.
*/
ACADOS_SYMBOL_EXPORT int back_acados_create_with_discretization(back_solver_capsule * capsule, int n_time_steps, double* new_time_steps);
/**
* Update the time step vector. Number N must be identical to the currently set number of shooting nodes in the
* nlp_solver_plan. Returns 0 if no error occurred and a otherwise a value other than 0.
*/
ACADOS_SYMBOL_EXPORT int back_acados_update_time_steps(back_solver_capsule * capsule, int N, double* new_time_steps);
/**
* This function is used for updating an already initialized solver with a different number of qp_cond_N.
*/
ACADOS_SYMBOL_EXPORT int back_acados_update_qp_solver_cond_N(back_solver_capsule * capsule, int qp_solver_cond_N);
ACADOS_SYMBOL_EXPORT int back_acados_update_params(back_solver_capsule * capsule, int stage, double *value, int np);
ACADOS_SYMBOL_EXPORT int back_acados_update_params_sparse(back_solver_capsule * capsule, int stage, int *idx, double *p, int n_update);
ACADOS_SYMBOL_EXPORT int back_acados_set_p_global_and_precompute_dependencies(back_solver_capsule* capsule, double* data, int data_len);
ACADOS_SYMBOL_EXPORT int back_acados_solve(back_solver_capsule * capsule);
ACADOS_SYMBOL_EXPORT void back_acados_batch_solve(back_solver_capsule ** capsules, int N_batch);
ACADOS_SYMBOL_EXPORT int back_acados_free(back_solver_capsule * capsule);
ACADOS_SYMBOL_EXPORT void back_acados_print_stats(back_solver_capsule * capsule);
ACADOS_SYMBOL_EXPORT int back_acados_custom_update(back_solver_capsule* capsule, double* data, int data_len);
ACADOS_SYMBOL_EXPORT ocp_nlp_in *back_acados_get_nlp_in(back_solver_capsule * capsule);
ACADOS_SYMBOL_EXPORT ocp_nlp_out *back_acados_get_nlp_out(back_solver_capsule * capsule);
ACADOS_SYMBOL_EXPORT ocp_nlp_out *back_acados_get_sens_out(back_solver_capsule * capsule);
ACADOS_SYMBOL_EXPORT ocp_nlp_solver *back_acados_get_nlp_solver(back_solver_capsule * capsule);
ACADOS_SYMBOL_EXPORT ocp_nlp_config *back_acados_get_nlp_config(back_solver_capsule * capsule);
ACADOS_SYMBOL_EXPORT void *back_acados_get_nlp_opts(back_solver_capsule * capsule);
ACADOS_SYMBOL_EXPORT ocp_nlp_dims *back_acados_get_nlp_dims(back_solver_capsule * capsule);
ACADOS_SYMBOL_EXPORT ocp_nlp_plan_t *back_acados_get_nlp_plan(back_solver_capsule * capsule);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // ACADOS_SOLVER_back_H_