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 devel #90

Open
wants to merge 27 commits into
base: ros2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 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
14 changes: 14 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
See [ROS wiki](http://wiki.ros.org/ar_track_alvar) for the users document.

### Testing (Build from Source)

The testing suite for this package makes use of a ros1 bag, and depends on the following [repo](https://github.com/ros2/rosbag2_bag_v2). In order to get it to work
you need to source both the ros1 underlay and the ros2 underlay in your ~/.bashrc file. Do this in a new terminal.

```
# ROS1
source /opt/ros/noetic/setup.bash

# ROS2
source /opt/ros/foxy/setup.bash
source /usr/share/colcon_cd/function/colcon_cd.sh
export _colcon_cd_root=/opt/ros/foxy

```
kscottz marked this conversation as resolved.
Show resolved Hide resolved
264 changes: 134 additions & 130 deletions ar_track_alvar/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,183 +1,187 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.5)
project(ar_track_alvar)

set(MSG_DEPS
ar_track_alvar_msgs
std_msgs
sensor_msgs
geometry_msgs
visualization_msgs)

find_package(catkin COMPONENTS
genmsg
roscpp
tf
tf2
image_transport
resource_retriever
cv_bridge
pcl_ros
pcl_conversions
message_generation
${MSG_DEPS}
dynamic_reconfigure
cmake_modules
REQUIRED)
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

find_package(Eigen3 REQUIRED)
find_package(OpenCV REQUIRED)
find_package(TinyXML REQUIRED)

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
if(NOT DEFINED CMAKE_SUPPRESS_DEVELOPER_WARNINGS)
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE INTERNAL "No dev warnings")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this new?

endif()

cmake_policy(SET CMP0046 OLD)

# dynamic reconfigure support
generate_dynamic_reconfigure_options(cfg/Params.cfg)

catkin_package(
INCLUDE_DIRS include
LIBRARIES ar_track_alvar
CATKIN_DEPENDS
ar_track_alvar_msgs
std_msgs
roscpp
tf
tf2
message_runtime
image_transport
sensor_msgs
geometry_msgs
visualization_msgs
resource_retriever
cv_bridge
pcl_ros
pcl_conversions
dynamic_reconfigure
find_package(rclcpp REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2 REQUIRED)
find_package(image_transport REQUIRED)
find_package(resource_retriever REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(perception_pcl REQUIRED)
find_package(pcl_ros)
find_package(pcl_conversions REQUIRED)
find_package(ar_track_alvar_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(rosbag2_bag_v2_plugins REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(PCL REQUIRED QUIET COMPONENTS common io)
find_package(Eigen3 REQUIRED)
find_package(tinyxml_vendor REQUIRED)

include_directories(include)

# Kinect filtering code
set(KINECT_FILTERING_TARGETS kinect_filtering medianFilter)
set(ALVAR_TARGETS ar_track_alvar individualMarkers individualMarkersNoKinect trainMarkerBundle findMarkerBundles findMarkerBundlesNoKinect createMarker)

set(dependencies
OpenCV
tf2_ros
tf2
pcl_ros

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried run rosdep install --from-paths src --ignore-src --rosdistro foxy -yr during installation, and this is not specified in package.xml. Also realized that pcl_ros is not available as debian in foxy.

Anyway, we can also remove this since that pcl_ros is not used anyway in the code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @youliangtan I made the changes you suggested

pcl_conversions
std_msgs
tinyxml_vendor
image_transport
perception_pcl
visualization_msgs
rclcpp
resource_retriever
geometry_msgs
tf2_geometry_msgs
cv_bridge
sensor_msgs
ar_track_alvar_msgs
)

include_directories(include
${catkin_INCLUDE_DIRS}
include_directories(include
${OpenCV_INCLUDE_DIRS}
${TinyXML_INCLUDE_DIRS}

${PCL_COMMON_INCLUDE_DIRS}
)

set(GENCPP_DEPS ar_track_alvar_msgs_gencpp std_msgs_gencpp sensor_msgs_gencpp geometry_msgs_gencpp visualization_msgs_gencpp)

add_library(ar_track_alvar
src/Camera.cpp
src/CaptureDevice.cpp
src/Pose.cpp
src/Marker.cpp
src/MarkerDetector.cpp
add_library(${PROJECT_NAME}
src/Bitset.cpp
src/Rotation.cpp
src/CvTestbed.cpp
src/Camera.cpp
src/CaptureDevice.cpp
src/CaptureFactory.cpp
src/CaptureFactory_unix.cpp
src/FileFormatUtils.cpp
src/Threads.cpp
src/Threads_unix.cpp
src/Mutex.cpp
src/Mutex_unix.cpp
src/ConnectedComponents.cpp
src/Line.cpp src/Plugin.cpp
src/Plugin_unix.cpp
src/CvTestbed.cpp
src/DirectoryIterator.cpp
src/DirectoryIterator_unix.cpp
src/Draw.cpp
src/Util.cpp
src/FileFormatUtils.cpp
src/Filter.cpp
src/Kalman.cpp
src/kinect_filtering.cpp
src/Optimization.cpp
src/Line.cpp
src/Marker.cpp
src/MarkerDetector.cpp
src/MultiMarker.cpp
src/MultiMarkerBundle.cpp
src/MultiMarkerInitializer.cpp)
target_link_libraries(ar_track_alvar ${OpenCV_LIBS} ${TinyXML_LIBRARIES} ${catkin_LIBRARIES})
add_dependencies(ar_track_alvar ${GENCPP_DEPS})

# Kinect filtering code
set(KINECT_FILTERING_TARGETS kinect_filtering medianFilter)
src/MultiMarkerInitializer.cpp
src/Mutex.cpp
src/Mutex_unix.cpp
src/Optimization.cpp
src/Plugin.cpp
src/Plugin_unix.cpp
src/Pose.cpp
src/Rotation.cpp
src/Threads.cpp
src/Threads_unix.cpp
src/Util.cpp
)

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES} tinyxml)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it compilable, I added find_package(PCL REQUIRED) on top, and alse appended ${PCL_LIBRARIES} here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thanks!

ament_target_dependencies(ar_track_alvar ${dependencies})

add_library(kinect_filtering src/kinect_filtering.cpp)
target_link_libraries(kinect_filtering ${catkin_LIBRARIES})
add_dependencies(kinect_filtering ${GENCPP_DEPS})
ament_target_dependencies(kinect_filtering ${dependencies})

add_library(medianFilter src/medianFilter.cpp)
target_link_libraries(medianFilter ar_track_alvar ${catkin_LIBRARIES})
add_dependencies(medianFilter ${GENCPP_DEPS})

set(ALVAR_TARGETS ar_track_alvar individualMarkers individualMarkersNoKinect trainMarkerBundle findMarkerBundles findMarkerBundlesNoKinect createMarker ar_track_alvar)
add_library(medianFilter src/medianFilter.cpp)
target_link_libraries(medianFilter ar_track_alvar ${TinyXML_LIBRARIES})
ament_target_dependencies(medianFilter ${dependencies})

add_executable(individualMarkers nodes/IndividualMarkers.cpp)
target_link_libraries(individualMarkers ar_track_alvar kinect_filtering ${catkin_LIBRARIES})
add_dependencies(individualMarkers ${PROJECT_NAME}_gencpp ${GENCPP_DEPS} ${PROJECT_NAME}_gencfg)
target_link_libraries(individualMarkers ar_track_alvar kinect_filtering ${TinyXML_LIBRARIES})
ament_target_dependencies(individualMarkers ${dependencies})

add_executable(individualMarkersNoKinect nodes/IndividualMarkersNoKinect.cpp)
target_link_libraries(individualMarkersNoKinect ar_track_alvar ${catkin_LIBRARIES})
add_dependencies(individualMarkersNoKinect ${PROJECT_NAME}_gencpp ${GENCPP_DEPS} ${PROJECT_NAME}_gencfg)
target_link_libraries(individualMarkersNoKinect ar_track_alvar)
ament_target_dependencies(individualMarkersNoKinect ${dependencies})

add_executable(trainMarkerBundle nodes/TrainMarkerBundle.cpp)
target_link_libraries(trainMarkerBundle ar_track_alvar ${catkin_LIBRARIES})
add_dependencies(trainMarkerBundle ${PROJECT_NAME}_gencpp ${GENCPP_DEPS})
target_link_libraries(trainMarkerBundle ar_track_alvar ${TinyXML_LIBRARIES})
ament_target_dependencies(trainMarkerBundle ${dependencies})


add_executable(findMarkerBundles nodes/FindMarkerBundles.cpp)
target_link_libraries(findMarkerBundles ar_track_alvar kinect_filtering medianFilter ${catkin_LIBRARIES})
add_dependencies(findMarkerBundles ${PROJECT_NAME}_gencpp ${GENCPP_DEPS})
target_link_libraries(findMarkerBundles ar_track_alvar kinect_filtering medianFilter ${TinyXML_LIBRARIES})
ament_target_dependencies(findMarkerBundles ${dependencies})

add_executable(findMarkerBundlesNoKinect nodes/FindMarkerBundlesNoKinect.cpp)
target_link_libraries(findMarkerBundlesNoKinect ar_track_alvar ${catkin_LIBRARIES})
add_dependencies(findMarkerBundlesNoKinect ${PROJECT_NAME}_gencpp ${GENCPP_DEPS})
target_link_libraries(findMarkerBundlesNoKinect ar_track_alvar ${TinyXML_LIBRARIES})
ament_target_dependencies(findMarkerBundlesNoKinect ${dependencies})

add_executable(createMarker src/SampleMarkerCreator.cpp)
target_link_libraries(createMarker ar_track_alvar ${catkin_LIBRARIES})
add_dependencies(createMarker ${PROJECT_NAME}_gencpp ${GENCPP_DEPS})
target_link_libraries(createMarker ar_track_alvar ${TinyXML_LIBRARIES})
ament_target_dependencies(createMarker ${dependencies})


ament_export_include_directories(include)
ament_export_libraries(ar_track_alvar)
ament_export_dependencies(OpenCV ar_track_alvar_msgs std_msgs rclcpp tf2_ros tf2 message_runtime image_transport sensor_msgs geometry_msgs visualization_msgs resource_retriever cv_bridge perception_pcl pcl_conversions)


install(TARGETS ${ALVAR_TARGETS} ${KINECT_FILTERING_TARGETS}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
)

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

install(DIRECTORY launch bundles
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/
DESTINATION share/${PROJECT_NAME}
)

if (CATKIN_ENABLE_TESTING)
find_package(catkin REQUIRED COMPONENTS roslaunch rostest)


if(BUILD_TESTING)

file(GLOB LAUNCH_FILES launch/*.launch test/*.test)
foreach(LAUNCH_FILE ${LAUNCH_FILES})
roslaunch_add_file_check(${LAUNCH_FILE} USE_TEST_DEPENDENCIES)
endforeach()
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()

catkin_download_test_data(
${PROJECT_NAME}_4markers_tork.bag
http://download.ros.org/data/ar_track_alvar/ar_track_alvar_4markers_tork_2017-02-08-11-21-14.bag
# Workaround the issue http://answers.ros.org/question/253787/accessing-data-downloaded-via-catkin_download_test_data/
# by downloading into source folder.
#DESTINATION ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/test
DESTINATION ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/test
MD5 627aa0316bbfe4334e06023d7c2b4087
)
add_rostest(test/marker_arg_config-basic.test DEPENDENCIES ${PROJECT_NAME}_4markers_tork.bag)
add_rostest(test/marker_arg_config-full.test DEPENDENCIES ${PROJECT_NAME}_4markers_tork.bag)
add_rostest(test/marker_param_config-basic.test DEPENDENCIES ${PROJECT_NAME}_4markers_tork.bag)
add_rostest(test/marker_param_config-full.test DEPENDENCIES ${PROJECT_NAME}_4markers_tork.bag)
set(_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}")
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}")
endif()

# Test bag playing (if this fails all other tests will fail)
add_launch_test("test/test_ar_track_alvar_bag.py"
PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
)

# Test Individual Markers in launch test
add_launch_test("test/test_ar_track_alvar_individual_markers.py"
PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
)

# Legacy Tests
add_launch_test("test/test_ar_legacy.py"
PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
)

# Test Launch Files
add_launch_test("test/test_launch_files.py"
PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
)
kscottz marked this conversation as resolved.
Show resolved Hide resolved

endif()

ament_package()
Loading