Skip to main content

Build and Run


Build From Source

Clone vizionsdk_ros2 into a ROS 2 workspace:

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
git clone https://github.com/TechNexion-Vision/vizionsdk-ros2.git vizionsdk_ros2
cd ~/ros2_ws

Install ROS dependencies and build the package:

source /opt/ros/<distro>/setup.bash
rosdep update
rosdep install --from-paths src --ignore-src -r -y
colcon build --symlink-install \
--packages-select vizionsdk_ros2 \
--cmake-args -DCMAKE_BUILD_TYPE=Release
source install/local_setup.bash

List Connected Cameras

Use list_devices to show connected VizionSDK cameras and their device indexes:

ros2 run vizionsdk_ros2 list_devices

Show each camera's available image modes:

ros2 run vizionsdk_ros2 list_devices --formats

The camera node uses device_index to select a camera.

Start IMU Publishing

Launch the camera node with the default settings:

ros2 launch vizionsdk_ros2 vizionsdk_camera.launch.py \
publish_imu:=true

By default, the node opens device_index:=0, publishes IMU data on imu/data, and publishes camera status on camera/status.

Start Image Publishing

Start IMU publishing plus image publishing:

ros2 launch vizionsdk_ros2 vizionsdk_camera.launch.py \
device_index:=0 \
publish_imu:=true \
publish_image:=true \
image_format:=MJPG \
image_width:=1920 \
image_height:=1080 \
image_framerate:=30

For MJPG, the node publishes sensor_msgs/msg/CompressedImage on image_raw/compressed.

To publish a raw image format, select one of the raw formats advertised by the camera. Use list_devices --formats to check supported image_format, image_width, image_height, and image_framerate values:

ros2 launch vizionsdk_ros2 vizionsdk_camera.launch.py \
publish_image:=true \
image_format:=BGR \
image_width:=1280 \
image_height:=720 \
image_framerate:=30

Raw image formats publish sensor_msgs/msg/Image on image_raw.

note

UYVY and YUY2 are packed YUV422 formats. If you want to view these streams in RViz or rqt_image_view, run yuv422_to_bgr_node to convert the image topic to bgr8. See YUV422 Viewing.

Connect From Other ROS 2 Nodes

After vizionsdk_camera_node is running, other ROS 2 nodes can subscribe to the standard topics published by the node:

ros2 topic list

For example, inspect the IMU topic:

ros2 topic echo /imu/data

Inspect camera status:

ros2 topic echo /camera/status

Customer applications should subscribe to image_raw, image_raw/compressed, camera_info, imu/data, or camera/status depending on the data they need. Camera controls exposed by this wrapper can be changed with ROS parameters while the node is running.

View With RViz

Use the compressed RViz configuration for MJPG streams:

rviz2 -d install/vizionsdk_ros2/share/vizionsdk_ros2/rviz/vizionsdk_imu_camera_compressed.rviz

Use the uncompressed RViz configuration for raw image streams such as BGR, BGRA, or RGB:

rviz2 -d install/vizionsdk_ros2/share/vizionsdk_ros2/rviz/vizionsdk_imu_camera.rviz

To view an MJPG stream with rqt_image_view, start the viewer and select image_raw/compressed:

rqt_image_view

If RViz or rqt_image_view reports a missing compressed transport plugin, install it and source the ROS 2 environment again:

sudo apt install ros-<distro>-compressed-image-transport
source /opt/ros/<distro>/setup.bash
source install/local_setup.bash

Test the ROS 2 Package

Build and run the package tests:

source /opt/ros/<distro>/setup.bash
colcon build --packages-select vizionsdk_ros2 \
--cmake-args -DCMAKE_BUILD_TYPE=Debug
colcon test --packages-select vizionsdk_ros2
colcon test-result --verbose

Run a release build before publishing:

colcon build --packages-select vizionsdk_ros2 \
--cmake-args -DCMAKE_BUILD_TYPE=Release