How to add cv_bridge support in code generation ?

23 vues (au cours des 30 derniers jours)
Nicolas Thierry
Nicolas Thierry le 24 Oct 2023
Commenté : Nicolas Thierry le 25 Oct 2023
I have a ros2 Gazebo environnement with a camera in it that output its data to a topic and I'm developping a simulink node to process the video. I made a simple simulink block that subscribe to the ROS2 topic, read the image and then ouput the result with a Video Viewer block. When I run it in Simulink there is no problem the Video is stream correctly. However, when I try to generate the ROS2 c++ node with the "Build model" option the colcon build fail with the following error:
CMake Error at CMakeLists.txt:22 (find_package): By not providing "Findcv_bridge.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "cv_bridge", but CMake did not find one. Could not find a package configuration file provided by "cv_bridge" with any of the following names: cv_bridgeConfig.cmake cv_bridge-config.cmake Add the installation prefix of "cv_bridge" to CMAKE_PREFIX_PATH or set "cv_bridge_DIR" to a directory containing one of the above files. If "cv_bridge" provides a separate development package or SDK, be sure it has been installed. -- Configuring incomplete, errors occurred!
First I was thinking that it was just missing the cv-bridge or the opencv package but they seems to be already installed. I'm a beginner in ROS and simulink coder so I don't really get what is the procedure to solve the dependency issue ?

Réponses (1)

Josh Chen
Josh Chen le 25 Oct 2023
Hi Nicolas,
Since you mentioned that both packages seem to be already installed. I assume you are trying to build and run the model on the remote device where you run the ROS 2 Gazebo environment?
Could you please select "Remote Device" under "ROS" tab > "Deploy to" in your model and configure the device information before generating the code?
Note that both packages are installed on remote device, so local code generation (meaning if you are trying to generate code to local device) will not work.
Let me know if my assumption is not correct.
Josh
  6 commentaires
Nicolas Thierry
Nicolas Thierry le 25 Oct 2023
Modifié(e) : Nicolas Thierry le 25 Oct 2023
Of course, I attach my simulink file with a simple ROS2 subscriber and a Video Viewer to display the video.
And for the gcc version I'm using 11.4.0
Do you know if there is a way to check which version Matlab use to compile the code (to see if we use the same) ?
Nicolas Thierry
Nicolas Thierry le 25 Oct 2023
By doing futher testing I found a second behavior but my main issue seems to be solved (but it does not compile).
If I delete all folders (including src) and only left the simulink file. Then, when trying to "generate code" it works and when I run the "colcon build --merge-install" i get the error I send previously.
But, if I delete all folders (including src) and only left the simulink file. Then, when trying to "Build Model" I get this:
## Writing header file test_code_types.h
### Writing header file test_code.h
### Writing header file rtwtypes.h
### Writing header file multiword_types.h
.
### Writing source file test_code.cpp
### Writing header file test_code_private.h
### Writing header file rtmodel.h
### Writing source file test_code_data.cpp
### Writing source file ert_main.cpp
### TLC code generation complete (took 1.181s).
### Saving binary information cache.
### Using toolchain: Colcon Tools
### Building 'test_code': all
Running colcon build in folder '/home/nicolas/Bureau/siera'.
Error building package: build_log.
### Build procedure for test_code aborted due to an error.
Inside the build_log
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - 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: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ament_cmake: 1.3.3 (/usr/local/MATLAB/R2023b/sys/ros2/glnxa64/ros2/share/ament_cmake/cmake)
-- Found Python3: /home/nicolas/.matlab/R2023b/ros2/glnxa64/venv/bin/python3.10 (found version "3.10.12") found components: Interpreter
-- Found ament_cmake_ros: 0.10.0 (/usr/local/MATLAB/R2023b/sys/ros2/glnxa64/ros2/share/ament_cmake_ros/cmake)
-- Found cv_bridge: 3.2.1 (/opt/ros/humble/share/cv_bridge/cmake)
-- Found rosidl_generator_c: 3.1.4 (/usr/local/MATLAB/R2023b/sys/ros2/glnxa64/ros2/share/rosidl_generator_c/cmake)
-- Found rosidl_adapter: 3.1.4 (/usr/local/MATLAB/R2023b/sys/ros2/glnxa64/ros2/share/rosidl_adapter/cmake)
-- Found rosidl_generator_cpp: 3.1.4 (/usr/local/MATLAB/R2023b/sys/ros2/glnxa64/ros2/share/rosidl_generator_cpp/cmake)
-- Using all available rosidl_typesupport_c: rosidl_typesupport_fastrtps_c;rosidl_typesupport_introspection_c
-- Using all available rosidl_typesupport_cpp: rosidl_typesupport_fastrtps_cpp;rosidl_typesupport_introspection_cpp
-- Found rclcpp: 16.0.3 (/usr/local/MATLAB/R2023b/sys/ros2/glnxa64/ros2/share/rclcpp/cmake)
-- Found rmw_implementation_cmake: 6.1.1 (/usr/local/MATLAB/R2023b/sys/ros2/glnxa64/ros2/share/rmw_implementation_cmake/cmake)
-- Found rmw_fastrtps_cpp: 6.2.2 (/usr/local/MATLAB/R2023b/sys/ros2/glnxa64/ros2/share/rmw_fastrtps_cpp/cmake)
-- Found FastRTPS: /usr/local/MATLAB/R2023b/sys/ros2/glnxa64/ros2/include
-- Using RMW implementation 'rmw_fastrtps_cpp' as default
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done
CMake Error at /opt/ros/humble/share/cv_bridge/cmake/export_cv_bridgeExport.cmake:56 (set_target_properties):
The link interface of target "cv_bridge::cv_bridge" contains:
sensor_msgs::sensor_msgs__rosidl_generator_py
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
/opt/ros/humble/share/cv_bridge/cmake/ament_cmake_export_targets-extras.cmake:9 (include)
/opt/ros/humble/share/cv_bridge/cmake/cv_bridgeConfig.cmake:41 (include)
CMakeLists.txt:22 (find_package)
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
And, if I then try to do a "colcon build --merge-install" (outside simulink)
Starting >>> test_code
ninja: error: loading 'build.ninja': No such file or directory
--- stderr: test_code
CMake Error at CMakeLists.txt:31 (add_executable):
Target "test_code" links to target
"sensor_msgs::sensor_msgs__rosidl_generator_py" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
CMake Generate step failed. Build files cannot be regenerated correctly.
---
Failed <<< test_code [0.91s, exited with code 1]

Connectez-vous pour commenter.

Catégories

En savoir plus sur Network Connection and Exploration 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