aditya00j / GX

1 stars 0 forks source link

matlab issues #14

Open bluetulip89 opened 6 years ago

bluetulip89 commented 6 years ago

In file included from E:\mavlink_s\sfun_decode_mavlink.cpp:18:0: E:\mavlink_s\include/sfun_decode_mavlink.h:7:48: fatal error: include/sfun_mavlink_msg_heartbeat.h: No such file or directory

include "include/sfun_mavlink_msg_heartbeat.h"

                                            ^

compilation terminated.

bluetulip89 commented 6 years ago

but during the build the file is created in the respective paths (inside include folder) but still getting the error.

aditya00j commented 6 years ago

Can you paste your example_create_sfunctions.m file? Also paste the text this file prints on the command prompt when you run it.

bluetulip89 commented 6 years ago

here is the sequence once it is run

example_create_sfunctions

* Running create_sfun_encode for E:\mavlink_s\include\mavlink\v1.0\common\mavlink_msg_heartbeat.h: Creating Simulink bus from message... done Bus is saved in buses/bus_mavlink_heartbeat_t.mat Creating the s-function header file... done Header file is saved in include/sfun_mavlink_msg_heartbeat.h ** Creating the output file sfun_encode_msg_heartbeat.cpp ... done Compiling the s-function... Building with 'MinGW64 Compiler (C++)'. MEX completed successfully. S-function source and compiled files are in the folder 'sfunctions'


* Running create_sfun_encode for E:\mavlink_s\include\mavlink\v1.0\common\mavlink_msg_attitude.h: Creating Simulink bus from message... done Bus is saved in buses/bus_mavlink_attitude_t.mat Creating the s-function header file... done Header file is saved in include/sfun_mavlink_msg_attitude.h ** Creating the output file sfun_encode_msg_attitude.cpp ... done Compiling the s-function... Building with 'MinGW64 Compiler (C++)'. MEX completed successfully. S-function source and compiled files are in the folder 'sfunctions'


* Running create_sfun_encode for E:\mavlink_s\include\mavlink\v1.0\common\mavlink_msg_raw_imu.h: Creating Simulink bus from message... done Bus is saved in buses/bus_mavlink_raw_imu_t.mat Creating the s-function header file... done Header file is saved in include/sfun_mavlink_msg_raw_imu.h ** Creating the output file sfun_encode_msg_raw_imu.cpp ... done Compiling the s-function... Building with 'MinGW64 Compiler (C++)'. MEX completed successfully. S-function source and compiled files are in the folder 'sfunctions'


* Running create_sfun_decode: Creating Simulink bus from message... done Bus is saved in buses/bus_mavlink_heartbeat_t.mat Creating the s-function header file... done Header file is saved in include/sfun_mavlink_msg_heartbeat.h Creating Simulink bus from message... done Bus is saved in buses/bus_mavlink_attitude_t.mat Creating the s-function header file... done Header file is saved in include/sfun_mavlink_msg_attitude.h Creating Simulink bus from message... done Bus is saved in buses/bus_mavlink_raw_imu_t.mat Creating the s-function header file... done Header file is saved in include/sfun_mavlink_msg_raw_imu.h ** Creating s-function header file... done Creating the output file sfun_decode_mavlink.cpp ... done Compiling the s-function... Building with 'MinGW64 Compiler (C++)'. Error using mex In file included from E:\mavlink_s\sfun_decode_mavlink.cpp:18:0: E:\mavlink_s\include/sfun_decode_mavlink.h:7:48: fatal error: include/sfun_mavlink_msg_heartbeat.h: No such file or directory

include "include/sfun_mavlink_msg_heartbeat.h"

                                            ^

compilation terminated.

Error in create_sfun_decode (line 212) eval(['mex ' output_filename '.cpp']);

Error in example_create_sfunctions (line 35) create_sfun_decode(filenames);

bluetulip89 commented 6 years ago

example_create_sfunctions.zip

bluetulip89 commented 6 years ago

Even if we add manually the path along with file and sub-folders / if we give addpath(genpath(cd)) or

p = genpath(cd) addpath(p)

its throwing same error

aditya00j commented 6 years ago

Just make sure there is no file called sfun_decode_mavlink.cpp before you run the Matlab script, and then please paste the sfun_decode_mavlink.cpp file being created by the script. This is the file that is not compiling, so we have to see. Also, let me know if this file is created in your root folder (and not examples folder).

bluetulip89 commented 6 years ago

Same error comes even when sfun_decode_mavlink.cpp is deleted before run.

sfun_decode_mavlink.cpp content generated during build

/ DO NOT EDIT. This file was automatically created by the Matlab function 'create_sfun_decode' on 21-Nov-2017 18:18:01 as part of Simulink MAVLink library. /

define S_FUNCTION_NAME sfun_decode_mavlink

define S_FUNCTION_LEVEL 2

include "simstruc.h"

// System and Component IDs for MAVLink communication

define SYS_ID 100

define COMP_ID 200

include "include/mavlink/v1.0/common/mavlink.h"

include "include/sfun_decode_mavlink.h"

/* Function: mdlInitializeSizes ================================================

} / end mdlInitializeSizes /

/* Function: mdlInitializeSampleTimes ==========================================

} / end mdlInitializeSampleTimes /

/* Function: mdlStart ==========================================================

/* Function: mdlOutputs ========================================================

}

/* Function: mdlTerminate ======================================================

/=============================

ifdef MATLAB_MEX_FILE / Is this file being compiled as a MEX-file? /

include "simulink.c" / MEX-file interface mechanism /

else

include "cg_sfun.h" / Code generation registration function /

endif

aditya00j commented 6 years ago

This is a curious error, which I am not getting, nor have any of the other users (I know of at least 3 other people who have used this function). If you look at the error, it is saying that the file "include/sfun_mavlink_msg_heartbeat.h" does not exist, even though that file was correctly used during the compilation of sfun_encode_msg_heartbeat. Even the other include file, include/sfun_decode_mavlink.h is included correctly.

I don't know if this is a compiler specific message, which is resolving the relative paths differently from MS Visual C++ compiler (but highly unlikely). As a different approach, I can suggest you this:

After the file sfun_decode_mavlink.cpp is created, go to the file include/sfun_decode_mavlink.h, and manually copy-paste the content from sfun_mavlink_msg_heartbeat.h, sfun_mavlink_msg_attitude.h, and sfun_mavlink_msg_raw_imu.h where it includes these files (so that instead of including the files, you are just pasting their contents). Then compile the s-function.

aditya00j commented 6 years ago

Hi, I installed the minGW compiler and found that I was also getting this same issue. As I suspected, it is because of how the compiler deals with relative paths. Check this: http://www.mingw.org/wiki/includepathhowto

Specifically, the following sentence:

path must be a relative path, and it must be relative to the directory in which the file containing the pertinent #include directive is itself located.

I have fixed the issue. You can update your repo, it should work now.

aditya00j commented 6 years ago

Closing this issue.

bluetulip89 commented 6 years ago

Have updated the repo and now i am getting the following error. Any Idea to get rid of the following error.

example_create_sfunctions

* Running create_sfun_encode for C:\Simulation\simulink_mavlink\include\mavlink\v1.0\common\mavlink_msg_heartbeat.h: Creating Simulink bus from message... Error using fgets Invalid file identifier. Use fopen to generate a valid file identifier.

Error in fgetl (line 33) [tline,lt] = fgets(fid);

Error in create_bus_from_mavlink_header (line 16) lin = fgetl(fid);

Error in create_sfun_header (line 27) [simulink_bus, simulink_bus_name] = create_bus_from_mavlink_header(filename);

Error in create_sfun_encode (line 29) mavlink_msg_name = create_sfun_header(filename);

Error in example_create_sfunctions (line 26) create_sfun_encode(filenames{i});

aditya00j commented 6 years ago

I think you have to update the file names to your computer path. "C:\Simulation\simulink_mavlink" is my path, which I used in the example. Change it to your relevant path.

priyablue commented 6 years ago

Oh ok will change and let you know.