Implementing the code from a tutorial made by Aleksander Haber
source: Interface and Use Camera in ROS2 (Iron Irwini) and OpenCV - Write Publisher and Subscriber Nodes
git clone https://github.com/royyandzakiy/ws_ros2_opencv
clone repository
- this will act as a node to capture image from the chosen camera or video device
- the captured image then be converted to ROS
imgmsg
type- it then gets published to the topic
camera_image_topic
cd ws_ros2_opencv
source /opt/ros/iron/setup.bash
setup underlay environment of ros2 iron irwinisource install/setup.bash
setup overlay environment unique to the project ws_ros2_opencvcolcon build
ros2 run ros2_opencv image_publisher_node
run nodeexplanation:
ros2_opencv
is the package name registered inpackage.xml
.image_publisher_node
is a node defined insrc/ros2_opencv/setup.py
, which is then registered using the commandcolcon build
- this will act as a node to receive sent images from the
image_publisher_node
- it recieves images by subcribing to the topic
camera_image_topic
- open a new terminal
cd ws_ros2_opencv
source /opt/ros/iron/setup.bash
source install/setup.bash
ros2 run ros2_opencv image_subscriber_node
run nodeexplanation:
image_subscriber_node
is a node defined insrc/ros2_opencv/setup.py