Hello all, I have made this package to send video footage from a webcam, USB camera, or an ip_address onto a ros2 topic, which you can use for openCV in your ros2 projects. The main reason to create this package was to get video streaming from my phone on to an ip address and use that stream as ros2 topic. After searching for a while i could find 2 repositories which are really good but for ip_address streaming i could not find so i created this package. Its very simple and has 3 nodes.
- Opencv_cam - https://github.com/clydemcqueen/opencv_cam
- usb cam - https://github.com/ros-drivers/usb_cam
Go to your work_space/src folder, and create one if you don't have.
To create a workspace and src folder
$ mkdir ros2_ws/src
$ cd ros2_ws/src
clone the repo in the src folder
$ git clone https://github.com/pratikPhadte/my_camera.git
Go back to the workspace folder (ros2_ws/)
$ cd ..
Once you are in your workspace, we can start building the repo
$ colcon build --packages-select my_camera
IF its showing you an error while building in ROS2 humble and Ubuntu 22.04 version, try building it in sequential mode. if your "my_camera" is built successfully then please skip this step.
$ colcon build --executor sequential --packages-select my_camera
IT's DONE!
Go to your work_space/ folder.
$ cd ros2_ws
Always remember to source your workspace :)
$ source install/local_setup.bash
Run the ROS2 webam_node, this node will publish the webcam feed onto a ros2 topic.
$ ros2 run my_camera webcam_node
If you want to see usb webcam footage or RC/fpv camera receiver footage, use below a node, instead of 0( 0 is a deafult computer webcam number), you can put 1,2,3.. to check your connected usb cam.
$ ros2 run my_camera usbcam_node --cam 0
If you want to see an ip_address feed, use below command, note that you have to add the PORT number at the end :)
$ ros2 run my_camera ip_stream_node --ip 192.168.0.180:8080
In another terminal, check the ros2 topics
$ ros2 topic list
To view your footage, enter below command in another terminal.
$ ros2 run rqt_image_view rqt_image_view