Hi,
I have made a simple matlab function block in simulink that contains the following code:
function relPose = test_MS(range_in, angle_in, rangeMax)% To prevent code generation uncertainity
ranges = double(range_in);angles = double(angle_in);% Check for invalid data in ranges input and remove them
if any(isnan(ranges)) || any(isinf(ranges)) || any(ranges < 0) disp('invalid lidar data') idx_invalid = (ranges < 0) | isinf(ranges) | isnan(ranges); % set all invalid data to a value higher than rangeMax
ranges(idx_invalid) = rangeMax + 1;endidx_remove = ranges>=rangeMax;ranges_new = ranges(~idx_remove);angles_new = angles(~idx_remove);% Try simple scan matching between consecutive scans
persistent scan_prevscan_in = lidarScan(ranges_new,angles_new);if isempty(scan_prev) % For the very first scan
scan_prev = scan_in;endrelPose = matchScans(scan_prev, scan_in,'CellSize',2);relPose(3) = rad2deg(relPose(3));fprintf('\n Relative Pose is %f %f %f\n',relPose(1),relPose(2),relPose(3))scan_prev = scan_in;end
There is nothing else in the Simulink model, other than a subscriber block to the lidar scan.
But when I try to generate the code for a ROS node (build and load directly to a turtlbot in my case), I get the following error:
[ 0%] Built target sensor_msgs_generate_messages_nodejs
Scanning dependencies of target test_sim_ms_node[ 14%] Building C object test_sim_ms/CMakeFiles/test_sim_ms_node.dir/roundtolong.c.o
[ 14%] Building C object test_sim_ms/CMakeFiles/test_sim_ms_node.dir/csleepfun_windows.c.o
[ 21%] Building C object test_sim_ms/CMakeFiles/test_sim_ms_node.dir/ctimefun_windows.c.o
[ 28%] Building CXX object test_sim_ms/CMakeFiles/test_sim_ms_node.dir/ert_main.cpp.o
/home/th06001/catkin_PF/src/test_sim_ms/csleepfun_windows.c:5:21: fatal error: windows.h: No such file or directorycompilation terminated.test_sim_ms/CMakeFiles/test_sim_ms_node.dir/build.make:89: recipe for target 'test_sim_ms/CMakeFiles/test_sim_ms_node.dir/csleepfun_windows.c.o' failedmake[3]: *** [test_sim_ms/CMakeFiles/test_sim_ms_node.dir/csleepfun_windows.c.o] Error 1make[3]: *** Waiting for unfinished jobs..../home/th06001/catkin_PF/src/test_sim_ms/ctimefun_windows.c:5:21: fatal error: windows.h: No such file or directorycompilation terminated.test_sim_ms/CMakeFiles/test_sim_ms_node.dir/build.make:113: recipe for target 'test_sim_ms/CMakeFiles/test_sim_ms_node.dir/ctimefun_windows.c.o' failedmake[3]: *** [test_sim_ms/CMakeFiles/test_sim_ms_node.dir/ctimefun_windows.c.o] Error 1CMakeFiles/Makefile2:1951: recipe for target 'test_sim_ms/CMakeFiles/test_sim_ms_node.dir/all' failedmake[2]: *** [test_sim_ms/CMakeFiles/test_sim_ms_node.dir/all] Error 2CMakeFiles/Makefile2:1963: recipe for target 'test_sim_ms/CMakeFiles/test_sim_ms_node.dir/rule' failedmake[1]: *** [test_sim_ms/CMakeFiles/test_sim_ms_node.dir/rule] Error 2Makefile:810: recipe for target 'test_sim_ms_node' failedmake: *** [test_sim_ms_node] Error 2Base path: /home/th06001/catkin_PFSource space: /home/th06001/catkin_PF/srcBuild space: /home/th06001/catkin_PF/buildDevel space: /home/th06001/catkin_PF/develInstall space: /home/th06001/catkin_PF/install######## Running command: "cmake /home/th06001/catkin_PF/src -DCATKIN_DEVEL_PREFIX=/home/th06001/catkin_PF/devel -DCMAKE_INSTALL_PREFIX=/home/th06001/catkin_PF/install -G Unix Makefiles" in "/home/th06001/catkin_PF/build"############ Running command: "make test_sim_ms_node -j4 -l4" in "/home/th06001/catkin_PF/build"####Invoking "make test_sim_ms_node -j4 -l4" failed
It seems that the compiler cannot find csleepfun_windows.c.o or something.
Is there something I'm doing wrong?
I don't have this problem when I use matchScansGrid() function though. I can run the model on simulink too without any problem (by remotely connecting to the turtlebot ROS core).
Thanks in advance.
Sooraj
Best Answer