Error during Build - utils/types.h for MABX II

Hi :wave:

I’m using Matlab as an acados interface. I’m currently working on the implementation of a NMPC for Energy Efficient Torque Vectoring on a vehicle by doing an implementation on a MABX II through dSPACE.

I’ve followed the procedure stated on acados website without any major inconvenient but while doing the final step (Build), I’m getting this error but I’m not sure what really means nor how to solve it.

MATLAB/Simulink Error:
image

MATLAB/Simulink Error (text):

COMPILING  "Six_DOF.c"
Caution: current program unit "Six_DOF_output" is too large (34752) for higher level optimizations.  
Optimizations downgraded.
Caution: current program unit "Six_DOF_initialize" is too large (44848) for higher level optimizations.  
Optimizations downgraded.
COMPILING  "Six_DOF_data.c"
COMPILING  "Six_DOF_rticanmm.c"
COMPILING  "Six_DOF_trc_ptr.c"
COMPILING  "rtGetInf.c"
COMPILING  "rtGetNaN.c"
COMPILING  "rt_nonfinite.c"
COMPILING  "C:\Program Files\dSPACE RCPHIL 2018-B\MATLAB\RTI\RTI\C\rti_sim_engine.c"
COMPILING  "..\\c_generated_code\acados_solver_sfunction_nmpc.c"
(I) C0228-D; "..\include\acados/utils/types.h", line 85 pos 17; trailing comma is nonstandard
      ACADOS_READY,
                  ^
(I) C0228-D; "..\include\acados/sim/sim_collocation_utils.h", line 74 pos 20; trailing comma is nonstandard
      GAUSS_RADAU_IIA,
                     ^
(E) C0020; "..\include\acados/sim/sim_common.h", line 84 pos 5; identifier "bool" is undefined
      bool identity_seed; // indicating if S_forw = [eye(nx), zeros(nx x nu)]
      ^
(E) C0020; "..\include\acados/sim/sim_common.h", line 137 pos 5; identifier "bool" is undefined
      bool sens_forw;
      ^
(E) C0020; "..\include\acados/sim/sim_common.h", line 138 pos 5; identifier "bool" is undefined
      bool sens_adj;
      ^
(E) C0020; "..\include\acados/sim/sim_common.h", line 139 pos 5; identifier "bool" is undefined
      bool sens_hess;
      ^
(E) C0020; "..\include\acados/sim/sim_common.h", line 141 pos 5; identifier "bool" is undefined
      bool output_z;        // 1 -- if zn should be computed
      ^
(E) C0020; "..\include\acados/sim/sim_common.h", line 142 pos 5; identifier "bool" is undefined
      bool sens_algebraic;  // 1 -- if S_algebraic should be computed
      ^
(E) C0020; "..\include\acados/sim/sim_common.h", line 143 pos 5; identifier "bool" is undefined
      bool exact_z_output;  // 1 -- if z, S_algebraic should be computed exactly, extra Newton iterations
      ^
(E) C0020; "..\include\acados/sim/sim_common.h", line 149 pos 5; identifier "bool" is undefined
      bool jac_reuse;
      ^
(I) C0228-D; "..\\c_generated_code\..\include\acados_c\sim_interface.h", line 52 pos 23; trailing comma is nonstandard
      INVALID_SIM_SOLVER,
                        ^
(F) C0005; "..\\c_generated_code\acados_solver_sfunction_nmpc.c", line 42 pos 44; could not open source file "..\include\acados_c\sim_common.h"
  #include "..\include\acados_c\sim_common.h"
                                             ^
8 Errors     3 Informationals
COMPILING FAILED (1) 
 
MAKE PROCESS ABORTED

If it is somehow helpful, please find attached the s_function code as well as the make file code:

s_function

#define S_FUNCTION_NAME acados_solver_sfunction_nmpc
#define S_FUNCTION_LEVEL 2

#define MDL_START

// acados
// #include "acados/utils/print.h"
#include "..\include\acados_c\sim_interface.h"
#include "..\include\acados_c\sim_common.h"
#include "..\include\acados_c\external_function_interface.h"

// example specific
#include "nmpc_model/nmpc_model.h"
#include "acados_solver_nmpc.h"

#include "simstruc.h"

#define SAMPLINGTIME -1

static void mdlInitializeSizes (SimStruct *S)
{
    // specify the number of continuous and discrete states
    ssSetNumContStates(S, 0);
    ssSetNumDiscStates(S, 0);

    int N = NMPC_N;// specify the number of input ports
    if ( !ssSetNumInputPorts(S, 2) )
        return;

    // specify the number of output ports
    if ( !ssSetNumOutputPorts(S, 6) )
        return;

    // specify dimension information for the input ports
    // lbx_0
    ssSetInputPortVectorDimension(S, 0, 8);
    // ubx_0
    ssSetInputPortVectorDimension(S, 1, 8);/* specify dimension information for the OUTPUT ports */
    ssSetOutputPortVectorDimension(S, 0, 2 );
    ssSetOutputPortVectorDimension(S, 1, 20 );
    ssSetOutputPortVectorDimension(S, 2, 88 );
    ssSetOutputPortVectorDimension(S, 3, 1 );
    ssSetOutputPortVectorDimension(S, 4, 1);
    ssSetOutputPortVectorDimension(S, 5, 1 );

    // specify the direct feedthrough status
    // should be set to 1 for all inputs used in mdlOutputs
    ssSetInputPortDirectFeedThrough(S, 0, 1);
    ssSetInputPortDirectFeedThrough(S, 1, 1);

    // one sample time
    ssSetNumSampleTimes(S, 1);
}


#if defined(MATLAB_MEX_FILE)

#define MDL_SET_INPUT_PORT_DIMENSION_INFO
#define MDL_SET_OUTPUT_PORT_DIMENSION_INFO

static void mdlSetInputPortDimensionInfo(SimStruct *S, int_T port, const DimsInfo_T *dimsInfo)
{
    if ( !ssSetInputPortDimensionInfo(S, port, dimsInfo) )
         return;
}

static void mdlSetOutputPortDimensionInfo(SimStruct *S, int_T port, const DimsInfo_T *dimsInfo)
{
    if ( !ssSetOutputPortDimensionInfo(S, port, dimsInfo) )
         return;
}

#endif /* MATLAB_MEX_FILE */


static void mdlInitializeSampleTimes(SimStruct *S)
{
    ssSetSampleTime(S, 0, SAMPLINGTIME);
    ssSetOffsetTime(S, 0, 0.0);
}


static void mdlStart(SimStruct *S)
{
    nmpc_solver_capsule *capsule = nmpc_acados_create_capsule();
    nmpc_acados_create(capsule);

    ssSetUserData(S, (void*)capsule);
}


static void mdlOutputs(SimStruct *S, int_T tid)
{
    nmpc_solver_capsule *capsule = ssGetUserData(S);
    ocp_nlp_config *nlp_config = nmpc_acados_get_nlp_config(capsule);
    ocp_nlp_dims *nlp_dims = nmpc_acados_get_nlp_dims(capsule);
    ocp_nlp_in *nlp_in = nmpc_acados_get_nlp_in(capsule);
    ocp_nlp_out *nlp_out = nmpc_acados_get_nlp_out(capsule);

    InputRealPtrsType in_sign;

    int N = NMPC_N;

    // local buffer
    real_t buffer[8];

    /* go through inputs */
    // lbx_0
    in_sign = ssGetInputPortRealSignalPtrs(S, 0);
    for (int i = 0; i < 8; i++)
        buffer[i] = (double)(*in_sign[i]);

    ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "lbx", buffer);
    // ubx_0
    in_sign = ssGetInputPortRealSignalPtrs(S, 1);
    for (int i = 0; i < 8; i++)
        buffer[i] = (double)(*in_sign[i]);
    ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "ubx", buffer);

  

  

  

    /* call solver */
    int rti_phase = 0;
    ocp_nlp_solver_opts_set(nlp_config, capsule->nlp_opts, "rti_phase", &rti_phase);
    int acados_status = nmpc_acados_solve(capsule);


    /* set outputs */
    // assign pointers to output signals
    real_t *out_u0, *out_utraj, *out_xtraj, *out_status, *out_sqp_iter, *out_KKT_res, *out_KKT_residuals, *out_x1, *out_cpu_time, *out_cpu_time_sim, *out_cpu_time_qp, *out_cpu_time_lin, *out_cost_value;
    int tmp_int;
    out_u0 = ssGetOutputPortRealSignal(S, 0);
    ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, 0, "u", (void *) out_u0);
    out_utraj = ssGetOutputPortRealSignal(S, 1);
    for (int ii = 0; ii < N; ii++)
        ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, ii,
                        "u", (void *) (out_utraj + ii * 2));

  

    out_xtraj = ssGetOutputPortRealSignal(S, 2);
    for (int ii = 0; ii < 11; ii++)
        ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, ii,
                        "x", (void *) (out_xtraj + ii * 8));
    out_status = ssGetOutputPortRealSignal(S, 3);
    *out_status = (real_t) acados_status;
    out_cpu_time = ssGetOutputPortRealSignal(S, 4);
    // get solution time
    ocp_nlp_get(nlp_config, capsule->nlp_solver, "time_tot", (void *) out_cpu_time);
    out_sqp_iter = ssGetOutputPortRealSignal(S, 5);
    // get sqp iter
    ocp_nlp_get(nlp_config, capsule->nlp_solver, "sqp_iter", (void *) &tmp_int);
    *out_sqp_iter = (real_t) tmp_int;

}

static void mdlTerminate(SimStruct *S)
{
    nmpc_solver_capsule *capsule = ssGetUserData(S);

    nmpc_acados_free(capsule);
    nmpc_acados_free_capsule(capsule);
}


#ifdef  MATLAB_MEX_FILE
#include "simulink.c"
#else
#include "cg_sfun.h"
#endif

make file:

# Directories where S-Function C source files are stored.
SFCN_DIR = \
"\c_generated_code" \
"\c_generated_code\nmpc_model"

# Additional C source files to be compiled (file name extension .c).
USER_SRCS = \
acados_solver_nmpc.c \
acados_sim_solver_nmpc.c \
nmpc_model/nmpc_dyn_disc_phi_fun.c \
nmpc_model/nmpc_dyn_disc_phi_fun_jac.c \
nmpc_cost/nmpc_cost_ext_cost_0_fun.c \
nmpc_cost/nmpc_cost_ext_cost_0_fun_jac.c \
nmpc_cost/nmpc_cost_ext_cost_0_fun_jac_hess.c \
nmpc_cost/nmpc_cost_ext_cost_fun.c \
nmpc_cost/nmpc_cost_ext_cost_fun_jac.c \
nmpc_cost/nmpc_cost_ext_cost_fun_jac_hess.c \
nmpc_cost/nmpc_cost_ext_cost_e_fun.c \
nmpc_cost/nmpc_cost_ext_cost_e_fun_jac.c \
nmpc_cost/nmpc_cost_ext_cost_e_fun_jac_hess.c \
nmpc_constraints/nmpc_constr_h_fun.c \
nmpc_constraints/nmpc_constr_h_fun_jac_uxt_zt_hess.c \
nmpc_constraints/nmpc_constr_h_fun_jac_uxt_zt.c

# Additional assembler source files to be compiled (file name extension .asm).
USER_ASM_SRCS =

# Directories where additional C and assembler source files are stored.
USER_SRCS_DIR =

# Path names for user include files.
USER_INCLUDES_PATH = \
E2E_SPAx\E2E_SPAx\E2ELibrary\inc \
"include" \
"include\blasfeo\include" \
"include\hpipm\include" \
"include\acados_c"

# Additional user object files to be linked.
USER_OBJS =

# Additional user libraries to be linked.
USER_LIBS = \
E2E_SPAx\E2E_SPAx\E2ELibrary\E2E_DSPACE_ds1401.lib \
lib\blasfeo.lib \
lib\hpipm.lib \
lib\acados.lib

# EOF -------------------------------------------------------------------------

Am I missing something?

Thanks for your time and please let me know if further information is required,
Daniel

FOLLOW UP

We’ve managed to identify what might be the problem with this. It’s likely that the issue is related to the compiler since “bool” operations are not recognized but “_Bool” are indeed recognized. However, this did not get solved by incorporating #include <stdio.h> and #include <stdbool.h> into the header file (I had to hardcode it to troubleshoot - which is something I don’t like). As expected, this got solved but new issues related to other operations (in this case, DISCRETE) popped up.

Does anyone have any clue about where can I look at regarding the compiler setup?

Thanks once again for your time,
Daniel

FOLLOW UP

By doing further research, I managed to find out that on Simulink Settings → Interface → Advanced math library, by setting the “Standard math llibrary” from C89/90 (ANSI) to C99 (ISO) the errors I was getting got, apparantly, solved. However, I’m having other issues that didn’t have before and I think that what is happening is that there’s a part of the model (that I inherited) that was done according to C89/90 ANSI standard while, apparently, acados on C99 ISO.

If I’m not saying anything crazy, is there any way of “translating” ISO to ANSI and/or viceversa?

Thanks once again for your time,
Daniel