해당 실습 자료는 한양대학교 Road Balance - ROS 2 for G Camp와 ROS 2 Documentation: Foxy, 표윤석, 임태훈 <ROS 2로 시작하는 로봇 프로그래밍> 루피페이퍼(2022) 를 참고하여 작성하였습니다.
이번 장에서는 SSD를 이용한 detection 프로그램을 구현해봅니다. Detection Inference code 에서는 image_tools 패키지를 이용하여 센서(웹캠)로부터 이미지를 받아 msg를 뿌리는 publisher를 실행한 뒤, 이미지 정보를 받아
torchvision
의SSD
모델을 이용하여 detection을 수행하는 subscriber를 실행합니다.
ros2_ws/src
디렉토리에 이동하신 다음 새로운 패키지를 생성합니다.$ ros2 pkg create ssd_detection --build-type ament_python --dependencies rclpy std_msgs image_tools
새로운 패키지 이름은 ssd_detection
으로 동명의 디렉토리에 패키지 기본 구성이 생성된 것을 확인 할 수 있을 겁니다.
추가로 --dependencies
인수를 통해 패키지 환경 설정 파일 package.xml
에 필요한 종속성 패키지인 rclpy
, std_msgs
가 자동으로 추가됩니다.
sensor_msgs.msg Image헤더 정보
uint32 height
uint32 width
string encoding
uint8 is_bigendian
uint32 step
uint8[] data
gdown <https://drive.google.com/uc?id=**YOUR_FILE_ID**&export=download
>$ cd ros2_ws/src/ssd_detection
$ gdown <https://drive.google.com/uc?id=**1Td1fGqjdw-OcIp0DAKyLXFbrpUlTMLVA**&export=download>