Error generating code for matchScans() function.

1 次查看(过去 30 天)
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;
end
idx_remove = ranges>=rangeMax;
ranges_new = ranges(~idx_remove);
angles_new = angles(~idx_remove);
% Try simple scan matching between consecutive scans
persistent scan_prev
scan_in = lidarScan(ranges_new,angles_new);
if isempty(scan_prev) % For the very first scan
scan_prev = scan_in;
end
relPose = 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 directory
compilation 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' failed
make[3]: *** [test_sim_ms/CMakeFiles/test_sim_ms_node.dir/csleepfun_windows.c.o] Error 1
make[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 directory
compilation 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' failed
make[3]: *** [test_sim_ms/CMakeFiles/test_sim_ms_node.dir/ctimefun_windows.c.o] Error 1
CMakeFiles/Makefile2:1951: recipe for target 'test_sim_ms/CMakeFiles/test_sim_ms_node.dir/all' failed
make[2]: *** [test_sim_ms/CMakeFiles/test_sim_ms_node.dir/all] Error 2
CMakeFiles/Makefile2:1963: recipe for target 'test_sim_ms/CMakeFiles/test_sim_ms_node.dir/rule' failed
make[1]: *** [test_sim_ms/CMakeFiles/test_sim_ms_node.dir/rule] Error 2
Makefile:810: recipe for target 'test_sim_ms_node' failed
make: *** [test_sim_ms_node] Error 2
Base path: /home/th06001/catkin_PF
Source space: /home/th06001/catkin_PF/src
Build space: /home/th06001/catkin_PF/build
Devel space: /home/th06001/catkin_PF/devel
Install 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

采纳的回答

Yiping Liu
Yiping Liu 2020-9-26
The error from matchScans during cross-platform codegen (like from Windows to ROS target) has been fixed in 20b release.
If you have MATLAB on Ubuntu, you can also try to generate the node from there, this will avoid the cross-compling issue (just like lbrobotics suggests)
matchScansGrid uses a different solver under the hood, so it does not have the issue.

更多回答(1 个)

lburseg
lburseg 2020-9-24
Hey Sooraj,
I have the same problem right now. If I build my Simulink model on Ubuntu it works fine. If I build the same model on the Windows machine that is connected to Ubuntu the windows.h error occurs.
Have you ever solved this problem?
Best
Lukas

类别

Help CenterFile Exchange 中查找有关 Code Generation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by