custom ros package not detected after catkin_make
Hi guys,
I am working with openVino, and I am currently trying to integrate their sample code to ros (in a package that I called openvinotry). So I changed the code in the cpp file, adding pub and sub, I added the essential things in the cmake and in the package.xml, and everything seems to compile fine:
-- ~~ traversing 5 packages in topological order:
-- ~~ - realsense2_description
-- ~~ - object_msgs
-- ~~ - open_vino_try
-- ~~ - opencv_tuto
-- ~~ - realsense2_camera
Scanning dependencies of target open_vino_try
[ 88%] Building CXX object open_vino_try/pedestrian_tracker_demo/CMakeFiles/open_vino_try.dir/main.cpp.o
[ 90%] Building CXX object open_vino_try/pedestrian_tracker_demo/CMakeFiles/open_vino_try.dir/src/cnn.cpp.o
[ 92%] Building CXX object open_vino_try/pedestrian_tracker_demo/CMakeFiles/open_vino_try.dir/src/kuhn_munkres.cpp.o
[ 92%] Building CXX object open_vino_try/pedestrian_tracker_demo/CMakeFiles/open_vino_try.dir/src/detector.cpp.o
[ 94%] Building CXX object open_vino_try/pedestrian_tracker_demo/CMakeFiles/open_vino_try.dir/src/distance.cpp.o
[ 95%] Building CXX object open_vino_try/pedestrian_tracker_demo/CMakeFiles/open_vino_try.dir/src/tracker.cpp.o
[ 97%] Building CXX object open_vino_try/pedestrian_tracker_demo/CMakeFiles/open_vino_try.dir/src/utils.cpp.o
[ 98%] Linking CXX executable /home/antoine/catkin_ws/devel/lib/open_vino_try/open_vino_try
[ 98%] Built target open_vino_try
But then I cannot run it through a rosrun, and actually the package does not appear anywhere, no matters the command. I obviously tried to source the devel every time but nothing changes.
The structure of my project is the following: I have my pkg (openvinotry) which will hold many subfolders, corresponding to the different sample code from OpenVino (btw I am aware that ros packages already exist, but they didn't seem to work properly, and moreover I really want to know why it is not working). For now there is only one subfolder: pedestriantrackerdemo. So I have a "big" CMakeLists at the root of my pkg which will call other CMakeLists in the different subfolder.
That the tree of my project:
- openvinotry (my package)
- CMakeLists.txt
- Package.xml
- pedestriantrackerdemo
- CMakeLists.txt
- src (folder)
- include
- main.cpp
- (Other folder denpencies)
This is my CMakeFiles in the pkg root folder:
cmake_minimum_required(VERSION 3.0.2)
project(open_vino_try)
find_package(catkin REQUIRED COMPONENTS
cv_bridge
image_transport
roscpp
sensor_msgs
std_msgs
rospy
)
catkin_package()
option(ENABLE_PYTHON "Whether to build extension modules for Python demos" OFF)
if (CMAKE_BUILD_TYPE STREQUAL "")
message(STATUS "CMAKE_BUILD_TYPE not defined, 'Release' will be used")
set(CMAKE_BUILD_TYPE "Release")
endif()
if (NOT(BIN_FOLDER))
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} ARCH)
if(ARCH STREQUAL "x86_64" OR ARCH STREQUAL "amd64") # Windows detects Intel's 64-bit CPU as AMD64
set(ARCH intel64)
elseif(ARCH STREQUAL "i386")
set(ARCH ia32)
endif()
set (BIN_FOLDER ${ARCH})
endif()
if (NOT(IE_MAIN_SOURCE_DIR))
# in case if samples are built out of IE repo
set (IE_MAIN_SAMPLES_DIR ${CMAKE_CURRENT_BINARY_DIR})
else()
# in case if samples are built from IE repo
set (IE_MAIN_SAMPLES_DIR ${IE_MAIN_SOURCE_DIR})
endif()
if(NOT(UNIX))
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
set (CMAKE_LIBRARY_PATH ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
set (CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
set (CMAKE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
#set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
set (LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
set (LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}) # compatibility issue: linux uses LIBRARY_OUTPUT_PATH, windows uses LIBRARY_OUTPUT_DIRECTORY
else ()
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
set (CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
set (CMAKE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
#set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "/home/antoine/catkin_ws/devel/lib/open_vino_try")
set (LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
set (LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}/lib)
endif()
if (WIN32)
if (NOT "${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message(FATAL_ERROR "Only 64-bit supported on Windows")
endif()
set_property (DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS -DNOMINMAX")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") #no asynchronous structured exception handling
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
if (TREAT_WARNING_AS_ERROR)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") #treating warnings as errors
endif ()
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251 /wd4275 /wd4267") #disable some warnings
endif()
else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") #treating warnings as errors
if (APPLE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-command-line-argument")
elseif(UNIX)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuninitialized -Winit-self")
if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmaybe-uninitialized")
endif()
endif()
endif()
####################################
## to use C++11
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
set (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
endif()
####################################
set (GFLAGS_IS_SUBPROJECT TRUE)
set (HAVE_SYS_STAT_H 1)
set (HAVE_INTTYPES_H 1)
add_subdirectory(thirdparty/gflags)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
add_subdirectory(common)
# samples build can be switched off during whole IE build
if (IE_MAIN_SOURCE_DIR AND NOT ENABLE_SAMPLES)
return()
endif()
function(add_samples_to_build)
# check each passed sample subdirectory
foreach (dir ${ARGN})
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
# check if a subdirectory contains CMakeLists.txt. In this case we can build it.
file(GLOB is_sample_dir "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/CMakeLists.txt")
if(is_sample_dir)
# check if specified sample/demo is found.
if (BUILD_SAMPLE_NAME)
list(FIND BUILD_SAMPLE_NAME ${dir} index)
endif()
if (index EQUAL -1)
message(STATUS "${dir} SKIPPED")
else()
# Include subdirectory to the project.
add_subdirectory(${dir})
endif()
endif()
endif()
endforeach()
endfunction(add_samples_to_build)
include(CMakeParseArguments)
#
# ie_add_sample(NAME <target name>
# SOURCES <source files>
# [HEADERS <header files>]
# [INCLUDE_DIRECTORIES <include dir>]
# [DEPENDENCIES <dependencies>]
# [OPENCV_DENENDENCIES <opencv modules>]
# [EXCLUDE_CPPLINT]
#
macro(ie_add_sample)
set(options EXCLUDE_CPPLINT)
set(oneValueArgs NAME)
set(multiValueArgs SOURCES HEADERS DEPENDENCIES OPENCV_DEPENDENCIES INCLUDE_DIRECTORIES)
cmake_parse_arguments(IE_SAMPLE "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )
# Find OpenCV components if exist
if(IE_SAMPLE_OPENCV_DEPENDENCIES)
find_package(OpenCV COMPONENTS ${IE_SAMPLE_OPENCV_DEPENDENCIES} QUIET)
if(NOT OpenCV_FOUND)
message(WARNING "OPENCV is disabled or not found, " ${IE_SAMPLE_NAME} " skipped")
return()
else()
add_definitions(-DUSE_OPENCV)
endif()
endif()
# Create named folders for the sources within the .vcproj
# Empty name lists them directly under the .vcproj
source_group("src" FILES ${IE_SAMPLE_SOURCES})
if(IE_SAMPLE_HEADERS)
source_group("include" FILES ${IE_SAMPLE_HEADERS})
endif()
# Create executable file from sources
add_executable(${IE_SAMPLE_NAME} ${IE_SAMPLE_SOURCES} ${IE_SAMPLE_HEADERS})
if(WIN32)
set_target_properties(${IE_SAMPLE_NAME} PROPERTIES COMPILE_PDB_NAME ${IE_SAMPLE_NAME})
endif()
if(IE_SAMPLE_INCLUDE_DIRECTORIES)
target_include_directories(${IE_SAMPLE_NAME} PRIVATE ${IE_SAMPLE_INCLUDE_DIRECTORIES})
endif()
target_include_directories(${IE_SAMPLE_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../common")
target_link_libraries(${IE_SAMPLE_NAME} PRIVATE ${OpenCV_LIBRARIES} ${InferenceEngine_LIBRARIES}
${IE_SAMPLE_DEPENDENCIES} gflags)
if(UNIX)
target_link_libraries(${IE_SAMPLE_NAME} PRIVATE pthread)
endif()
# create global target with all samples / demo apps
if(NOT TARGET ie_samples)
add_custom_target(ie_samples ALL)
endif()
add_dependencies(ie_samples ${IE_SAMPLE_NAME})
if(COMMAND add_cpplint_target AND NOT IE_SAMPLE_EXCLUDE_CPPLINT)
add_cpplint_target(${IE_SAMPLE_NAME}_cpplint FOR_TARGETS ${IE_SAMPLE_NAME})
endif()
endmacro()
# use this flag if you need to throw custom message in case if the IE package is not found.
if (IE_NOT_FOUND_MESSAGE)
find_package(InferenceEngine 2.0 QUIET)
if (NOT(InferenceEngine_FOUND))
message(FATAL_ERROR ${IE_NOT_FOUND_MESSAGE})
endif()
else()
find_package(InferenceEngine 2.0 REQUIRED)
endif()
find_package(ngraph REQUIRED)
# collect all samples subdirectories
file(GLOB samples_dirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
# skip building of unnecessary subdirectories
list(REMOVE_ITEM samples_dirs common thirdparty)
add_samples_to_build(${samples_dirs})
if(ENABLE_PYTHON)
find_package(PythonInterp 3.5 REQUIRED)
find_package(PythonLibs "${PYTHON_VERSION_STRING}" EXACT REQUIRED)
add_subdirectory(python_demos/human_pose_estimation_3d_demo/pose_extractor)
endif()
include_directories(
${catkin_INCLUDE_DIRS}
)
message(" Output directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ")
This is the Package.xml:
<?xml version="1.0"?>
<package format="2">
<name>open_vino_try</name>
<version>0.0.0</version>
<description>The opencv_tuto package</description>
<maintainer email="ehsan@todo.todo">ehsan</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>cv_bridge</build_depend>
<build_depend>image_transport</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>cv_bridge</build_export_depend>
<build_export_depend>image_transport</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>cv_bridge</exec_depend>
<exec_depend>image_transport</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
And this is my CMakeFiles in the subfolder pedestriantrackerdemo:
# Copyright (C) 2018-2019 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
file (GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file (GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
ie_add_sample(NAME open_vino_try
SOURCES ${SOURCES}
HEADERS ${HEADERS}
INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include"
DEPENDENCIES monitors
OPENCV_DEPENDENCIES highgui)
target_link_libraries(open_vino_try PRIVATE
${catkin_LIBRARIES}
)
target_link_libraries(open_vino_try PRIVATE ngraph::ngraph)
I have no idea what to do now, do you see an obvious mistake? I know the code is "heavy" but thanks for your time!
Antoine
Asked by AntoineKuleba on 2020-07-01 08:50:22 UTC
Answers
Well, after several days of trying everything, I finally found the issue.
For this particular package, I do not know why, but to allow the rosrun command to find my pkg, I have first to make a rospack depends1 pkg_name ( after sourcing the devel/setup obviously). This command succeeds in locating my package, and then it seems to update it and then allows me to run the command rosrun. It doesn't seem to be a normal process, does anyone have encounter such similar behavior?
Asked by AntoineKuleba on 2020-07-06 02:38:46 UTC
Comments
try
source ~/.bashrc
... I have to do that each time after I catkin build a new package.... otherwise it could not locate the new packageAsked by xibeisiber on 2020-07-01 09:13:58 UTC
Hi, sorry I forgot to say that I did it everytime, and sourcing the devel/setup.bash, but nothing changes!
Asked by AntoineKuleba on 2020-07-01 09:21:06 UTC