0、本机基础环境:
CUDA:11.4 Jetpack:5.1.2 L4T:35.4.1 Ubuntu:20.04 focal camera:zedm
因此,在官网下载安装包:ZED SDK 4.2 - Download | Stereolabs
选择对应的版本,同时SDK 版本与zed-ros2版本有对应关系,这点需要注意一下。
本文下载的是ZED_SDK_Tegra_L4T35.4_v4.1.2.zstd.run; 即SDK4.1.2版本
需要注意的:根据安装的SDK版本来选择对应的zed-ros2版本。
1、ZED SDK安装
参考官方安装步骤:How to Install ZED SDK on NVIDIA® Jetson - Stereolabs
按照提示安装即可;
chmod +x ZED_SDK_Tegra_L4T35.4_v4.1.2.zstd.run
./ZED_SDK_Tegra_L4T35.4_v4.1.2.zstd.run
2、 ZED SDK卸载
步骤也很简单,主要是找到安装位置;
cd /usr/local
sudo rm -rf zed
3、zed-ros2 安装
参考官方指导:Getting Started with ROS 2 and ZED - Stereolabs
官方代码仓库地址:https://github.com/stereolabs/zed-ros2-wrapper/tree/humble-v4.1.4?tab=readme-ov-file
然后按照官方步骤就可以安装
mkdir -p ~/ros2_ws/src/ # create your workspace if it does not exist
cd ~/ros2_ws/src/ #use your current ros2 workspace folder
git clone --recursive https://github.com/stereolabs/zed-ros2-wrapper.git
cd ..
sudo apt update
rosdep update
rosdep install --from-paths src --ignore-src -r -y # install dependencies
colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release --parallel-workers $(nproc) # build the workspace
echo source $(pwd)/install/local_setup.bash >> ~/.bashrc # automatically source the installation in every new bash (optional)
source ~/.bashrc
其中的rosdep update 出现错误,rosdep update一直显示超时; 网上有不同的解决办法,但是本文采用了 @鱼香ROS 的方法(感谢小鱼)
sudo pip install rosdepc
sudo pip3 install rosdepc
安装好rosdepc后,然后运行下面代码:
sudo rosdepc init
rosdepc update
同理,在本文用到的rosdep 指令统统改为rosdepc
这样的话就可以顺利完成安装,如果安装过程中出现报错,基本是没有安装对应的包,然后从网上找一下安装步骤即可;由于安装时间有一段时间,记不清楚了哪些问题。可以参考这些github上的问题:
https://github.com/stereolabs/zed-ros2-wrapper/issues/272
https://github.com/stereolabs/zed-ros2-wrapper/issues?page=2&q=is%3Aissue+is%3Aclosed
这样的话就安装成功啦,连上相机,运行一下指令:
ros2 launch zed_wrapper zed_camera.launch.py camera_model:=zedm
这里有个小插曲,我的jetson安装了conda,base环境的python是3.9版本,导致运行不成功。我切换到另一个环境,python是3.8版本,然后就可以了。我也很奇怪,后面解决了再贴上。
python3.9运行错误:
(base) nvidia@nvidia-desktop-o:~$ ros2 launch zed_wrapper zed_camera.launch.py camera_model:=zedm
[INFO] [launch]: All log files can be found below /home/nvidia/.ros/log/2024-11-27-10-10-49-012063-nvidia-desktop-o-19829
[INFO] [launch]: Default logging verbosity is set to INFO
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:226> exception=SubstitutionFailure('executed command failed. Command: xacro /home/nvidia/ros2_ws/install/zed_wrapper/share/zed_wrapper/urdf/zed_descr.urdf.xacro camera_name:=zed camera_model:=zedm custom_baseline:=0.0')>
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 228, in _process_one_event
await self.__process_event(next_event)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 248, in __process_event
visit_all_entities_and_collect_futures(entity, self.__context))
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
[Previous line repeated 2 more times]
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
sub_entities = entity.visit(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/action.py", line 108, in visit
return self.execute(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/actions/node.py", line 444, in execute
self._perform_substitutions(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/actions/node.py", line 399, in _perform_substitutions
evaluated_parameters = evaluate_parameters(context, self.__parameters)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/utilities/evaluate_parameters.py", line 164, in evaluate_parameters
output_params.append(evaluate_parameter_dict(context, param))
File "/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/utilities/evaluate_parameters.py", line 71, in evaluate_parameter_dict
evaluated_value = perform_substitutions(context, list(value))
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in perform_substitutions
return ''.join([context.perform_substitution(sub) for sub in subs])
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in <listcomp>
return ''.join([context.perform_substitution(sub) for sub in subs])
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_context.py", line 232, in perform_substitution
return substitution.perform(self)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/substitutions/command.py", line 116, in perform
raise SubstitutionFailure(f'executed command failed. Command: {command_str}')
launch.substitutions.substitution_failure.SubstitutionFailure: executed command failed. Command: xacro /home/nvidia/ros2_ws/install/zed_wrapper/share/zed_wrapper/urdf/zed_descr.urdf.xacro camera_name:=zed camera_model:=zedm custom_baseline:=0.0
python3.8环境:然后这样就可以啦。
(base) nvidia@nvidia-desktop-o:~$ conda activate yolox
(yolox) nvidia@nvidia-desktop-o:~$ ros2 launch zed_wrapper zed_camera.launch.py camera_model:=zedm
[INFO] [launch]: All log files can be found below /home/nvidia/.ros/log/2024-11-27-10-11-56-866813-nvidia-desktop-o-19844
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [robot_state_publisher-1]: process started with pid [19847]
[INFO] [zed_wrapper-2]: process started with pid [19849]
[robot_state_publisher-1] Parsing robot urdf xml string.
[robot_state_publisher-1] Link zed_camera_center had 2 children
[robot_state_publisher-1] Link zed_left_camera_frame had 1 children
[robot_state_publisher-1] Link zed_left_camera_optical_frame had 0 children
[robot_state_publisher-1] Link zed_right_camera_frame had 1 children
[robot_state_publisher-1] Link zed_right_camera_optical_frame had 0 children
[robot_state_publisher-1] [INFO] [1732673517.173597079] [zed.zed_state_publisher]: got segment zed_camera_center
[robot_state_publisher-1] [INFO] [1732673517.173732568] [zed.zed_state_publisher]: got segment zed_camera_link
[robot_state_publisher-1] [INFO] [1732673517.173747608] [zed.zed_state_publisher]: got segment zed_left_camera_frame
[robot_state_publisher-1] [INFO] [1732673517.173756728] [zed.zed_state_publisher]: got segment zed_left_camera_optical_frame
[robot_state_publisher-1] [INFO] [1732673517.173763736] [zed.zed_state_publisher]: got segment zed_right_camera_frame
[robot_state_publisher-1] [INFO] [1732673517.173769752] [zed.zed_state_publisher]: got segment zed_right_camera_optical_frame
[zed_wrapper-2] [INFO] [1732673517.242533520] [zed.zed_node]: ********************************