Skip to content

Commit 305176c

Browse files
committed
Merge branch 'master' of github.com:stereolabs/zed-ros2-examples
2 parents 5b7acdf + 10e8e44 commit 305176c

File tree

100 files changed

+32727
-1097
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+32727
-1097
lines changed

README.md

+29-17
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,62 @@
1-
![](./images/Picto+STEREOLABS_Black.jpg)
1+
<h1 align="center">
2+
<img src="./images/Picto+STEREOLABS_Black.jpg" alt="Stereolabs" title="Stereolabs" /><br \>
3+
ROS 2 Tutorials and Examples
4+
</h1>
25

3-
# Stereolabs ZED Camera - ROS2 Tutorials and Examples
4-
5-
This package is a collection of examples and tutorials to illustrate how to better use the ZED cameras in the ROS2 framework
6+
This package is a collection of examples and tutorials to illustrate how to better use the ZED cameras in the ROS 2 framework
67

78
[More information](https://www.stereolabs.com/docs/ros2/)
89

910
## Getting started
1011

11-
- First, be sure to have installed the main ROS2 package to integrate the ZED cameras in the ROS2 framework: [zed-ros2-wrapper](https://github.com/stereolabs/zed-ros2-wrapper/)
12+
- First, be sure to have installed the main ROS 2 package to integrate the ZED cameras in the ROS 2 framework: [zed-ros2-wrapper](https://github.com/stereolabs/zed-ros2-wrapper/)
1213
- [Install](#build-the-package) the Tutorials package
1314
- Read the online documentation for [More information](https://www.stereolabs.com/documentation/guides/using-zed-with-ros/introduction.html)
1415

1516
### Prerequisites
1617

17-
- Ubuntu 20.04
18-
- [ZED SDK](https://www.stereolabs.com/developers/release/latest/) v3.6 or later
19-
- [ROS2 ROS 2 Foxy Fitzroy](https://docs.ros.org/en/foxy/Installation/Linux-Install-Debians.html)
18+
- ROS 2 Foxy Fitzroy or ROS 2 Humble Hawksbill:
19+
- [Foxy on Ubuntu 20.04](https://docs.ros.org/en/foxy/Installation/Linux-Install-Debians.html)
20+
- [Humble on Ubuntu 22.04](https://docs.ros.org/en/humble/Installation/Linux-Install-Debians.html)
2021

2122
### Build the package
2223

2324
The `zed-ros-examples` repository is a collection of [colcon](http://design.ros2.org/articles/build_tool.html) packages.
2425

2526
Open a terminal, clone the repository, update the dependencies and build the packages:
2627

27-
$ cd ~/ros2_ws/src/ #use your current ros2 workspace folder
28-
$ git clone https://github.com/stereolabs/zed-ros2-examples.git
29-
$ cd ../
30-
$ rosdep install --from-paths src --ignore-src -r -y
31-
$ colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release
32-
$ source ~/.bashrc
28+
```bash
29+
cd ~/ros2_ws/src/ #use your current ros2 workspace folder
30+
git clone https://github.com/stereolabs/zed-ros2-examples.git
31+
cd ../
32+
sudo apt update
33+
rosdep update
34+
rosdep install --from-paths src --ignore-src -r -y
35+
colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release
36+
source ~/.bashrc
37+
```
3338

34-
## Run the tutorials and examples
39+
## Tutorials and examples
3540

3641
### Rviz visualization examples
3742

3843
- Example launch files to start a preconfigured instance of Rviz displaying all the ZED Wrapper node information: [zed_display_rviz2](https://github.com/stereolabs/zed-ros2-examples/tree/master/zed_display_rviz2)
39-
- ROS2 plugin for ZED2 to visualize the results of the Object Detection module (bounding boxes and skeletons): [rviz-plugin-zed-od](https://github.com/stereolabs/zed-ros2-examples/tree/master/rviz-plugin-zed-od)
44+
- ROS 2 plugin for ZED2 to visualize the results of the Object Detection module (bounding boxes and skeletons): [rviz-plugin-zed-od](https://github.com/stereolabs/zed-ros2-examples/tree/master/rviz-plugin-zed-od)
4045

4146
### Tutorials
4247

4348
- [Images subscription tutorial](https://github.com/stereolabs/zed-ros2-examples/tree/master/tutorials/zed_video_tutorial)
4449
- [Depth subscription tutorial](https://github.com/stereolabs/zed-ros2-examples/tree/master/tutorials/zed_depth_tutorial)
4550
- [Pose/Odometry subscription tutorial](https://github.com/stereolabs/zed-ros2-examples/tree/master/tutorials/zed_pose_tutorial)
46-
- [ROS2 Composition + BGRA2BGR conversion tutorial](https://github.com/stereolabs/zed-ros2-examples/tree/master/tutorials/zed_rgb_convert)
51+
- [ROS 2 Composition + BGRA2BGR conversion tutorial](https://github.com/stereolabs/zed-ros2-examples/tree/master/tutorials/zed_rgb_convert)
4752
- [Multi-camera](https://github.com/stereolabs/zed-ros2-examples/tree/master/tutorials/zed_multi_camera)
53+
- [Robot integration](https://github.com/stereolabs/zed-ros2-examples/tree/master/tutorials/zed_robot_integration)
54+
55+
### Examples
56+
57+
* [ZED Localization with ArUco markers](./examples/zed_aruco_localization): use localized ArUco tags as a reference for localization.
58+
* [Convert ZED Depth map to virtual laser scan](./examples/zed_depth_to_laserscan): convert ZED Depth maps into virtual Laser Scans using
59+
* [ROS 2 Composition](https://docs.ros.org/en/humble/Concepts/Intermediate/About-Composition.html): use ROS 2 composition to convert BGRA images to BGR
4860

4961
## Tools
5062

examples/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Examples
2-
How to use the ZED ROS2 node with other ROS packages.
2+
How to use the ZED ROS2 node with other ROS packages or other nodes.
3+
4+
* [zed_aruco_localization](./zed_aruco_localization): use localized ArUco tag as a reference for localization.
5+
* [zed_depth_to_laserscan](./zed_depth_to_laserscan): convert ZED Depth maps into virtual Laser Scans using
6+
* [ROS 2 Composition](https://docs.ros.org/en/humble/Concepts/Intermediate/About-Composition.html): use ROS 2 composition to convert BGRA images to BGR
37

48

59

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# C++ objects and libs
2+
3+
*.slo
4+
*.lo
5+
*.o
6+
*.a
7+
*.la
8+
*.lai
9+
*.so
10+
*.dll
11+
*.dylib
12+
13+
# Qt-es
14+
15+
/.qmake.cache
16+
/.qmake.stash
17+
*.pro.user
18+
*.pro.user.*
19+
*.qbs.user
20+
*.qbs.user.*
21+
*.moc
22+
moc_*.cpp
23+
moc_*.h
24+
qrc_*.cpp
25+
ui_*.h
26+
Makefile*
27+
*build-*
28+
29+
# QtCreator
30+
31+
*.autosave
32+
33+
# QtCtreator Qml
34+
*.qmlproject.user
35+
*.qmlproject.user.*
36+
37+
# QtCtreator CMake
38+
CMakeLists.txt.user*
39+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(zed_aruco_localization)
3+
4+
## Generate symbols for IDE indexer
5+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6+
7+
################################################
8+
# Check the ROS2 version
9+
10+
set(ROS2_FOUND FALSE)
11+
if(DEFINED ENV{ROS_DISTRO})
12+
set(FOUND_ROS2_DISTRO $ENV{ROS_DISTRO})
13+
set(ROS2_FOUND TRUE)
14+
#message("* Found ROS2 ${FOUND_ROS2_DISTRO}")
15+
else()
16+
message("* ROS2 distro variable not set. Trying to figure it out...")
17+
set(ROS2_DISTROS "ardent;crystal;dashing;eloquent;foxy;galactic;humble;rolling")
18+
set(ROS2_FOUND FALSE)
19+
foreach(distro ${ROS2_DISTROS})
20+
if(NOT ROS2_FOUND)
21+
find_path(RCLCPP_H rclcpp.hpp PATHS /opt/ros/${distro}/include/rclcpp)
22+
if(RCLCPP_H)
23+
message("* Found ROS2 ${distro}")
24+
set(FOUND_ROS2_DISTRO ${distro})
25+
set(ROS2_FOUND TRUE)
26+
endif()
27+
endif()
28+
endforeach()
29+
endif()
30+
31+
if(ROS2_FOUND)
32+
if(${FOUND_ROS2_DISTRO} STREQUAL "humble")
33+
#message("* ROS2 ${FOUND_ROS2_DISTRO} is officially supported by this package.")
34+
add_definitions(-DFOUND_HUMBLE)
35+
elseif(${FOUND_ROS2_DISTRO} STREQUAL "iron")
36+
#message("* ROS2 ${FOUND_ROS2_DISTRO} is officially supported by this package.")
37+
add_definitions(-DFOUND_IRON)
38+
else()
39+
message("*** WARNING *** ROS2 ${FOUND_ROS2_DISTRO} is not officially supported by the package '${PROJECT_NAME}'. Correct operation is not guaranteed.")
40+
endif()
41+
else()
42+
message("*** WARNING *** ROS2 distro is unknown. This package could not work correctly.")
43+
endif()
44+
################################################
45+
46+
# Default to C99
47+
if(NOT CMAKE_C_STANDARD)
48+
set(CMAKE_C_STANDARD 99)
49+
endif()
50+
51+
# Default to C++14
52+
if(NOT CMAKE_CXX_STANDARD)
53+
set(CMAKE_CXX_STANDARD 14)
54+
endif()
55+
56+
#if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
57+
# add_compile_options(-Wall -Wextra -Wpedantic)
58+
#endif()
59+
60+
# if CMAKE_BUILD_TYPE is not specified, take 'Release' as default
61+
if(NOT CMAKE_BUILD_TYPE)
62+
set(CMAKE_BUILD_TYPE Release)
63+
endif()
64+
65+
if(CMAKE_BUILD_TYPE MATCHES Release)
66+
#message(" * Release Mode")
67+
add_compile_options(-Wno-deprecated-declarations)
68+
endif()
69+
70+
if(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
71+
#message(" * Release with Debug Info Mode")
72+
add_compile_options(-Wno-deprecated-declarations)
73+
endif()
74+
75+
if(CMAKE_BUILD_TYPE MATCHES Debug)
76+
message(" * Debug Mode")
77+
endif()
78+
79+
#############################################
80+
# Dependencies
81+
82+
find_package(OpenCV 4 REQUIRED)
83+
find_package(ZED 4 REQUIRED)
84+
find_package(CUDA REQUIRED)
85+
86+
set(DEPENDENCIES_COMP
87+
rclcpp
88+
rclcpp_components
89+
builtin_interfaces
90+
sensor_msgs
91+
image_transport
92+
zed_interfaces
93+
tf2
94+
tf2_ros
95+
tf2_geometry_msgs
96+
)
97+
98+
find_package(ament_cmake_auto REQUIRED)
99+
ament_auto_find_build_dependencies()
100+
101+
find_package(rcutils REQUIRED)
102+
find_package(rclcpp REQUIRED)
103+
find_package(rclcpp_components REQUIRED)
104+
find_package(builtin_interfaces REQUIRED)
105+
find_package(sensor_msgs REQUIRED)
106+
find_package(image_transport REQUIRED)
107+
find_package(tf2 REQUIRED)
108+
find_package(tf2_ros REQUIRED)
109+
find_package(tf2_geometry_msgs REQUIRED)
110+
find_package(zed_components)
111+
112+
if(BUILD_TESTING)
113+
find_package(ament_lint_auto REQUIRED)
114+
ament_lint_auto_find_test_dependencies()
115+
endif()
116+
117+
###############################################################################
118+
#Add all files in subdirectories of the project in
119+
# a dummy_target so qtcreator have access to all files
120+
file(GLOB_RECURSE all_files ${CMAKE_SOURCE_DIR}/*)
121+
add_custom_target(all_${PROJECT_NAME}_files SOURCES ${all_files})
122+
123+
# create ament index resource which references the libraries in the binary dir
124+
set(node_plugins "")
125+
126+
if( ${FOUND_ROS2_DISTRO} STREQUAL "humble" OR ${FOUND_ROS2_DISTRO} STREQUAL "iron")
127+
###############################################################################
128+
# SOURCES
129+
130+
set(INC
131+
${CMAKE_CURRENT_SOURCE_DIR}/src/include/aruco_loc_visibility_control.hpp
132+
)
133+
134+
set(INC_COMP
135+
${CMAKE_CURRENT_SOURCE_DIR}/src/component/include/zed_aruco_localization_component.hpp
136+
${CMAKE_CURRENT_SOURCE_DIR}/src/component/include/aruco.hpp
137+
)
138+
139+
set(SRC_COMP
140+
${CMAKE_CURRENT_SOURCE_DIR}/src/component/src/zed_aruco_localization_component.cpp
141+
${CMAKE_CURRENT_SOURCE_DIR}/src/component/src/aruco.cpp
142+
)
143+
144+
###############################################################################
145+
# Bin and Install
146+
147+
# Component
148+
add_library(${PROJECT_NAME}_component SHARED
149+
${INC}
150+
${INC_COMP}
151+
${SRC_COMP}
152+
)
153+
target_compile_definitions(${PROJECT_NAME}_component
154+
PRIVATE "COMPOSITION_BUILDING_DLL"
155+
)
156+
target_include_directories(${PROJECT_NAME}_component
157+
PUBLIC
158+
${CMAKE_CURRENT_SOURCE_DIR}/src/include
159+
${CMAKE_CURRENT_SOURCE_DIR}/src/component/include
160+
${OpenCV_INCLUDE_DIRS}
161+
)
162+
target_link_libraries(${PROJECT_NAME}_component
163+
${OpenCV_LIBS}
164+
)
165+
ament_target_dependencies(${PROJECT_NAME}_component
166+
${DEPENDENCIES_COMP}
167+
)
168+
169+
rclcpp_components_register_nodes(${PROJECT_NAME}_component "stereolabs::ZedArucoLoc")
170+
set(node_plugins "${node_plugins}stereolabs::ZedArucoLoc;$<TARGET_FILE:${PROJECT_NAME}_component>\n")
171+
172+
# Install components
173+
install(TARGETS ${PROJECT_NAME}_component
174+
ARCHIVE DESTINATION lib
175+
LIBRARY DESTINATION lib
176+
RUNTIME DESTINATION lib/${PROJECT_NAME}
177+
)
178+
179+
# Install header files
180+
install(
181+
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/include/
182+
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/component/include/
183+
DESTINATION include/${PROJECT_NAME}/
184+
)
185+
186+
# Install LAUNCH files
187+
install(DIRECTORY
188+
launch config rviz2
189+
DESTINATION share/${PROJECT_NAME}
190+
)
191+
192+
ament_export_include_directories(include)
193+
ament_export_libraries(${PROJECT_NAME}_component)
194+
ament_export_dependencies(${DEPENDENCIES_COMP})
195+
endif()
196+
197+
198+
ament_package()

0 commit comments

Comments
 (0)