Build for DS1401 is failing

Hi,

I am using Acados in Simulink and trying to build the code for DS140. I have successfully cross compiled Acados for DS1401. I use Matlab 2021b. I end up with the following warnings and errors:

COMPILING “AutoboxModel.c”
COMPILING “AutoboxModel_trc_ptr.c”
COMPILING “rtGetInf.c”
COMPILING “rtGetNaN.c”
COMPILING “rt_nonfinite.c”
COMPILING “C:\AcadosBuilds\c_generated_code\acados_mex_create_MPC_OCP.c”
(I) C0228-D; “C:\Git\acados\buildDS1401\install\include\hpipm/include/hpipm_common.h”, line 54 pos 8; trailing comma is nonstandard
ROBUST, // focus on robustness, relative IPM formulation
^
(I) C0228-D; “C:\Git\acados\buildDS1401\install\include\hpipm/include/hpipm_common.h”, line 63 pos 11; trailing comma is nonstandard
INCONS_EQ, // unconsistent equality constraints
^
(I) C0228-D; “C:\Git\acados\buildDS1401\install\include\acados/utils/types.h”, line 83 pos 23; trailing comma is nonstandard
ACADOS_TIMEOUT = 7,
^
(I) C0228-D; “C:\Git\acados\buildDS1401\install\include\acados/utils/types.h”, line 94 pos 17; trailing comma is nonstandard
INVALID_COST,
^
(I) C0228-D; “C:\Git\acados\buildDS1401\install\include\acados/utils/types.h”, line 105 pos 7; trailing comma is nonstandard
ZERO,
^
(I) C0228-D; “C:\Git\acados\buildDS1401\install\include\acados/sim/sim_collocation_utils.h”, line 72 pos 25; trailing comma is nonstandard
EXPLICIT_RUNGE_KUTTA,
^
(E) C0070; “C:\Git\acados\buildDS1401\install\include\acados/utils/timing.h”, line 105 pos 21; incomplete type is not allowed
struct timespec tic;
^
(E) C0070; “C:\Git\acados\buildDS1401\install\include\acados/utils/timing.h”, line 106 pos 21; incomplete type is not allowed
struct timespec toc;
^
(I) C0228-D; “C:\Git\acados\buildDS1401\install\include\acados_c/ocp_qp_interface.h”, line 102 pos 22; trailing comma is nonstandard
INVALID_QP_SOLVER,
^
(I) C0228-D; “C:\Git\acados\buildDS1401\install\include\acados_c/sim_interface.h”, line 49 pos 23; trailing comma is nonstandard
INVALID_SIM_SOLVER,
^
(I) C0228-D; “C:\Git\acados\buildDS1401\install\include\acados_c/ocp_nlp_interface.h”, line 58 pos 23; trailing comma is nonstandard
INVALID_NLP_SOLVER,
^
(I) C0228-D; “C:\Git\acados\buildDS1401\install\include\acados_c/ocp_nlp_interface.h”, line 67 pos 21; trailing comma is nonstandard
INVALID_DYNAMICS,
^
(I) C0228-D; “C:\Git\acados\buildDS1401\install\include\acados_c/ocp_nlp_interface.h”, line 82 pos 23; trailing comma is nonstandard
INVALID_CONSTRAINT,
^
(I) C0228-D; “C:\Git\acados\buildDS1401\install\include\acados_c/ocp_nlp_interface.h”, line 94 pos 23; trailing comma is nonstandard
INVALID_REGULARIZE,
^
(E) C0020; “C:\Matlab\R2021b\extern\include\matrix.h”, line 227 pos 9; identifier “int64_T” is undefined
typedef int64_T mxInt64;
^
(E) C0020; “C:\Matlab\R2021b\extern\include\matrix.h”, line 228 pos 9; identifier “uint64_T” is undefined
typedef uint64_T mxUint64;
^
4 Errors 12 Informationals

COMPILING FAILED (1)

MAKE PROCESS ABORTED

So mainly I have 2 errors:

(E) C0020; “C:\Matlab\R2021b\extern\include\matrix.h”, line 227 pos 9; identifier “int64_T” is undefined
typedef int64_T mxInt64;
^

and

(E) C0070; “C:\Git\acados\buildDS1401\install\include\acados/utils/timing.h”, line 105 pos 21; incomplete type is not allowed
struct timespec tic;
^

And some warnings for commas.

How can I solve these 2 errors? I believe int64_T should already be defined in tmwtypes.h in C:\Matlab\R2021b\extern\include\tmwtypes.h and I included the header file and its folder in the Code Generation settings.

Thanks in advance!
Umur

Hi again,

I was able to fix these errors in the following ways:

For uint64_T and int64_T, I added the following lines into timing.h :

#ifndef int64_T
typedef long long int int64_T;
#endif

#ifndef uint64_T
typedef unsigned long long int uint64_T;
#endif

For timespec problem, I have commented out the following part that corresponds to else loop (ANSI C Mode) :

/** A structure for keeping internal timer data. */
/*typedef struct acados_timer_
{
    struct timespec tic;
    struct timespec toc;
} acados_timer;*/

And instead added the following code:

#include <C:\dSPACE_RCPHIL_2021-B\DS1401\RTLib\brtenv.h>

typedef struct acados_timer_
{
    double time;
} acados_timer;

Actually what I added corresponds to one of the elif loops ( defined(MABX2) ). I am using DS1401, hence MABX2, I am suprised for the fact that why is ( defined(MABX2) not TRUE…

Later on, I had another problem, regarding, mex_macros.h not being in the path… Then I copy pasted it under one of the include directories: C:\Git\acados\buildDS1401\install\include .

Then compilation was successfull but linking raised errors.

One problem I faced was fmin and isinf not being recognized… I am not quite sure for the reason, but apperently, somehow the compiler is using C89, not C99, so I added them in a custom_math.c and custom_math.h as:

custom_math.c

#include <float.h>

double fmin(double a, double b) {
    return (a < b) ? a : b;
}

int isinf(double x) {
    return (x == DBL_MAX || x == -DBL_MAX);
}

custom_math.h

#ifndef CUSTOM_MATH_H
#define CUSTOM_MATH_H

double fmin(double a, double b);
int isinf(double x);

#endif // CUSTOM_MATH_H

Put them under the same include directory that was already included in the include directories under Custom Code settings: C:\Git\acados\buildDS1401\install\include . And also added “C:\Git\acados\buildDS1401\install\include\custom_math.c” into source files list under custom code settings.

Second problem I faced was “#A0329-D Reserved memory overlapped from address 0x3000000 to 0x3000927”. This was due to my application size being too large. I had some constant blocks calling some big time series data from workspace (in total 20 mb of time series data). Then I removed them, and I fixed that problem.

Lastly, I had problems regarding which c files to include under source files. According to Step 3: Prepare and build Simulink model, I should include all c files under c_generated_code. However, I think that is not correct (?). Because it complaines a lot for some functions being already defined by previously called files (such as main, etc). This is error code (E) #A0307-D. I have included and excluded the c files as shown below:

NOT INCLUDED

C:\acadosbuilds2\c_generated_code\acados_mex_create_MPC_OCP_multiAxleTrailer.c
C:\acadosbuilds2\c_generated_code\acados_mex_free_MPC_OCP_multiAxleTrailer.c
C:\acadosbuilds2\c_generated_code\acados_mex_reset_MPC_OCP_multiAxleTrailer.c
C:\acadosbuilds2\c_generated_code\acados_mex_set_MPC_OCP_multiAxleTrailer.c
C:\acadosbuilds2\c_generated_code\acados_mex_solve_MPC_OCP_multiAxleTrailer.c
C:\acadosbuilds2\c_generated_code\acados_solver_sfunction_MPC_OCP_multiAxleTrailer.c
C:\acadosbuilds2\c_generated_code\acados_sim_solver_sfunction_MPC_OCP_multiAxleTrailer.c
C:\acadosbuilds2\c_generated_code\CMakeFiles\3.31.0\CompilerIdC\CMakeCCompilerId.c
C:\acadosbuilds2\c_generated_code\main_sim_MPC_OCP_multiAxleTrailer.c
C:\acadosbuilds2\c_generated_code\acados_sim_solver_MPC_OCP_multiAxleTrailer.c
C:\acadosbuilds2\c_generated_code\main_MPC_OCP_multiAxleTrailer.c

INCLUDED

C:\acadosbuilds2\c_generated_code\acados_solver_MPC_OCP_multiAxleTrailer.c
C:\acadosbuilds2\c_generated_code\MPC_OCP_multiAxleTrailer_constraints\MPC_OCP_multiAxleTrailer_constr_h_0_fun.c
C:\acadosbuilds2\c_generated_code\MPC_OCP_multiAxleTrailer_constraints\MPC_OCP_multiAxleTrailer_constr_h_0_fun_jac_u…
C:\acadosbuilds2\c_generated_code\MPC_OCP_multiAxleTrailer_constraints\MPC_OCP_multiAxleTrailer_constr_h_fun.c
C:\acadosbuilds2\c_generated_code\MPC_OCP_multiAxleTrailer_constraints\MPC_OCP_multiAxleTrailer_constr_h_fun_jac_uxt…
C:\acadosbuilds2\c_generated_code\MPC_OCP_multiAxleTrailer_model\MPC_OCP_multiAxleTrailer_expl_ode_fun.c
C:\acadosbuilds2\c_generated_code\MPC_OCP_multiAxleTrailer_model\MPC_OCP_multiAxleTrailer_expl_vde_adj.c
C:\acadosbuilds2\c_generated_code\MPC_OCP_multiAxleTrailer_model\MPC_OCP_multiAxleTrailer_expl_vde_forw.c

It took quite some time to fix all the issues, but at the end I was successfully build my code. I will soon try it on Autobox. I hope these solutions help some others.

Cheers,
Umur

Hi Umur :wave:

great to hear that you managed to fix the issues! We will review your changes, maybe we can add some more hints to the docs page!

Best, Katrin

Hi,

Did you manage to get it to run on the MABX2?

I had the exact same issues, but having built the code I am unable to load it onto the DS1401. I made a post about this here.

Any info or insights would be much appreciated!

Thanks,

De