[已解决]ubuntu24.04 ros-rolling 相机标定
遇到问题
使用rollig的相机包始终报错
ros2 run camera_calibration cameracalibrator --size 10x6 --square 0.015 image:=/image_raw camera:=/camera
[WARN] [1753873753.720306605] [rcl]: Found remap rule 'image:=/image_raw'. This syntax is deprecated. Use '--ros-args --remap image:=/image_raw' instead.
[WARN] [1753873753.720331938] [rcl]: Found remap rule 'camera:=/camera'. This syntax is deprecated. Use '--ros-args --remap camera:=/camera' instead.
[WARN] [1753873753.723629121] [rcl]: Found remap rule 'image:=/image_raw'. This syntax is deprecated. Use '--ros-args --remap image:=/image_raw' instead.
[WARN] [1753873753.723640382] [rcl]: Found remap rule 'camera:=/camera'. This syntax is deprecated. Use '--ros-args --remap camera:=/camera' instead.
Waiting for service camera/set_camera_info ...
Service camera/set_camera_info not found.
Waiting for service left_camera/set_camera_info ...
Service left_camera/set_camera_info not found.
Waiting for service right_camera/set_camera_info ...
Service right_camera/set_camera_info not found.
Traceback (most recent call last):
File "/opt/ros/rolling/lib/camera_calibration/cameracalibrator", line 33, in <module>
sys.exit(load_entry_point('camera-calibration==7.0.0', 'console_scripts', 'cameracalibrator')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ros/rolling/lib/python3.12/site-packages/camera_calibration/nodes/cameracalibrator.py", line 230, in main
node = OpenCVCalibrationNode(
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ros/rolling/lib/python3.12/site-packages/camera_calibration/camera_calibrator.py", line 274, in __init__
CalibrationNode.__init__(self, *args, **kwargs)
File "/opt/ros/rolling/lib/python3.12/site-packages/camera_calibration/camera_calibrator.py", line 128, in __init__
raise RuntimeError("no camera service available")
RuntimeError: no camera service available
[ros2run]: Process exited with failure 1
解决方式
camera_info 主题与相机信息服务不同 - 该服务是可选的 ROS 2 服务,允许在校准完成时设置新参数。如果您的驱动程序没有 set_camera_info 服务,则可以通过在命令中添加“--no-service-check”来跳过此操作
ros2 run camera_calibration cameracalibrator --size 10x6 --square 0.015 image:=/image_raw camera:=/camera --no-service-check
运行,出现新的报错
zhizhi@zzpc:~$ ros2 run camera_calibration cameracalibrator --size 10x6 --square 0.015 image:=/image_raw camera:=/camera --no-service-check
[WARN] [1753965730.060102168] [rcl]: Found remap rule 'image:=/image_raw'. This syntax is deprecated. Use '--ros-args --remap image:=/image_raw' instead.
[WARN] [1753965730.060116976] [rcl]: Found remap rule 'camera:=/camera'. This syntax is deprecated. Use '--ros-args --remap camera:=/camera' instead.
[WARN] [1753965730.068889503] [rcl]: Found remap rule 'image:=/image_raw'. This syntax is deprecated. Use '--ros-args --remap image:=/image_raw' instead.
[WARN] [1753965730.068904629] [rcl]: Found remap rule 'camera:=/camera'. This syntax is deprecated. Use '--ros-args --remap camera:=/camera' instead.
Traceback (most recent call last):
File "/opt/ros/rolling/lib/camera_calibration/cameracalibrator", line 33, in <module>
sys.exit(load_entry_point('camera-calibration==7.0.0', 'console_scripts', 'cameracalibrator')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ros/rolling/lib/python3.12/site-packages/camera_calibration/nodes/cameracalibrator.py", line 230, in main
node = OpenCVCalibrationNode(
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ros/rolling/lib/python3.12/site-packages/camera_calibration/camera_calibrator.py", line 274, in __init__
CalibrationNode.__init__(self, *args, **kwargs)
File "/opt/ros/rolling/lib/python3.12/site-packages/camera_calibration/camera_calibrator.py", line 138, in __init__
self, sensor_msgs.msg.Image, 'left', qos_profile=self.get_topic_qos("left"))
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ros/rolling/lib/python3.12/site-packages/camera_calibration/camera_calibrator.py", line 261, in get_topic_qos
self.get_logger().warn(
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'RcutilsLogger' object has no attribute 'warn'
[ros2run]: Process exited with failure 1
我们可以看到问题出在这里,
File "/opt/ros/rolling/lib/python3.12/site-packages/camera_calibration/camera_calibrator.py", line 261, in get_topic_qos
self.get_logger().warn(
尝试了一些ros的其他版本,只有rolling会出现这个问题(当前是2025.7.31).
我们把对应的代码注释掉:
sudo gedit /opt/ros/rolling/lib/python3.12/site-packages/camera_calibration/camera_calibrator.py
注释261,262行
topic_name = self.resolve_topic_name(topic_name)
topic_info = self.get_publishers_info_by_topic(topic_name=topic_name)
if len(topic_info):
qos_profile = topic_info[0].qos_profile
qos_profile.history = qos_profile_system_default.history
qos_profile.depth = qos_profile_system_default.depth
return qos_profile
else:
# self.get_logger().warn(
# f"No publishers available for topic {topic_name}. Using system default QoS for subscriber.")
return qos_profile_system_default
保存,再运行
ros2 run camera_calibration cameracalibrator --size 10x6 --square 0.015 image:=/image_raw camera:=/camera --no-service-check
浙公网安备 33010602011771号