Skip to content

Latest commit

 

History

History
99 lines (74 loc) · 2.71 KB

README.md

File metadata and controls

99 lines (74 loc) · 2.71 KB

build codecov License Ubuntu

What Is This?

A ROS2 package that simulates a camera, providing ROS messages from playing a static video or image.

Dependencies

  1. OpenCV
  2. ROS2 Humble Hawksbill

Setup 🔨

Run the command below.

cd $HOME
git clone https://github.com/cardboardcode/virtual_camera.git --branch humble_devel --single-branch --depth 1
cd ~/virtual_camera
source /opt/ros/humble/setup.bash
colcon build

Run 🚀

Run the commands below to run virtual_camera ROS 2 node:

cd ~/virtual_camera
source install/local_setup.bash

Run Options

# For running without image-viewer
./scripts/run.bash
# For running with image-viewer
./scripts/show_image.bash

Create A Static Video/Image

# Jump into a folder called data
cd data
# Move your intended video/image into this folder
# Create a symbolic link to video.
ln -sf <video_file_name> input_data
# Or create a symbolic link to image.
ln -sf <image_file_name> input_data
# You can choose not to do it manually by running the following script:
# Input the number of the input image shown in the script -
./scripts/set_input_data.bash

Control FPS

Run the following command to control the speed of the video

ros2 param set /virtual_camera FPS <an integer>
# Eg. ros2 pararm set /virtual_camera FPS 24

Docker Instructions [Optional] 🐋

This section is for users who do not want to worry about installing all dependencies stated above.

Build the docker image.

docker build --tag vcam_image:humble .

Run the docker image.

# Enable display to be forwarded from container to host.
xhost +local:docker
# Run virtual_camera in docker container, vcam_test_container
docker run -it --rm \
    --net host \
    --name vcam_test_container \
    -e DISPLAY=$DISPLAY \
    -v /dev/shm:/dev/shm \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -u user  \
 vcam_image:humble bash -c \
 "ros2 launch virtual_camera showimageraw.launch.py \
 use_image_viewer:=true"