Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ros2 #20

Open
wants to merge 8 commits into
base: foxy-devel
Choose a base branch
from
Open

Ros2 #20

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 63 additions & 49 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,66 +1,80 @@
cmake_minimum_required(VERSION 2.8.3)

cmake_minimum_required(VERSION 3.5)
project(vrpn_client_ros)

find_package(catkin REQUIRED COMPONENTS geometry_msgs roscpp tf2_ros)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(VRPN REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_kdl REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)

catkin_package(
INCLUDE_DIRS include
LIBRARIES vrpn_client_ros
CATKIN_DEPENDS geometry_msgs tf2_ros
DEPENDS VRPN
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

set_directory_properties(PROPERTIES COMPILE_OPTIONS "-std=c++11;-Wall")

include_directories(
include
${catkin_INCLUDE_DIRS}
SYSTEM ${VRPN_INCLUDE_DIR}
)
include_directories(include)

add_library(vrpn_client_ros
src/vrpn_client_ros.cpp
)
target_link_libraries(vrpn_client_ros
${catkin_LIBRARIES}
${VRPN_LIBRARIES}
)
src/vrpn_client_ros.cpp)
ament_target_dependencies(vrpn_client_ros rclcpp std_msgs geometry_msgs tf2 tf2_ros tf2_kdl tf2_geometry_msgs VRPN)

add_executable(vrpn_tracker_node
src/vrpn_tracker_node.cpp)
add_dependencies(vrpn_tracker_node vrpn_client_ros)
target_link_libraries(vrpn_tracker_node
vrpn_client_ros
${catkin_LIBRARIES}
)
add_executable(vrpn_tracker_node src/vrpn_tracker_node.cpp)
target_link_libraries(vrpn_tracker_node vrpn_client_ros)
ament_target_dependencies(vrpn_tracker_node rclcpp std_msgs geometry_msgs tf2 tf2_ros tf2_kdl tf2_geometry_msgs VRPN)

add_executable(vrpn_client_node
src/vrpn_client_node.cpp)
add_dependencies(vrpn_client_node vrpn_client_ros)
target_link_libraries(vrpn_client_node
vrpn_client_ros
${catkin_LIBRARIES}
)
add_executable(vrpn_client_node src/vrpn_client_node.cpp)
target_link_libraries(vrpn_client_node vrpn_client_ros)
ament_target_dependencies(vrpn_client_node rclcpp std_msgs geometry_msgs tf2 tf2_ros tf2_kdl tf2_geometry_msgs VRPN)

install(TARGETS vrpn_client_ros vrpn_tracker_node vrpn_client_node
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
)

install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
install(DIRECTORY
config
DESTINATION share/${PROJECT_NAME}/
)

install(DIRECTORY launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
install(TARGETS
vrpn_client_ros
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)

install(TARGETS
vrpn_tracker_node
vrpn_client_node
DESTINATION lib/${PROJECT_NAME}
)

if(CATKIN_ENABLE_TESTING)
find_package(roslaunch REQUIRED)
find_package(roslint REQUIRED)
roslint_cpp()
roslint_add_test()
roslaunch_add_file_check(launch)
endif()
ament_package()
156 changes: 156 additions & 0 deletions cmake/FindVRPN.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# - try to find VRPN library
#
# Cache Variables:
# VRPN_LIBRARY
# VRPN_SERVER_LIBRARY
# VRPN_INCLUDE_DIR
#
# Non-cache variables you might use in your CMakeLists.txt:
# VRPN_FOUND
# VRPN_SERVER_LIBRARIES - server libraries
# VRPN_LIBRARIES - client libraries
# VRPN_CLIENT_DEFINITIONS - definitions if you only use the client library
# VRPN_DEFINITIONS - Client-only definition if all we found was the client library.
# VRPN_INCLUDE_DIRS
#
# VRPN_ROOT_DIR is searched preferentially for these files
#
# Requires these CMake modules:
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# 2009-2012 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2012.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

set(VRPN_ROOT_DIR
"${VRPN_ROOT_DIR}"
CACHE
PATH
"Root directory to search for VRPN")

if("${CMAKE_SIZEOF_VOID_P}" MATCHES "8")
set(_libsuffixes lib64 lib)

# 64-bit dir: only set on win64
file(TO_CMAKE_PATH "$ENV{ProgramW6432}" _progfiles)
else()
set(_libsuffixes lib)
set(_PF86 "ProgramFiles(x86)")
if(NOT "$ENV{${_PF86}}" STREQUAL "")
# 32-bit dir: only set on win64
file(TO_CMAKE_PATH "$ENV{${_PF86}}" _progfiles)
else()
# 32-bit dir on win32, useless to us on win64
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _progfiles)
endif()
endif()

set(_vrpn_quiet)
if(VRPN_FIND_QUIETLY)
set(_vrpn_quiet QUIET)
endif()

###
# Configure VRPN
###

find_path(VRPN_INCLUDE_DIR
NAMES
vrpn_Connection.h
PATH_SUFFIXES
include
include/vrpn
HINTS
"${VRPN_ROOT_DIR}"
PATHS
"${_progfiles}/VRPN"
C:/usr/local
/usr/local)

find_library(VRPN_LIBRARY
NAMES
vrpn
PATH_SUFFIXES
${_libsuffixes}
HINTS
"${VRPN_ROOT_DIR}"
PATHS
"${_progfiles}/VRPN"
C:/usr/local
/usr/local)

find_library(VRPN_SERVER_LIBRARY
NAMES
vrpnserver
PATH_SUFFIXES
${_libsuffixes}
HINTS
"${VRPN_ROOT_DIR}"
PATHS
"${_progfiles}/VRPN"
C:/usr/local
/usr/local)

###
# Dependencies
###
set(_deps_libs)
set(_deps_includes)
set(_deps_check)

find_package(quatlib ${_vrpn_quiet})
list(APPEND _deps_libs ${QUATLIB_LIBRARIES})
list(APPEND _deps_includes ${QUATLIB_INCLUDE_DIRS})
list(APPEND _deps_check QUATLIB_FOUND)

if(NOT WIN32)
find_package(Threads ${_vrpn_quiet})
list(APPEND _deps_libs ${CMAKE_THREAD_LIBS_INIT})
list(APPEND _deps_check CMAKE_HAVE_THREADS_LIBRARY)
endif()

if(WIN32)
find_package(Libusb1 QUIET)
if(LIBUSB1_FOUND)
list(APPEND _deps_libs ${LIBUSB1_LIBRARIES})
list(APPEND _deps_includes ${LIBUSB1_INCLUDE_DIRS})
endif()
endif()


# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(VRPN
DEFAULT_MSG
VRPN_LIBRARY
VRPN_INCLUDE_DIR
${_deps_check})

if(VRPN_FOUND)
set(VRPN_INCLUDE_DIRS "${VRPN_INCLUDE_DIR}" ${_deps_includes})
set(VRPN_LIBRARIES "${VRPN_LIBRARY}" ${_deps_libs})
set(VRPN_SERVER_LIBRARIES "${VRPN_SERVER_LIBRARY}" ${_deps_libs})

if(VRPN_LIBRARY)
set(VRPN_CLIENT_DEFINITIONS -DVRPN_CLIENT_ONLY)
else()
unset(VRPN_CLIENT_DEFINITIONS)
endif()

if(VRPN_LIBRARY AND NOT VRPN_SERVER_LIBRARY)
set(VRPN_DEFINITIONS -DVRPN_CLIENT_ONLY)
else()
unset(VRPN_DEFINITIONS)
endif()

mark_as_advanced(VRPN_ROOT_DIR)
endif()

mark_as_advanced(VRPN_LIBRARY VRPN_SERVER_LIBRARY VRPN_INCLUDE_DIR)
104 changes: 104 additions & 0 deletions cmake/Findquatlib.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# - Find quatlib
# Find the quatlib headers and libraries.
#
# QUATLIB_INCLUDE_DIRS - where to find quat.h
# QUATLIB_LIBRARIES - List of libraries when using quatlib.
# QUATLIB_FOUND - True if quatlib found.
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

if(TARGET quat)
# Look for the header file.
find_path(QUATLIB_INCLUDE_DIR NAMES quat.h
PATHS ${quatlib_SOURCE_DIR})

set(QUATLIB_LIBRARY "quat")

else()
set(QUATLIB_ROOT_DIR
"${QUATLIB_ROOT_DIR}"
CACHE
PATH
"Root directory to search for quatlib")
if(DEFINED VRPN_ROOT_DIR AND NOT QUATLIB_ROOT_DIR)
set(QUATLIB_ROOT_DIR "${VRPN_ROOT_DIR}")
mark_as_advanced(QUATLIB_ROOT_DIR)
endif()

if("${CMAKE_SIZEOF_VOID_P}" MATCHES "8")
set(_libsuffixes lib64 lib)

# 64-bit dir: only set on win64
file(TO_CMAKE_PATH "$ENV{ProgramW6432}" _progfiles)
else()
set(_libsuffixes lib)
set(_PF86 "ProgramFiles(x86)")
if(NOT "$ENV{${_PF86}}" STREQUAL "")
# 32-bit dir: only set on win64
file(TO_CMAKE_PATH "$ENV{${_PF86}}" _progfiles)
else()
# 32-bit dir on win32, useless to us on win64
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _progfiles)
endif()
endif()

# Look for the header file.
find_path(QUATLIB_INCLUDE_DIR
NAMES
quat.h
HINTS
"${QUATLIB_ROOT_DIR}"
PATH_SUFFIXES
include
PATHS
"${_progfiles}/VRPN"
"${_progfiles}/quatlib"
C:/usr/local
/usr/local)

# Look for the library.
find_library(QUATLIB_LIBRARY
NAMES
quat.lib
libquat.a
HINTS
"${QUATLIB_ROOT_DIR}"
PATH_SUFFIXES
${_libsuffixes}
PATHS
"${_progfiles}/VRPN"
"${_progfiles}/quatlib"
C:/usr/local
/usr/local)
endif()

# handle the QUIETLY and REQUIRED arguments and set QUATLIB_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(quatlib
DEFAULT_MSG
QUATLIB_LIBRARY
QUATLIB_INCLUDE_DIR)

if(QUATLIB_FOUND)
set(QUATLIB_LIBRARIES ${QUATLIB_LIBRARY})
if(NOT WIN32)
list(APPEND QUATLIB_LIBRARIES m)
endif()
set(QUATLIB_INCLUDE_DIRS ${QUATLIB_INCLUDE_DIR})

mark_as_advanced(QUATLIB_ROOT_DIR)
else()
set(QUATLIB_LIBRARIES)
set(QUATLIB_INCLUDE_DIRS)
endif()

mark_as_advanced(QUATLIB_LIBRARY QUATLIB_INCLUDE_DIR)
Loading