ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Getting YOLO/darknet_ros working in Ubuntu 20 and ROS Noetic

asked 2021-01-07 19:15:06 -0500

RobbieTheK gravatar image

updated 2021-01-08 11:13:34 -0500

Is there a way to get darknet_ros working in Ubuntu 20? So far I see it's only tested for Ubuntu 18

Many errors when trying to compile.

cd /home/ourhome/catkin_workspace/build/darknet_ros/darknet_ros && /bin/cc -DDARKNET_FILE_PATH=\"/home/ourhome/catkin_workspace/src/darknet_ros/darknet\" -DOPENCV -DROSCONSOLE_BACKEND_LOG4CXX -DROS_BUILD_SHARED_LIBS=1 -DROS_PACKAGE_NAME=\"darknet_ros\" -Ddarknet_ros_lib_EXPORTS -I/home/ourhome/catkin_workspace/src/darknet_ros/darknet/src -I/home/ourhome/catkin_workspace/src/darknet_ros/darknet/include -I/home/ourhome/catkin_workspace/src/darknet_ros/darknet_ros/include -I/include -I/home/ourhome/catkin_workspace/devel/include -I/opt/ros/noetic/include -I/opt/ros/noetic/share/xmlrpcpp/cmake/../../../include/xmlrpcpp -isystem /usr/include/opencv4  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wno-unused-variable -Wfatal-errors -fPIC  -O3 -DNDEBUG -fPIC   -O4 -g -o CMakeFiles/darknet_ros_lib.dir/__/darknet/src/activation_layer.c.o   -c /home/ourhome/catkin_workspace/src/darknet_ros/darknet/src/activation_layer.c

In file included from /usr/include/opencv4/opencv2/core/types_c.h:84,
                 from /usr/include/opencv4/opencv2/core/core_c.h:48,
                 from /usr/include/opencv4/opencv2/highgui/highgui_c.h:45,
                 from /home/ourhome/catkin_workspace/src/darknet_ros/darknet/include/darknet.h:25,
                 from /home/ourhome/catkin_workspace/src/darknet_ros/darknet/src/activations.h:3,
                 from /home/ourhome/catkin_workspace/src/darknet_ros/darknet/src/activation_layer.h:4,
                 from /home/ourhome/catkin_workspace/src/darknet_ros/darknet/src/activation_layer.c:1:
/usr/include/opencv4/opencv2/core/cvdef.h:704:4: error: #error "OpenCV 4.x+ requires enabled C++11 support"
  704 | #  error "OpenCV 4.x+ requires enabled C++11 support"
      |    ^~~~~
compilation terminated due to -Wfatal-errors.
make[2]: *** [darknet_ros/darknet_ros/CMakeFiles/darknet_ros_lib.dir/build.make:89: darknet_ros/darknet_ros/CMakeFiles/darknet_ros_lib.dir/__/darknet/src/activation_layer.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....

cd /home/ourhome/catkin_workspace/build/darknet_ros/darknet_ros && /bin/cc -DDARKNET_FILE_PATH=\"/home/ourhome/catkin_workspace/src/darknet_ros/darknet\" -DOPENCV -DROSCONSOLE_BACKEND_LOG4CXX -DROS_BUILD_SHARED_LIBS=1 -DROS_PACKAGE_NAME=\"darknet_ros\" -Ddarknet_ros_lib_EXPORTS -I/home/ourhome/catkin_workspace/src/darknet_ros/darknet/src -I/home/ourhome/catkin_workspace/src/darknet_ros/darknet/include -I/home/ourhome/catkin_workspace/src/darknet_ros/darknet_ros/include -I/include -I/home/ourhome/catkin_workspace/devel/include -I/opt/ros/noetic/include -I/opt/ros/noetic/share/xmlrpcpp/cmake/../../../include/xmlrpcpp -isystem /usr/include/opencv4  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wno-unused-variable -Wfatal-errors -fPIC  -O3 -DNDEBUG -fPIC   -O4 -g -o CMakeFiles/darknet_ros_lib.dir/src/image_interface.c.o   -c /home/ourhome/catkin_workspace/src/darknet_ros/darknet_ros/src/image_interface.c

In file included from /usr/include/opencv4/opencv2/core/types_c.h:84,
                 from /usr/include/opencv4/opencv2/core/core_c.h:48,
                 from /usr/include/opencv4/opencv2/highgui/highgui_c.h:45,
                 from /home/ourhome/catkin_workspace/src/darknet_ros/darknet/include/darknet.h:25,
                 from /home/ourhome/catkin_workspace/src/darknet_ros/darknet/src/box.h:3,
                 from /home/ourhome/catkin_workspace/src/darknet_ros/darknet/src/image.h:9,
                 from /home/ourhome/catkin_workspace/src/darknet_ros/darknet_ros/include/darknet_ros/image_interface.h:12,
                 from /home/ourhome/catkin_workspace/src/darknet_ros/darknet_ros/src/image_interface.c:9:
/usr/include/opencv4/opencv2/core/cvdef.h:704:4: error: #error "OpenCV 4.x+ requires enabled C++11 support"
  704 | #  error "OpenCV 4.x+ requires enabled C++11 support"
      |    ^~~~~
compilation terminated due to -Wfatal-errors.
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-01-07 21:41:31 -0500

It might be helpful to see what errors you are dealing with.

If you are asking for a working yolo model with ros, it might be useful to look into intel's openvino toolkit. Their ros bridge has worked for me in the past. You can use any of the models from the open model zoo or use your own trained darknet model. You can convert your yolo models to their intermediate representation and its ready to deploy in ros. Just change the model params in your launch file.

edit flag offensive delete link more

Comments

Sorry was waiting for my colleague to provide them but wanted to start a thread. I've updated the original.

It looks like the version of OpenCV installed expects to be compiled with C++, but darknet_ros is using standard C for some programs. OpenCV has an assertion saying it must be compiled with C++ 11 version. So, it blows up.

RobbieTheK gravatar image RobbieTheK  ( 2021-01-08 11:14:24 -0500 )edit

add this line in your CMakeLists.txt:

## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)
Akhil Kurup gravatar image Akhil Kurup  ( 2021-01-08 13:52:11 -0500 )edit

that option is already set. From the CMakeLists.txt:

# Set c++11 cmake flags

set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")

set(CMAKE_C_FLAGS "-Wall -Wno-unused-result -Wno-unknown-pragmas -Wno-unused-variable -Wfatal-errors -fPIC ${CMAKE_C_FLAGS}")

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

I tried adding it anyway, but it didn't change the errors.

If you look at the errors closely, it is compiling in C and not C++. So the root of the problem is that there are C programs including the C++ headers or some other type of conflict.

Similar issue here.

Is this related?

RobbieTheK gravatar image RobbieTheK  ( 2021-01-08 19:43:34 -0500 )edit

Did you take a look at the openvino ros toolkit? Or are you bound to the darknet_ros package?

Akhil Kurup gravatar image Akhil Kurup  ( 2021-01-08 23:36:43 -0500 )edit

My colleague did get a non-ROS version of darknet to compile But ideally we'd like to use darknet_ros. Any other suggested around?

RobbieTheK gravatar image RobbieTheK  ( 2021-01-09 09:34:47 -0500 )edit

Hello! I am currently experiencing the same problem. Did you find a solution for it?

JMMK gravatar image JMMK  ( 2022-03-16 11:47:08 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-01-07 19:15:06 -0500

Seen: 1,187 times

Last updated: Jan 08 '21