From 49bcfb15f13615e6904051ffce25e1cafb0e0833 Mon Sep 17 00:00:00 2001 From: Joshua Whitley Date: Wed, 12 Dec 2018 15:12:34 -0600 Subject: [PATCH 1/3] package.xml to version 2. Cleaning up CMakeLists. Fixing ROS_INFO calls. This is a squashed, updated version of PR #14. --- CMakeLists.txt | 244 +++--------------- cmake/FindLibUnwind.cmake | 42 +++ .../camera.h | 0 .../capture.h | 6 +- .../serialization.h | 0 .../std_include.h | 0 .../{ => spinnaker_sdk_camera_driver}/utils.h | 0 ...mage_names.msg => SpinnakerImageNames.msg} | 0 package.xml | 32 +-- src/acquisition_node.cpp | 2 +- src/camera.cpp | 2 +- src/capture.cpp | 8 +- src/utils.cpp | 2 +- 13 files changed, 100 insertions(+), 238 deletions(-) create mode 100644 cmake/FindLibUnwind.cmake rename include/{ => spinnaker_sdk_camera_driver}/camera.h (100%) rename include/{ => spinnaker_sdk_camera_driver}/capture.h (95%) rename include/{ => spinnaker_sdk_camera_driver}/serialization.h (100%) rename include/{ => spinnaker_sdk_camera_driver}/std_include.h (100%) rename include/{ => spinnaker_sdk_camera_driver}/utils.h (100%) rename msg/{spinnaker_image_names.msg => SpinnakerImageNames.msg} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 017a86a..f9cd37d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 2.8.3) project(spinnaker_sdk_camera_driver) -## Compile as C++11, supported in ROS Kinetic and newer -# add_compile_options(-std=c++11) +add_compile_options(-std=c++11) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") ### # camera Acquisition specific @@ -15,19 +15,13 @@ set(SPINNAKER_LIB_DIR "/usr/lib" CACHE PATH "Spinnaker Libs Directory") # set(yaml-cpp_DIR "~/apps/yaml-cpp" CACHE PATH "yaml-cpp Directory") set(CUDA_USE_STATIC_CUDA_RUNTIME OFF) - -## Find catkin macros and libraries -## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) -## is used, also find other catkin packages find_package(catkin REQUIRED COMPONENTS roscpp - rospy std_msgs message_generation cv_bridge image_transport sensor_msgs -# tf ) #find_package(PCL REQUIRED) @@ -37,8 +31,9 @@ find_package(catkin REQUIRED COMPONENTS ### # Find Packages find_package(OpenCV REQUIRED) +find_package(LibUnwind REQUIRED) -find_package(Boost) +find_package(Boost REQUIRED) if(Boost_FOUND) find_package ( Boost COMPONENTS filesystem system serialization REQUIRED ) set(Boost_GENERAL ${Boost_LIBRARIES}) @@ -46,219 +41,54 @@ elseif(NOT Boost_FOUND) message("Boost not found!") endif() -## System dependencies are found with CMake's conventions -# find_package(Boost REQUIRED COMPONENTS system) - - -## Uncomment this if the package has a setup.py. This macro ensures -## modules and global scripts declared therein get installed -## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html -# catkin_python_setup() - -################################################ -## Declare ROS messages, services and actions ## -################################################ - -## To declare and build messages, services or actions from within this -## package, follow these steps: -## * Let MSG_DEP_SET be the set of packages whose message types you use in -## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). -## * In the file package.xml: -## * add a build_depend tag for "message_generation" -## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET -## * If MSG_DEP_SET isn't empty the following dependency has been pulled in -## but can be declared for certainty nonetheless: -## * add a run_depend tag for "message_runtime" -## * In this file (CMakeLists.txt): -## * add "message_generation" and every package in MSG_DEP_SET to -## find_package(catkin REQUIRED COMPONENTS ...) -## * add "message_runtime" and every package in MSG_DEP_SET to -## catkin_package(CATKIN_DEPENDS ...) -## * uncomment the add_*_files sections below as needed -## and list every .msg/.srv/.action file to be processed -## * uncomment the generate_messages entry below -## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) - -## Generate messages in the 'msg' folder - add_message_files( - FILES - spinnaker_image_names.msg - ) - -## Generate added messages and services with any dependencies listed here - generate_messages( - DEPENDENCIES - std_msgs - ) - -## Generate services in the 'srv' folder -# add_service_files( -# FILES -# Service1.srv -# Service2.srv -# ) - -## Generate actions in the 'action' folder -# add_action_files( -# FILES -# Action1.action -# Action2.action -# ) - - - -################################################ -## Declare ROS dynamic reconfigure parameters ## -################################################ - -## To declare and build dynamic reconfigure parameters within this -## package, follow these steps: -## * In the file package.xml: -## * add a build_depend and a run_depend tag for "dynamic_reconfigure" -## * In this file (CMakeLists.txt): -## * add "dynamic_reconfigure" to -## find_package(catkin REQUIRED COMPONENTS ...) -## * uncomment the "generate_dynamic_reconfigure_options" section below -## and list every .cfg file to be processed +add_message_files( + FILES + SpinnakerImageNames.msg +) -## Generate dynamic reconfigure parameters in the 'cfg' folder -# generate_dynamic_reconfigure_options( -# cfg/DynReconf1.cfg -# cfg/DynReconf2.cfg -# ) +generate_messages( + DEPENDENCIES + std_msgs +) -################################### -## catkin specific configuration ## -################################### -## The catkin_package macro generates cmake config files for your package -## Declare things to be passed to dependent projects -## INCLUDE_DIRS: uncomment this if you package contains header files -## LIBRARIES: libraries you create in this project that dependent projects also need -## CATKIN_DEPENDS: catkin_packages dependent projects also need -## DEPENDS: system dependencies of this project that dependent projects also need catkin_package( - INCLUDE_DIRS include - #LIBRARIES datacollection_neu - CATKIN_DEPENDS roscpp rospy std_msgs message_runtime -# DEPENDS system_lib + INCLUDE_DIRS include + CATKIN_DEPENDS roscpp std_msgs message_runtime + DEPENDS OpenCV LibUnwind ) -########### -## Build ## -########### - -## Specify additional locations of header files -## Your package locations should be listed before other locations include_directories( -# include + ${PROJECT_INCLUDE_DIR} ${catkin_INCLUDE_DIRS} -# ${PCL_INCLUDE_DIRS} + ${SPINNAKER_INCLUDE_DIR} + ${OpenCV_INCLUDE_DIRS} + ${Boost_INCLUDE_DIR} + ${LibUnwind_INCLUDE_DIRS} ) -include_directories( ${PROJECT_INCLUDE_DIR} ) -include_directories( ${SPINNAKER_INCLUDE_DIR} ) -include_directories( ${OpenCV_INCLUDE_DIRS} ) -include_directories( ${Boost_INCLUDE_DIR} ) -#include_directories( ${YAML_CPP_INCLUDE_DIR} ) - -## Declare a C++ library -add_library (acquilib SHARED - # ${PROJECT_SOURCE_DIR}/src/utils.cpp - src/capture.cpp - src/camera.cpp) link_directories( ${SPINNAKER_LIB_DIR} ) -# Settings libraries to link to -# set (ROS_LIBS ${cv_bridge_LIBRARIES} ${image_transport_LIBRARIES}) -#set (LIBS glog gflags gomp unwind Spinnaker yaml-cpp ${OpenCV_LIBS} ${Boost_GENERAL}) # ${ROS_LIBS} profiler -set (LIBS gomp unwind Spinnaker ${OpenCV_LIBS} ${Boost_GENERAL}) # ${ROS_LIBS} profiler -# Custom compiler flags -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -std=c++11") +set (LIBS ${LibUnwind_LIBRARIES} Spinnaker ${OpenCV_LIBS} ${Boost_GENERAL}) -# add_library(${PROJECT_NAME} -# src/${PROJECT_NAME}/datacollection_neu.cpp -# ) +add_library (acquilib SHARED + src/capture.cpp + src/camera.cpp +) -## Add cmake target dependencies of the library -## as an example, code may need to be generated before libraries -## either from message generation or dynamic reconfigure -# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) +add_dependencies(acquilib ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) +target_link_libraries(acquilib ${LIBS} ${catkin_LIBRARIES}) -## Declare a C++ executable -## With catkin_make all packages are built within a single CMake context -## The recommended prefix ensures that target names across packages don't collide -#add_executable(${PROJECT_NAME}_node src/datacollection_neu_node.cpp) add_executable (acquisition_node src/acquisition_node.cpp) - - -#target_link_libraries (multiAcq_node acquilib ${LIBS} ) -#target_link_libraries (acquisition_mt_node acquilib ${LIBS} ${catkin_LIBRARIES}) -#target_link_libraries (conversion_node acquilib ${LIBS} ) +add_dependencies(acquisition_node acquilib ${catkin_EXPORTED_TARGETS}) target_link_libraries (acquisition_node acquilib ${LIBS} ${catkin_LIBRARIES}) -add_dependencies(acquisition_node spinnaker_sdk_camera_driver_generate_messages_cpp) -#add_dependencies(acquisition_mt_node datacollection_neu_generate_messages_cpp) - -## Rename C++ executable without prefix -## The above recommended prefix causes long target names, the following renames the -## target back to the shorter version for ease of user use -## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node" -# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "") - -## Add cmake target dependencies of the executable -## same as for the library above -# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) -add_dependencies(acquisition_node ${catkin_EXPORTED_TARGETS}) -#add_dependencies(acquisition_mt_node ${catkin_EXPORTED_TARGETS}) - -## Specify libraries to link a library or executable target against -# target_link_libraries(${PROJECT_NAME}_node -# ${catkin_LIBRARIES} -# ) -############# -## Install ## -############# - -# all install targets should use catkin DESTINATION variables -# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html - -## Mark executable scripts (Python etc.) for installation -## in contrast to setup.py, you can choose the destination -# install(PROGRAMS -# scripts/my_python_script -# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} -# ) - -## Mark executables and/or libraries for installation -# install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node -# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} -# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} -# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} -# ) - -## Mark cpp header files for installation -# install(DIRECTORY include/${PROJECT_NAME}/ -# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} -# FILES_MATCHING PATTERN "*.h" -# PATTERN ".svn" EXCLUDE -# ) - -## Mark other files for installation (e.g. launch and bag files, etc.) -# install(FILES -# # myfile1 -# # myfile2 -# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} -# ) - -############# -## Testing ## -############# - -## Add gtest based cpp test target and link libraries -# catkin_add_gtest(${PROJECT_NAME}-test test/test_datacollection_neu.cpp) -# if(TARGET ${PROJECT_NAME}-test) -# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) -# endif() +install(TARGETS acquilib acquisition_node + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) -## Add folders to be run by python nosetests -# catkin_add_nosetests(test) +install(DIRECTORY include + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} + FILES_MATCHING PATTERN "*.h" +) diff --git a/cmake/FindLibUnwind.cmake b/cmake/FindLibUnwind.cmake new file mode 100644 index 0000000..af4d1cc --- /dev/null +++ b/cmake/FindLibUnwind.cmake @@ -0,0 +1,42 @@ +# Find the libunwind library +# +# LibUnwind_FOUND - True if libunwind was found. +# LibUnwind_LIBRARIES - The libraries needed to use libunwind +# LibUnwind_INCLUDE_DIRS - Location of unwind.h and libunwind.h + +FIND_PATH(LibUnwind_INCLUDE_DIRS libunwind.h) +if(NOT LibUnwind_INCLUDE_DIRS) + message(STATUS "failed to find libunwind.h") +elseif(NOT EXISTS "${LibUnwind_INCLUDE_DIRS}/unwind.h") + message(STATUS "libunwind.h was found, but unwind.h was not found in that directory.") + SET(LibUnwind_INCLUDE_DIRS "") +endif() + +FIND_LIBRARY(LibUnwind_GENERIC_LIBRARY "unwind") +if(NOT LibUnwind_GENERIC_LIBRARY) + MESSAGE(STATUS "failed to find unwind generic library") +endif() +SET(LibUnwind_LIBRARIES ${LibUnwind_GENERIC_LIBRARY}) + +# For some reason, we have to link to two libunwind shared object files: +# one arch-specific and one not. +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") + SET(LibUnwind_ARCH "arm") +elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") + SET(LibUnwind_ARCH "x86_64") +elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") + SET(LibUnwind_ARCH "x86") +endif() + +if(LibUnwind_ARCH) + FIND_LIBRARY(LibUnwind_SPECIFIC_LIBRARY "unwind-${LibUnwind_ARCH}") + if (NOT LibUnwind_SPECIFIC_LIBRARY) + MESSAGE(STATUS "failed to find unwind-${LibUnwind_ARCH}") + endif() + SET(LibUnwind_LIBRARIES ${LibUnwind_LIBRARIES} ${LibUnwind_SPECIFIC_LIBRARY}) +endif(LibUnwind_ARCH) + +MARK_AS_ADVANCED(LibUnwind_LIBRARIES LibUnwind_INCLUDE_DIRS) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibUnwind DEFAULT_MSG + LibUnwind_LIBRARIES LibUnwind_INCLUDE_DIRS) diff --git a/include/camera.h b/include/spinnaker_sdk_camera_driver/camera.h similarity index 100% rename from include/camera.h rename to include/spinnaker_sdk_camera_driver/camera.h diff --git a/include/capture.h b/include/spinnaker_sdk_camera_driver/capture.h similarity index 95% rename from include/capture.h rename to include/spinnaker_sdk_camera_driver/capture.h index 9780078..fba1522 100755 --- a/include/capture.h +++ b/include/spinnaker_sdk_camera_driver/capture.h @@ -9,7 +9,7 @@ #include #include "std_msgs/String.h" -#include "spinnaker_sdk_camera_driver/spinnaker_image_names.h" +#include "spinnaker_sdk_camera_driver/SpinnakerImageNames.h" #include @@ -84,7 +84,7 @@ namespace acquisition { double grab_time_, save_time_, toMat_time_, save_mat_time_, export_to_ROS_time_, achieved_time_; int nframes_; - int init_delay_; + float init_delay_; int skip_num_; float master_fps_; int binning_; @@ -128,7 +128,7 @@ namespace acquisition { vector img_msgs; vector cam_info_msgs; - spinnaker_sdk_camera_driver::spinnaker_image_names mesg; + spinnaker_sdk_camera_driver::SpinnakerImageNames mesg; boost::mutex queue_mutex_; }; diff --git a/include/serialization.h b/include/spinnaker_sdk_camera_driver/serialization.h similarity index 100% rename from include/serialization.h rename to include/spinnaker_sdk_camera_driver/serialization.h diff --git a/include/std_include.h b/include/spinnaker_sdk_camera_driver/std_include.h similarity index 100% rename from include/std_include.h rename to include/spinnaker_sdk_camera_driver/std_include.h diff --git a/include/utils.h b/include/spinnaker_sdk_camera_driver/utils.h similarity index 100% rename from include/utils.h rename to include/spinnaker_sdk_camera_driver/utils.h diff --git a/msg/spinnaker_image_names.msg b/msg/SpinnakerImageNames.msg similarity index 100% rename from msg/spinnaker_image_names.msg rename to msg/SpinnakerImageNames.msg diff --git a/package.xml b/package.xml index 597270f..c9eb6fb 100755 --- a/package.xml +++ b/package.xml @@ -1,9 +1,8 @@ - + spinnaker_sdk_camera_driver 0.0.0 - Point Grey (FLIR) Spinnaker based camera driver (Blackfly S etc.) - + Point Grey (FLIR) Spinnaker based camera driver (Blackfly S etc.) Vikrant Shah @@ -16,24 +15,15 @@ http://wiki.ros.org/spinnaker_sdk_camera_driver catkin - roscpp - rospy - std_msgs + message_generation - cv_bridge - image_transport - sensor_msgs - tf - - roscpp - rospy - std_msgs - message_runtime - cv_bridge - image_transport - sensor_msgs - tf + libgomp1 + + roscpp + std_msgs + cv_bridge + image_transport + sensor_msgs - - + message_runtime diff --git a/src/acquisition_node.cpp b/src/acquisition_node.cpp index ecd7beb..ed5ee3e 100755 --- a/src/acquisition_node.cpp +++ b/src/acquisition_node.cpp @@ -1,4 +1,4 @@ -#include "capture.h" +#include "spinnaker_sdk_camera_driver/capture.h" using namespace Spinnaker; using namespace Spinnaker::GenApi; diff --git a/src/camera.cpp b/src/camera.cpp index 5372af0..c189032 100755 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -1,4 +1,4 @@ -#include "camera.h" +#include "spinnaker_sdk_camera_driver/camera.h" acquisition::Camera::~Camera() { diff --git a/src/capture.cpp b/src/capture.cpp index d83dda9..a8151c2 100755 --- a/src/capture.cpp +++ b/src/capture.cpp @@ -1,4 +1,4 @@ -#include "capture.h" +#include "spinnaker_sdk_camera_driver/capture.h" acquisition::Capture::~Capture(){ @@ -112,7 +112,7 @@ acquisition::Capture::Capture():nh_(),nh_pvt_ ("~") { load_cameras(); //initializing the ros publisher - acquisition_pub = nh_.advertise("camera", 1000); + acquisition_pub = nh_.advertise("camera", 1000); } void acquisition::Capture::load_cameras() { @@ -292,9 +292,9 @@ void acquisition::Capture::read_parameters() { if (init_delay_>=0) ROS_INFO(" Init sleep delays set to : %0.2f sec",init_delay_); else { init_delay_=1; - ROS_WARN(" Provided 'delay' is not valid, using default behavior, delay=%d",init_delay_); + ROS_WARN(" Provided 'delay' is not valid, using default behavior, delay=%f",init_delay_); } - } else ROS_WARN(" 'delay' Parameter not set, using default behavior: delay=%d",init_delay_); + } else ROS_WARN(" 'delay' Parameter not set, using default behavior: delay=%f",init_delay_); if (nh_pvt_.getParam("fps", master_fps_)){ if (master_fps_>=0) ROS_INFO(" Master cam fps set to : %0.2f",master_fps_); diff --git a/src/utils.cpp b/src/utils.cpp index 7bb7718..7cb9a4d 100755 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,4 +1,4 @@ -#include "utils.h" +#include "spinnaker_sdk_camera_driver/utils.h" using namespace Spinnaker; using namespace Spinnaker::GenApi; From 58234f669c307ab7a1eef27921db6b6c0499081c Mon Sep 17 00:00:00 2001 From: Joshua Whitley Date: Thu, 13 Dec 2018 15:41:46 -0600 Subject: [PATCH 2/3] Adding missing dependency on libunwind-dev. --- package.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/package.xml b/package.xml index c9eb6fb..0ef116e 100755 --- a/package.xml +++ b/package.xml @@ -18,6 +18,7 @@ message_generation libgomp1 + libunwind-dev roscpp std_msgs From e09dd69494da9ee34a5cee56f60b1f06d90fd829 Mon Sep 17 00:00:00 2001 From: Joshua Whitley Date: Mon, 17 Dec 2018 07:41:08 -0600 Subject: [PATCH 3/3] Removing leftover OpenMP depend. --- package.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/package.xml b/package.xml index 0ef116e..059f84e 100755 --- a/package.xml +++ b/package.xml @@ -17,7 +17,6 @@ catkin message_generation - libgomp1 libunwind-dev roscpp