https://qlalf-smithy.tistory.com/34
ROS2_usb_cam 설치
https://github.com/ros-drivers/usb_cam GitHub - ros-drivers/usb_cam: A ROS Driver for V4L2 USB CamerasA ROS Driver for V4L2 USB Cameras. Contribute to ros-drivers/usb_cam development by creating an account on GitHub.github.com위 github 참고. version*
qlalf-smithy.tistory.com
해당 과정을 진행중에 발생했던 오류가 있었다.
error_code:
[ERROR] [launch]: Caught exception in launch (see debug for traceback): Caught multiple exceptions when trying to load file of format [py]: - PydanticUserError: If you use @root_validator with pre=False (the default) you MUST specify skip_on_failure=True. Note that @root_validator is deprecated and should be replaced with @model_validator.
찾아보니, Pydantic version 과 /aunch/camera_config.py 코드를 살짝 수정해줘야했다.
먼저 기존 Pydandic version==2.8.2,
이를 1.10.9 version 으로 바꿔줘야했다.
1. Pydantic version 2.8.2 => 1.10.9
pip install pydantic==1.10.9
* version 1.10.9 로 downgrade
2. camera_config.py 코드 수정
# Copyright 2023 usb_cam Authors
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of the usb_cam Authors nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
from pathlib import Path
from typing import List, Optional
from ament_index_python.packages import get_package_share_directory
from pydantic import BaseModel, root_validator, validator
USB_CAM_DIR = get_package_share_directory('usb_cam')
class CameraConfig(BaseModel):
name: str = 'camera1'
param_path: Path = Path(USB_CAM_DIR, 'config', 'params_1.yaml')
remappings: Optional[List]
namespace: Optional[str]
@validator('param_path')
def validate_param_path(cls, value):
if value and not value.exists():
raise FileNotFoundError(f'Could not find parameter file: {value}')
return value
@root_validator(pre=False, skip_on_failure=True)#pre=False, skip_on_failure=True: @root_validator에서 기본 설정인 pre=False와 skip_on_failure=True를 지정하여 검증을 실행.
def validate_root(cls, values):
name = values.get('name')
remappings = values.get('remappings')
if name and not remappings:
# Automatically set remappings if name is set
remappings = [
('image_raw', f'{name}/image_raw'),
('image_raw/compressed', f'{name}/image_compressed'),
('image_raw/compressedDepth', f'{name}/compressedDepth'),
('image_raw/theora', f'{name}/image_raw/theora'),
('camera_info', f'{name}/camera_info'),
]
values['remappings'] = remappings
return values
*version pydantic1 일때 다음과 같이 @root_validator 만 있는 부분 뒤에 pre=False, skip_on_failure=True 를 추가.
'Ubuntu > ROS' 카테고리의 다른 글
Ros2 패키지_생성 (0) | 2024.08.29 |
---|---|
Stereo_Camera_Calibration feat.USB_CAM (0) | 2024.08.17 |
Camera_parameter feat.calibration (0) | 2024.08.11 |
Ros2_usb_cam_오류수정 (0) | 2024.08.11 |
ROS2_usb_cam 설치 (0) | 2024.08.05 |