I am writing down all the necessary things related to zed ros2 wrapper -
The [ZED ROS2 wrapper] lets you use the ZED stereo cameras with the second version of ROS. It provides access to the following data:
- Left and right rectified/unrectified images
- Depth data
- Colored 3D point cloud
- IMU data
- Visual odometry: Position and orientation of the camera
- Pose tracking: Position and orientation of the camera fixed and fused with IMU data (ZED-M and ZED2 only)
- Detected objects (ZED2/ZED2i only)
- Persons skeleton (ZED2/ZED2i only)
BUILD THE PACKAGE
The zed_ros2_wrapper is a [colcon] package.
Note: If you haven’t set up your colcon workspace yet, please follow this [tutorial].
To install the zed_ros2_wrapper , open a bash terminal, clone the package from Github, and build it:
$ cd ~/ros2_ws/src/ #use your current ros2 workspace folder
$ git clone https://github.com/stereolabs/zed-ros2-wrapper.git
$ cd ..
$ rosdep install --from-paths src --ignore-src -r -y
$ colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release
$ echo source $(pwd)/install/local_setup.bash >> ~/.bashrc
$ source ~/.bashrc
Note: The option
--symlink-install is very important. It allows to use symlinks instead of copying files to the ROS2 folders during the installation, where possible. Each package in ROS2 must be installed and all the files used by the nodes must be copied into the installation folders. Using symlinks allows you to modify them in your workspace, reflecting the modification during the next executions without the needing to issue a new
colcon build command. This is true only for all the files that don’t need to be compiled (Python launch scripts, YAML configurations, etc).
Note: If you are using a different console interface like zsh, you have to change the
source command as follows:
echo source $(pwd)/install/local_setup.zsh >> ~/.zshrc and
source ~/.zshrc .
Starting the ZED node
To start the ZED node, open a terminal and use the CLI command
ros2 launch :
$ ros2 launch zed_wrapper zed.launch.py
$ ros2 launch zed_wrapper zedm.launch.py
$ ros2 launch zed_wrapper zed2.launch.py
$ ros2 launch zed_wrapper zed2i.launch.py
zed2.launch.py , and
zed2i.launch.py are three Python scripts that automatically start the ZED node using “[manual composition]”, loading the parameters from the correct “YAML files” and creating the camera model from the “URDF file” that is automatically created from a [
xacro ] configuration file. Basically, I am trying to use this compilation for my best HRMS software in Kolkata and related things.
Note : You can set your own configurations modifying the parameters in the files
zed2.yaml , and
zed2i.yaml available in the folder
zed_wrapper/config . For full descriptions of each parameter, follow the [complete guide].
Displaying ZED data
RVIZ2 is a useful visualization tool in ROS2. Using RVIZ2, you can visualize the left and right images acquired by the ZED cameras, the depth image and the 3D colored point cloud.
Launch the ZED wrapper along with RVIZ using the following command (installing the [
zed-ros2-examples package] is required):
$ ros2 launch zed_display_rviz display_zed.launch.py
If you are using a ZED-M camera:
$ roslaunch zed_display_rviz display_zedm.launch.py
If you are using a ZED2 camera:
$ roslaunch zed_display_rviz display_zed2.launch.py
If you are using a ZED2i camera:
$ roslaunch zed_display_rviz display_zed2i.launch.py
Note: If you haven’t yet configured your own RVIZ2 interface, you can find a detailed tutorial [here].
The ZED node publishes both original and stereo rectified (aligned) left and right images. In RVIZ2, select a topic and use the
image preview mode.
Here is a list of the main available image topics (more image topics are available):
rgb/image_rect_color : Color rectified image (left image by default)
rgb/image_raw_color : Color unrectified image (left image by default)
right/image_rect_color : Color rectified right image
right/image_raw_color : Color unrectified right image
left/image_rect_color : Color rectified left image
left/image_raw_color : Color unrectified left image
confidence/confidence_image : Confidence map
The depth map can be displayed in RVIZ subscribing to the following topic:
depth/depth_registered : 32-bit depth values in meters. RVIZ will normalize the depth map on 8-bit and display it as a grayscale depth image.
Note: An OpenNI compatibility mode is available modifying the
config/common.yaml file. Set
true to get depth in millimeters with 16-bit precision, then restart the ZED node.
DISPLAYING THE POINT CLOUD
A 3D colored point cloud can be displayed in RVIZ2 subscribing to the point_cloud/cloud_registered topic.
Add it in RVIZ2 with
PointCloud2 . Note that displaying point clouds slows down RVIZ2, so open a new instance if you want to display other topics.
DISPLAYING POSITION AND PATH
The ZED position and orientation in space over time is published to the following topics:
odom : Odometry pose referred to odometry frame (only visual odometry is applied for ZED, visual-inertial for ZED-M)
pose : Camera pose referred to Map frame (complete data fusion algorithm is applied)
pose_with_covariance : Camera pose referred to Map frame with covariance (if spatial_memory is false in launch parameters)
path_odom : The sequence of camera odometry poses in Map frame
path_map : The sequence of camera poses in Map frame
Launching with a recorded SVO video
With the ZED, you can record and play back stereo video using Stereolabs’ .SVO file format. To record a sequence, open the ZED Explorer app (
/usr/local/zed/tools ) and click on the REC button.
To launch the ROS wrapper with an SVO file, set the relative parameter while starting the node. For example, to start the ZED2 node using the SVO as input source:
$ ros2 launch zed_wrapper zed2.launch.py svo_path:=<full_path_to_svo_file>
$ ros2 launch zed_display_rviz2 display_zed2.launch.py svo_path:=<full_path_to_svo_file>
Important: Use only full paths to the SVO file. Relative paths are not allowed.
You can dynamically change many configuration parameters during the execution of the ZED node. All the parameters that can be dynamically changed while the node is runnin are marked as
[DYNAMIC] in the YAML configuration files. For a full description of each parameter please read the [complete guide].
You can set the parameters using the [CLI] command
ros2 param set , e.g.:
$ ros2 param set /zed2/zed_node depth.depth_confidence 80
if the parameter is successfully set you will get a confirmation message:
Set parameter successful
If you try to set a parameter that’s not dynamically reconfigurable, or if you provided an invalid value, you will get this error:
$ ros2 param set /zed2/zed_node depth.depth_confidence 150
Setting parameter failed: depth.depth_confidence must be a positive integer in the range [0,100]
You can also using a GUI to set dynamic parameters values:
IMAGE TRANSPORT AND TOPIC SUBSCRIPTIONS
There is an issue with the function
CameraPublisher::getNumSubscribers preventing the correct counting of the number of nodes subscribing one of the topics published by an
We suggest to install the the version [v3.0.0], published on 2021-05-26, that contains the fix for this issue.
To install the latest version from sources:
$ cd <colcon_workspace>/src # Access the source folder of your colcon workspace
$ git clone https://github.com/ros-perception/image_common.git -b ros2 # clone the "ros" branch of the "image_common" repository
$ cd <colcon_workspace> # Go back to the root of your colcon workspace
$ colcon build --symlink-install # Compile everything and install
Close the console and re-open it to apply the modifications.
IMAGE TRANSPORT PLUGINS AND COMPRESSED TOPICS
image_transport_plugins package is not correctly working with ROS2 Foxy (see [here]. We suggest you remove it to avoid many annoying warning messages until the ROS2 developers do not fix it or we find a workaround:
$ sudo apt remove ros-foxy-image-transport-plugins ros-foxy-compressed-depth-image-transport ros-foxy-compres
Hope this will help you properly.