Change RGB resolution when using ROS2 driver
- Best Answerset by jakaskerl
Hi,
resolution itself is separate from width and height parameters, to change it you need to change existing (or provide a new) parameter file, for specific parameters please refer to documentation. Please keep in mind that by default ISP scaling is applied to output, more information on that here
- Edited
I've also tried this parameter file (setting rgb.i_output_isp to False as well), but the raw RGB stream continues to be 1280x720. Do I have something incorrect in this launch file?
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import (
DeclareLaunchArgument,
IncludeLaunchDescription,
OpaqueFunction,
)
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
def launch_setup(context, *args, **kwargs):
params_file = LaunchConfiguration("params_file")
depthai_prefix = get_package_share_directory("depthai_ros_driver")
name = LaunchConfiguration("name").perform(context)
return [
IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(depthai_prefix, "launch", "camera.launch.py")),
launch_arguments={
"name": name,
"params_file": params_file,
"parent_frame": LaunchConfiguration("parent_frame"),
"cam_pos_x": LaunchConfiguration("cam_pos_x"),
"cam_pos_y": LaunchConfiguration("cam_pos_y"),
"cam_pos_z": LaunchConfiguration("cam_pos_z"),
"cam_roll": LaunchConfiguration("cam_roll"),
"cam_pitch": LaunchConfiguration("cam_pitch"),
"cam_yaw": LaunchConfiguration("cam_yaw"),
"use_rviz": LaunchConfiguration("use_rviz"),
"pointcloud.enable": "true",
"rs_compat": LaunchConfiguration("rs_compat"),
}.items(),
),
]
def generate_launch_description():
depthai_prefix = get_package_share_directory("depthai_ros_driver")
declared_arguments = [
DeclareLaunchArgument("name", default_value="oak"),
DeclareLaunchArgument("camera_model", default_value="OAK-D"),
DeclareLaunchArgument("parent_frame", default_value="oak-d-base-frame"),
DeclareLaunchArgument("cam_pos_x", default_value="0.0"),
DeclareLaunchArgument("cam_pos_y", default_value="0.0"),
DeclareLaunchArgument("cam_pos_z", default_value="0.0"),
DeclareLaunchArgument("cam_roll", default_value="0.0"),
DeclareLaunchArgument("cam_pitch", default_value="0.0"),
DeclareLaunchArgument("cam_yaw", default_value="0.0"),
DeclareLaunchArgument(
"params_file",
default_value=os.path.join(depthai_prefix, "config", "rgbd.yaml"),
),
DeclareLaunchArgument("use_rviz", default_value="False"),
DeclareLaunchArgument("rectify_rgb", default_value="False"),
DeclareLaunchArgument("rs_compat", default_value="False"),
DeclareLaunchArgument("rgb.i_height", default_value="3120"),
DeclareLaunchArgument("rgb.i_width", default_value="4208"),
DeclareLaunchArgument("rgb.i_fps", default_value="1"),
DeclareLaunchArgument("rgb.i_output_isp", default_value="False"),
]
return LaunchDescription(declared_arguments + [OpaqueFunction(function=launch_setup)])
Hi,
DeclareLaunchArgument("rgb.i_fps", default_value="1"),
won't set a parameter for a ROS2 node automatically, arguments and parameters are separate things in ROS, you can set a parameter from an argument but that would involve passing it as a dict directly to the Node, not the Launch file you are including. In your case, simplest thing would be to copy/create new YAML file with desired parameters and pass it to the Launch file
- Edited
Sorry this is still not very clear to me. How can I pass a YAML file to a launch file? I created a config based on https://docs.luxonis.com/software/ros/depthai-ros/driver/#DepthAI%20ROS%20Driver-List%20of%20parameters with the RGB resolution changed.
This does not work:
ros2 launch depthai_ros_driver rgbd_pcl.launch.py --ros-args --params-file ros/camera_config.yaml
It seems the launch file itself must be modified to include the parameters? Could you provide an example of this?
Also is there any reason that ros2 launch depthai_ros_driver camera.launch.py rgb.i_width:=3840 rgb.i_height:=2160 rgb.i_fps:=1 rgb.i_output_isp=False
should not work as well?
I also tried updating the parameters after the node was launched:
ros2 launch depthai_ros_driver rgbd_pcl.launch.py
then
ros2 param load oak ros/camera_config.yaml
where that config file had the following:
Still the /oak/stereo/image_raw topic continues to publish a 1280x720 image. Any ideas why? Your help is much appreciated!
Hi, IIRC path to the parameter file should be absolute (full path)
I'm seeing this error, even with a full path:
ros2: error: unrecognized arguments: --ros-args --params-file
From what I understand it is not possible to pass to pass in a parameter file to a launch file. If it is possible could you please send me a minimal working example with a config file and example launch command?
Or please let me know of some alternative to get this to work. This seems to me to be a very basic usecase to change any parameters with the ROS2 node, but nothing seems to be working. All I want to do is launch this as a ROS2 node but change the image resolution.
ros2 launch depthai_ros_driver camera.launch.py params_file:=test.yaml
Passing arguments in this way is recommended in ROS2. It doesnt have to be absolute path.
/oak:
ros__parameters:
# camera:
# i_nn_type: none
rgb:
i_fps: 1.0
# i_resolution: '4K'
i_height: 2160
i_width: 3840
This won't work:
ros2 launch depthai_ros_driver camera.launch.py rgb.i_width:=3840 rgb.i_height:=2160 rgb.i_fps:=1 rgb.i_output_isp=False
as you need /oak prefix so driver can know to which object to apply those parameters to.
Let me know if it works for you and if not let me know what camera/sensor you are using and paste your output.
Thanks! Seeing a new error:
what(): ColorCamera(0) - 'video' width or height (3840, 2160) bigger than maximum at current sensor resolution (1280, 720)
I am using an OAK-D lite with these features:
{socket: CAM_A, sensorName: IMX214, width: 4208, height: 3120, orientation: AUTO, supportedTypes: [COLOR], hasAutofocus: 1, hasAutofocusIC: 1, name: color}
{width: 1920, height: 1080, minFps: 0.735, maxFps: 35, type: COLOR, fov: {x:184, y: 480, width: 3840, height: 2160}}
{width: 3840, height: 2160, minFps: 1.4, maxFps: 34.3, type: COLOR, fov: {x:184, y: 480, width: 3840, height: 2160}}
{width: 4056, height: 3040, minFps: 1.4, maxFps: 29.4, type: COLOR, fov: {x:76, y: 40, width: 4056, height: 3040}}
{width: 4208, height: 3120, minFps: 1.4, maxFps: 28.5, type: COLOR, fov: {x:0, y: 0, width: 4208, height: 3120}}
{socket: CAM_B, sensorName: OV7251, width: 640, height: 480, orientation: AUTO, supportedTypes: [MONO], hasAutofocus: 0, hasAutofocusIC: 0, name: left}
{width: 640, height: 400, minFps: 0.79, maxFps: 117, type: MONO, fov: {x:0, y: 40, width: 640, height: 400}}
{width: 640, height: 480, minFps: 0.79, maxFps: 99, type: MONO, fov: {x:0, y: 0, width: 640, height: 480}}
{socket: CAM_C, sensorName: OV7251, width: 640, height: 480, orientation: AUTO, supportedTypes: [MONO], hasAutofocus: 0, hasAutofocusIC: 0, name: right}
{width: 640, height: 400, minFps: 0.79, maxFps: 117, type: MONO, fov: {x:0, y: 40, width: 640, height: 400}}
{width: 640, height: 480, minFps: 0.79, maxFps: 99, type: MONO, fov: {x:0, y: 0, width: 640, height: 480}}
Hi, the correct param file would be:
/oak:
ros__parameters:
camera:
i_pipeline_type: rgb
i_nn_type: none
rgb:
i_fps: 1.0
i_resolution: '4K'
i_set_isp_scale: false
If you want to use RGBD
pipeline you need to additionally set
stereo.i_width:1280
stereo.i_height:720
Though to get RGBD pointcloud from that you would need to add another ROS node which would upscale stereo/downscale rgb image
Thank you, that is working!!
I have a few followup questions:
How can I add that ROS node for RGBD to upscale the stereo? What node is it? Do I have to build a custom node myself? To confirm this is not already handled in camera.launch.py
which "launches camera in RGBD"?
Second, is there any additional documentation for all of the parameters and their possible values? I noticed that i_laser_dot_brightness
has a default value of 800, while setIrLaserDotProjectorIntensity()
takes in a value from 0 to 1.
Finally, is there a way to set an autoexposure region using the ROS parameters? (and ideally also the autofocus region?)
Thanks for all of the help!
BradSteiner How can I add that ROS node for RGBD to upscale the stereo? What node is it? Do I have to build a custom node myself? To confirm this is not already handled in camera.launch.py which "launches camera in RGBD"?
@Luxonis-Adam on above,
BradSteiner Second, is there any additional documentation for all of the parameters and their possible values? I noticed that i_laser_dot_brightness has a default value of 800, while setIrLaserDotProjectorIntensity() takes in a value from 0 to 1.
For possible parameters, most should be here. They are based on the depthai API, which you can search through on luxonis/depthai-core. Eg. for dot projector brightness/intensity:
luxonis/depthai-coreblob/ff58891a782ef27bb0a442e4fe5c0a46aee5f464/include/depthai/device/DeviceBase.hpp#L510
Thanks,
Jaka
How can I add that ROS node for RGBD to upscale the stereo? What node is it? Do I have to build a custom node myself? To confirm this is not already handled in camera.launch.py which "launches camera in RGBD"?
A separate node would be required here, it should be pretty straightforward (receive image and upscale using OpenCV), though please keep in mind that with upscaling you will introduce some additional noise.
Second, is there any additional documentation for all of the parameters and their possible values? I noticed that i_laser_dot_brightness has a default value of 800, while setIrLaserDotProjectorIntensity() takes in a value from 0 to 1.
The driver is using old version of API where brighness was given in mA. For laser dot projector max value is 1200mA, and for floodlight 1500 mA.
Thanks! Regarding
Finally, is there a way to set an autoexposure region using the ROS parameters? (and ideally also the autofocus region?)
Is there anything for that?
Since this is unrelated to my original question, I made a new one here: https://discuss.luxonis.com/d/5719-how-can-i-set-the-autoexposure-region-when-using-the-ros-node