Why I get Error using rosgenmsg?

1 vue (au cours des 30 derniers jours)
xyl
xyl le 17 Sep 2024
Commenté : xyl le 18 Sep 2024
Hello,
I am using Windows10 and MATLAB R2023b.
I got error by using the ROS Toolbox an generating some ROS Messages.
This is my error message:
rosgenmsg("D:\MATLAB2023\toolbox\ros\bin\win64\ros1")
Identifying message files in folder 'D:/MATLAB2023/toolbox/ros/bin/win64/ros1'..Done.
Validating message files in folder 'D:/MATLAB2023/toolbox/ros/bin/win64/ros1'..Done.
[1/1] Generating MATLAB interfaces for custom message packages... Done.
Running catkin build in folder 'D:/MATLAB2023/toolbox/ros/bin/win64/ros1/matlab_msg_gen_ros1/win64'.
Build in progress. This may take several minutes...错误使用 ros.internal.ROSProjectBuilder/buildPackage
Error building package: build_log.
出错 rosgenmsg (593 )
buildPackage(builder, [], 'install', catkinMakeArgs); %other messages might need to be present in the same directory
This is my build_log:
********************************************************************** ** Visual Studio 2022 Developer Command Prompt v17.11.3 ** Copyright (c) 2022 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x86_x64' -- The C compiler identification is MSVC 19.41.34120.0 -- The CXX compiler identification is MSVC 19.41.34120.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: D:/VScode/2022/community/VC/Tools/MSVC/14.41.34120/bin/Hostx86/x64/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: D:/VScode/2022/community/VC/Tools/MSVC/14.41.34120/bin/Hostx86/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Using CATKIN_DEVEL_PREFIX: D:/MATLAB2023/toolbox/ros/bin/win64/ros1/matlab_msg_gen_ros1/win64/devel -- Using CMAKE_PREFIX_PATH: D:\MATLAB2023\sys\ros1\win64\ros1;D:/MATLAB2023/toolbox/ros/mlroscpp/custom_messages -- This workspace overlays: D:/MATLAB2023/sys/ros1/win64/ros1;D:/MATLAB2023/toolbox/ros/mlroscpp/custom_messages -- Found PythonInterp: C:/Users/finee/AppData/Roaming/MathWorks/MATLAB/R2023b/ros1/win64/venv/Scripts/python.exe (found suitable version "3.9.7", minimum required is "3") -- Using PYTHON_EXECUTABLE: C:/Users/finee/AppData/Roaming/MathWorks/MATLAB/R2023b/ros1/win64/venv/Scripts/python.exe -- Using default Python package layout -- Found PY_em: C:\Users\finee\AppData\Roaming\MATHWO~1\MATLAB\R2023b\ros1\win64\venv\lib\site-packages\em.py -- Using empy: C:/Users/finee/AppData/Roaming/MATHWO~1/MATLAB/R2023b/ros1/win64/venv/lib/site-packages/em.py -- Using CATKIN_ENABLE_TESTING: off -- catkin 0.8.10 -- BUILD_SHARED_LIBS is on 系统找不到指定的批处理标签 - GenerateTempFilename Traceback (most recent call last): File "D:\MATLAB2023\toolbox\ros\bin\win64\ros1\matlab_msg_gen_ros1\win64\build\catkin_generated\generate_cached_setup.py", line 22, in <module> code = generate_environment_script('D:/MATLAB2023/toolbox/ros/bin/win64/ros1/matlab_msg_gen_ros1/win64/devel/env.bat') File "D:\MATLAB2023\sys\ros1\win64\ros1\lib\site-packages\catkin\environment_cache.py", line 63, in generate_environment_script env_after = ast.literal_eval(output.decode('utf8')) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb4 in position 3773: invalid start byte CMake Error at D:/MATLAB2023/sys/ros1/win64/ros1/share/catkin/cmake/safe_execute_process.cmake:11 (message): execute_process(C:/Users/finee/AppData/Roaming/MathWorks/MATLAB/R2023b/ros1/win64/venv/Scripts/python.exe "D:/MATLAB2023/toolbox/ros/bin/win64/ros1/matlab_msg_gen_ros1/win64/build/catkin_generated/generate_cached_setup.py") returned error code 1 Call Stack (most recent call first): D:/MATLAB2023/sys/ros1/win64/ros1/share/catkin/cmake/all.cmake:208 (safe_execute_process) D:/MATLAB2023/sys/ros1/win64/ros1/share/catkin/cmake/catkinConfig.cmake:20 (include) CMakeLists.txt:58 (find_package) -- Configuring incomplete, errors occurred! See also "D:/MATLAB2023/toolbox/ros/bin/win64/ros1/matlab_msg_gen_ros1/win64/build/CMakeFiles/CMakeOutput.log". Base path: D:\MATLAB2023\toolbox\ros\bin\win64\ros1\matlab_msg_gen_ros1\win64 Source space: D:\MATLAB2023\toolbox\ros\bin\win64\ros1\matlab_msg_gen_ros1\win64\src Build space: D:\MATLAB2023\toolbox\ros\bin\win64\ros1\matlab_msg_gen_ros1\win64\build Devel space: D:\MATLAB2023\toolbox\ros\bin\win64\ros1\matlab_msg_gen_ros1\win64\devel Install space: D:\MATLAB2023\toolbox\ros\bin\win64\ros1\matlab_msg_gen_ros1\win64\install Copying file from "D:\MATLAB2023\sys\ros1\win64\ros1\share\catkin\cmake\toplevel.cmake" to "D:\MATLAB2023\toolbox\ros\bin\win64\ros1\matlab_msg_gen_ros1\win64\src\CMakeLists.txt" #### #### Running command: "cmake D:\MATLAB2023\toolbox\ros\bin\win64\ros1\matlab_msg_gen_ros1\win64\src -DALIAS_ROS1_CLASS_LOADER=1 -DBoost_NAMESPACE=mwboost -DCATKIN_ENABLE_TESTING=off -DCMAKE_PREFIX_PATH=D:\MATLAB2023\sys\ros1\win64\ros1;D:/MATLAB2023/toolbox/ros/mlroscpp/custom_messages -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE=/MD /Od /Ob2 /DNDEBUG -DCATKIN_DEVEL_PREFIX=D:\MATLAB2023\toolbox\ros\bin\win64\ros1\matlab_msg_gen_ros1\win64\devel -DCMAKE_INSTALL_PREFIX=D:\MATLAB2023\toolbox\ros\bin\win64\ros1\matlab_msg_gen_ros1\win64\install -G Ninja" in "D:\MATLAB2023\toolbox\ros\bin\win64\ros1\matlab_msg_gen_ros1\win64\build" #### Invoking "cmake" failed
I saw a response on another post with the same question that there is any environment variable containing non-ASCII characters. However, I don't have any no ASCII chatacer on my computer. So,is there any other problem that caused this error to occur?
Thanks!

Réponse acceptée

Avadhoot
Avadhoot le 17 Sep 2024
Hello @xyl,
I infer from your error log that you are getting an error while generating ROS messages. Usually this is caused due to a non-ASCII character in any environment variable. Since you mention that this is not the case, here are the other scenaios where you could potentially face such an error:
1) Check Python and CMake versions:
Check for mismatches in the Python and CMake versions. Also ensure that they are compatible with ROS and MATLAB. This can cause unexpected errors if not paid attention to.
2) Environment variables:
Check if the environment variables do not have any unexpected values. This could cause potential issues.
3) Check for corrupted files:
Corrupted files while can cause errors while building. Try deleting and regenerating the message files to see if this resolves the issue.
4) Python environment:
Ensure that the Python virtual environment used by MATLAB is correctly set up. You can try recreating this environment to ensure it’s not corrupted.
5) Clear the CMake cache:
Clear the CMake cache. Sometimes stale cache files can cause issues. You can delete the CMakeCache.txt file in your build directory and try rebuilding.
There could be a few causes of the unexpected error like this. As a lot of variables are involved it is good to be sure of the origin of the issue. I hope the above information helps you in narrowing down the cause of the issue.
Regards,
Avadhoot.
  1 commentaire
xyl
xyl le 18 Sep 2024
Thanks a lot for your answer. It was really helpful!
I followed the steps you mentioned in point three, and it finally worked.
Best regards,
xyl.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Custom Message Support dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by