ROS 2 node and launch file for the Luxonis OAK-D and OAK-D Lite cameras. Each stream (color, depth, point cloud, raw and rectified stereo, disparity, IMU) is independent and published in its own topic, and only the streams you enable are captured. All the parameters are in one YAML file. It also includes the camera TF frames, an RViz configuration, an optional IMU orientation filter and a printable stand for the OAK-D Lite with exact TFs.
Tested with ROS 2 Jazzy on Ubuntu 24.04 and an OAK-D Lite.
-
Execute the below command to install the required dependencies:
sudo wget -qO- https://docs.luxonis.com/install_dependencies.sh | bashPlease refer to Installation documentation if any issues occur.
-
Clone the repository and add it to your ROS 2 workspace:
git clone https://github.com/jmguerreroh/oak_d_camera.git
-
Install dependencies (this also installs
depthai-ros,depth_image_procandimu_filter_madgwick):rosdep install --from-paths src --ignore-src -r -y
-
Build the workspace (with only ROS 2 Jazzy sourced):
colcon build --symlink-install
To launch the OAK-D camera node with the parameters of the configuration file:
ros2 launch oak_d_camera camera.launch.pyAll the parameters (streams, resolution, FPS, stereo settings, TF frames, stand...) are in config/camera_params.yaml, with a comment for each one. It is the only place with default values: edit it to change the default behaviour. With colcon build --symlink-install the changes apply without rebuilding.
Any parameter can also be overridden for a single run from the command line, which takes priority over the file:
ros2 launch oak_d_camera camera.launch.py color_resolution:=360p use_raw:=trueor use your own copy of the file (it must contain every parameter):
cp $(ros2 pkg prefix oak_d_camera)/share/oak_d_camera/config/camera_params.yaml my_params.yaml
ros2 launch oak_d_camera camera.launch.py params_file:=$PWD/my_params.yamlThe node can also be run directly, but it needs the file: ros2 run oak_d_camera camera_node --ros-args --params-file my_params.yaml (the point cloud is generated by the launch file, not by the node).
Invalid values or combinations stop the launch with a message that says what is wrong (they are never silently corrected).
Every topic is under the namespace parameter (oak in the file as delivered), shown here as /oak/.... Boolean values accept true/True/1.
| Parameter | Topics |
|---|---|
use_color |
/oak/color/image, /oak/color/camera_info |
use_depth |
/oak/stereo/depth (16UC1, millimeters), /oak/stereo/camera_info |
use_pointcloud |
/oak/stereo/points (needs use_color and use_depth) |
use_raw |
/oak/left/image, /oak/right/image (unrectified) |
use_rect |
/oak/left_rect/image, /oak/right_rect/image (rectified) |
use_disparity |
/oak/stereo/disparity (stereo_msgs/DisparityImage), /oak/disparity/camera_info |
use_imu |
/oak/imu (raw accelerometer and gyroscope) |
use_imu_orientation |
/oak/imu/data (the IMU with orientation, needs use_imu) |
/tf, /tf_static and /robot_description are not namespaced.
Images are published with a Reliable QoS, so any standard subscriber works. If you subscribe with a Best Effort profile (e.g. qos_profile_sensor_data) large images (1080p) may lose frames because DDS drops incomplete fragmented messages. Use Reliable or a smaller color_resolution.
- The RViz opened by the launch file shows the color image, the depth image and the point cloud. Edit
rviz/camera.rvizto change it. - Any other image:
ros2 run rqt_image_view rqt_image_view. stereo/disparityis not asensor_msgs/Image, so RViz andrqt_image_viewcannot show it:ros2 run image_view disparity_view --ros-args -r image:=/oak/stereo/disparity.- If you open your own RViz, use the fixed frame
oak_parent_frame(theparent_frameparameter) and the topics with their namespace.
color_resolution:1080p,720p,540por360p. Smaller is faster. At1080pthe point cloud only reaches about 4 Hz; at720por less all streams run at 25-30 Hz.fps: frames per second of all the cameras (1-60).
The depth is aligned to the color camera when use_color is enabled: it has the same frame (<tf_prefix>_rgb_camera_optical_frame), size (color_resolution) and camera_info as color/image, so depth, point cloud and color match pixel by pixel. Without use_color it is aligned to the right camera (640x480, frame <tf_prefix>_right_camera_optical_frame).
lr_check: left-right consistency check.extended_disparity: shorter minimum distance. Cannot be used withsubpixel.subpixel: better accuracy at long range. Cannot be used withextended_disparity.confidence_thresholdandlr_check_threshold(0-255).fix_disparity: only affectsstereo/disparity. Withfalsethe message is the unmodified output ofdepthai_bridge, whose focal length, baseline and disparity scale do not match the calibration of the camera. Withtruethe focal length, baseline and disparity limits come from the calibration of the camera, sodepth = f * t / disparitymatchesstereo/depth.
See the StereoDepth documentation for details.
The IMU of the OAK-D and OAK-D Lite (BMI270) only sends raw accelerometer and gyroscope data, so imu has no orientation and the IMU display of RViz does not rotate. With use_imu_orientation the launch file also starts a Madgwick filter (imu_filter_madgwick) on the computer that publishes imu/data with the orientation. The orientation is relative to gravity: the yaw is not absolute because there is no magnetometer. In RViz, add an Imu display on /oak/imu/data with the fixed frame oak_parent_frame.
Axes. Following REP 145 the IMU is published as the sensor reports it, in <tf_prefix>_imu_frame, and the URDF says how it is mounted in the camera. On the OAK-D Lite the axes of the sensor are x right, y up, z backwards (with the camera flat the accelerometer reads +9.8 on y), not the ROS body axes (x forward, y left, z up). Use the TF oak_base_frame -> oak_imu_frame to move the data to the body axes.
tf_prefix: prefix of the camera frames. The frame names in this document use the prefixoak.parent_frame: frame the camera (or its stand) is placed in, e.g. your robot base or the table.base_frame: base frame of the camera.cam_pos_x,cam_pos_y,cam_pos_z(m),cam_roll,cam_pitch,cam_yaw(rad): pose of the camera (or of the stand ifuse_stand) inparent_frame.camera_model:OAK-DorOAK-D-LITE.use_stand: mount the camera on the printable stand (OAK-D Lite only, see Printable stand).stand_tilt: version of the stand,15(camera tilted 15 degrees down) or0(vertical).
namespace: namespace of all the topics and nodes. Usenamespace:=/(or an empty value in your YAML) to publish in the root.use_rviz: open RViz.respawn: restart the camera node if the camera is lost.
No OAK camera found: check the cable and port, and that the Luxonis udev rules are installed (see Installation).The camera is in use by another process: close the othercamera_nodeor DepthAI program.Connection with the camera lost: the camera was unplugged, crashed or stopped sending frames for 5 s. The node exits with code 2. Launch withrespawn:=trueto restart it automatically.- Dropped frames or low FPS: connect to USB 3 and disable the streams you do not need.
- Nothing appears in RViz: check that the fixed frame is
oak_parent_frameand that each display uses the topic with its namespace (/oak/color/image). Changingcam_pos_*only moves the camera with respect toparent_frame, so it is not visible if the fixed frame is the camera itself. - The build fails with
Unknown CMake command "ament_target_dependencies": the workspace was built with ROS Rolling loaded. This package needs Jazzy: use a terminal with only/opt/ros/jazzysourced and deletebuild/andinstall/before building again.
There are two versions of the stand, to print in PLA (99 x 110 mm base, no supports needed, print it with the base on the bed). The camera is screwed to the back plate through its two VESA holes with 2 x M4x10 screws. The USB-C port and the tripod thread are on the bottom of the camera, so the camera floats about 55 mm above the table to leave room for the plug and the cable.
stand_tilt |
STL | Camera |
|---|---|---|
15 (default) |
meshes/oak_d_lite_stand_tilt15.stl (91 mm high) | tilted 15 degrees towards the table |
0 |
meshes/oak_d_lite_stand_tilt0.stl (86 mm high) | looks horizontally; the plate is behind the origin, so the hole is visible from above |
ros2 launch oak_d_camera camera.launch.py use_stand:=true stand_tilt:=0The camera frames then hang from the stand: oak_parent_frame (parent_frame) -> oak_stand_base -> oak_mount -> oak_base_frame -> oak_rgb_camera_optical_frame, ...
oak_stand_baseis on the table plane (z = 0). x points forward (where the camera looks), y to the left, z up (the vertical).- Its origin is the 3 mm through hole in the center of the base. To find the point of the table that is the origin, look through the hole or mark it with a pencil (with
stand_tilt:=15tilted forward, because the back plate is above it). Two shallow grooves on the top face also show the axes: one pointing forward ends in the letterX, and one along y has the letterYat its +y (left) end. - The pose of the camera in
oak_stand_baseis already in the URDF (from the geometry of the stand and the official Luxonis CAD). - Use
cam_pos_x/y/zandcam_yawto say where the stand is placed inparent_frame(e.g. in your robot's base or in a table frame).
Depth, point cloud and color/image are all in oak_rgb_camera_optical_frame, so a pixel and a point of the table can be converted with the camera intrinsics (color/camera_info) and one TF lookup between oak_stand_base and oak_rgb_camera_optical_frame.
Optional: position cross. meshes/oak_d_lite_stand_locator.stl is a cross (140 x 140 mm, print it flat) that marks the origin of oak_stand_base on the table. Stick it to the table (e.g. with double-sided tape) and put the stand on top: the arms fit into two slots under the base and the central pin into the hole, so the stand is centered and not rotated. The slots have 0.2 mm of clearance per side, adjust them if your printer needs more. With the cross in place the hole is filled by the pin, so take the cross off to mark the point with a pencil.
Accuracy. The camera pose comes from the CAD, not from a measurement of your printed stand: the print tolerance (PLA, about 0.2-0.3 mm) and the exact position of the lens inside the housing (a few mm along the optical axis) are not included. Check it with any object of known position on the table and correct the offsets in urdf/oak_d_lite_stand.urdf.xacro if you need more accuracy.
This project was made by José Miguel Guerrero, Associate Professor at Universidad Rey Juan Carlos.
Copyright © 2024-2026.
This work is licensed under the terms of the MIT license.