IntelRealSense / realsense-ros

ROS Wrapper for Intel(R) RealSense(TM) Cameras
http://wiki.ros.org/RealSense
Apache License 2.0
2.51k stars 1.74k forks source link

About how to set the resolution of /aligned_depth_to_color/image_raw in custom launch.py. #3194

Closed Poodlee closed 2 weeks ago

Poodlee commented 2 weeks ago

Required Info
Camera Model { D455 }
Firmware Version (5.13.0.50)
Operating System & Version { Ubuntu 22.04}
Kernel Version (Linux Only) (6.8.0-40-generic)
Platform PC
Librealsense SDK Version { 2.55.1}
Language {C/python }
Segment {Robot }
ROS Distro {Humble}
RealSense ROS Wrapper Version {4.51.1}

Issue Description

<Describe your issue / question / feature request / etc..> Currently, realsense-ros is used within the isaac ros related package. I am writing this post because I encountered a problem with settings related to /aligned_depth_to_color/image_raw resolution during related operations.

In the current situation, a new launch file is created and the realsenseNodeFactory node is configured and executed as follows.

    def get_composable_nodes(interface_specs: Dict[str, Any]) -> Dict[str, ComposableNode]:
        realsense_config_file_path = os.path.join(
            get_package_share_directory('isaac_ros_realsense'),
            'config', 'realsense_mono_depth.yaml'
        )

        return {
            'camera_node': ComposableNode(
                package='realsense2_camera',
                plugin='realsense2_camera::RealSenseNodeFactory',
                name='realsense2_camera',
                namespace='',
                parameters=[
                    realsense_config_file_path
                ],
                remappings=[('color/image_raw', 'image_rect'),
                            ('color/camera_info', 'camera_info_rect')]
            ),

At this time, the realsense_mono_depth.yaml code is structured as follows. Screenshot from 2024-08-29 23-06-02

image(2) I configured it as above and ran launch. After execution, if I check aligned_depth_to_color/image_raw through ros2 topic echo, the resolution result will be 1280x720. I thought I definitely changed it to 640x480x15 in the realsense_mono_depth.yaml file, but it doesn't apply.

I would appreciate it if you could let me know if there is anything I am wrong about or needs to be corrected.

MartyG-RealSense commented 2 weeks ago

Hi @Poodlee 1280x720 is the default resolution of RGB color on the D455 camera model. It is possible that your custom configuration was deemed invalid by the launch and the default stream profile was applied instead.

Please try changing your yaml file to use the color stream definition below.

rgb_camera.color_profile: 640x480x15

Poodlee commented 2 weeks ago

@MartyG-RealSense Thank you for quick reply. As you said, the yaml file was modified as follows: Screenshot from 2024-08-29 23-41-18

Based on what you just said, are you saying that it is impossible to change the resolution of the aligned_depth_to_color/image_raw topic? The desired resolution for the package currently in use is 640x480, so if that is not possible, the package needs to be modified, so I am asking.

MartyG-RealSense commented 2 weeks ago

I would think that the aligned resolution should be the resolution that the individual depth and color topics are published at.

Have you confirmed that depth and color are both being published at 640x480x15? Confirmation should be listed just before the end of the launch log. For example:

[realsense2_camera_node-1] [INFO] [1723364028.686621284] [camera.camera]: Starting Sensor: Depth Module
[realsense2_camera_node-1] [INFO] [1723364028.693726549] [camera.camera]: Open profile: stream_type: Depth(0), Format: Z16, Width: 640, Height: 480, FPS: 15
[realsense2_camera_node-1] [INFO] [1723364028.718951273] [camera.camera]: Starting Sensor: RGB Camera
[realsense2_camera_node-1] [INFO] [1723364028.727177525] [camera.camera]: Open profile: stream_type: Color(0), Format: RGB8, Width: 640, Height: 480, FPS: 15
Poodlee commented 2 weeks ago

Screenshot from 2024-08-30 00-13-59 After editing the .yaml file, I confirmed that the resolution did not change through ros2 topic echo. Screenshot from 2024-08-30 00-18-49

Since no settings have been made regarding log, only the following information is listed.

If there is anything I am lacking regarding this topic, please let me know and I will learn. thank you

MartyG-RealSense commented 2 weeks ago

Ideally, ROS wrapper 4.55.1 should be used with librealsense SDK 2.55.1, as 4.51.1 is designed for use with the old 2.51.1 librealsense version.

Let's try setting the depth and color resolution in the launch instruction instead of yaml to see whether it changes the aligned resolution.

ros2 launch realsense2_camera rs_launch.py depth_module.profile:=640x480x15 rgb_camera.color_profile:=640x480x15

Poodlee commented 2 weeks ago

Screenshot from 2024-08-30 00-34-51

As you said, I ran it through rs_launch.py ​​instead of yaml and confirmed that the depth profile changes. However, I confirmed that the color does not change to 1280x720x30. The related log is as follows.

[realsense2_camera_node-1] [INFO] [1724945843.789340615] [camera.camera]: Device with physical ID 2-8-4 was found.
[realsense2_camera_node-1] [INFO] [1724945843.789351303] [camera.camera]: Device with name Intel RealSense D455 was found.
[realsense2_camera_node-1] [INFO] [1724945843.789576606] [camera.camera]: Device with port number 2-8 was found.
[realsense2_camera_node-1] [INFO] [1724945843.789586902] [camera.camera]: Device USB type: 3.2
[realsense2_camera_node-1] [INFO] [1724945843.790954085] [camera.camera]: getParameters...
[realsense2_camera_node-1] [INFO] [1724945843.791124833] [camera.camera]: JSON file is not provided
[realsense2_camera_node-1] [INFO] [1724945843.791135397] [camera.camera]: Device Name: Intel RealSense D455
[realsense2_camera_node-1] [INFO] [1724945843.791144198] [camera.camera]: Device Serial No: 035122250158
[realsense2_camera_node-1] [INFO] [1724945843.791150989] [camera.camera]: Device physical port: 2-8-4
[realsense2_camera_node-1] [INFO] [1724945843.791159434] [camera.camera]: Device FW version: 5.13.0.50
[realsense2_camera_node-1] [INFO] [1724945843.791166404] [camera.camera]: Device Product ID: 0x0B5C
[realsense2_camera_node-1] [INFO] [1724945843.791172242] [camera.camera]: Sync Mode: Off
[realsense2_camera_node-1] [INFO] [1724945844.311761929] [camera.camera]: Set Exposure.1 to 7500
[realsense2_camera_node-1] [WARN] [1724945844.354739049] [camera.camera]: re-enable the stream for the change to take effect.
[realsense2_camera_node-1] [INFO] [1724945844.464593730] [camera.camera]: Set ROS param rgb_camera.profile to default: 1280x720x30
[realsense2_camera_node-1] [INFO] [1724945844.464822766] [camera.camera]: Set ROS param gyro_fps to default: 200
[realsense2_camera_node-1] [INFO] [1724945844.464836020] [camera.camera]: Set ROS param accel_fps to default: 63
[realsense2_camera_node-1] [INFO] [1724945844.467812455] [camera.camera]: Stopping Sensor: Stereo Module
[realsense2_camera_node-1] [INFO] [1724945844.477216273] [camera.camera]: Starting Sensor: Stereo Module
[realsense2_camera_node-1] [INFO] [1724945844.485908686] [camera.camera]: Open profile: stream_type: Depth(0), Format: Z16, Width: 640, Height: 480, FPS: 15
[realsense2_camera_node-1] [INFO] [1724945844.485990313] [camera.camera]: Stopping Sensor: RGB Camera
[realsense2_camera_node-1]  30/08 00:37:24,486 WARNING [136742810158656] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Success, number: 0
[realsense2_camera_node-1]  30/08 00:37:24,496 WARNING [136742810158656] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Success, number: 0
[realsense2_camera_node-1]  30/08 00:37:24,506 WARNING [136742810158656] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Success, number: 0
[realsense2_camera_node-1]  30/08 00:37:24,516 WARNING [136742810158656] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Success, number: 0
[realsense2_camera_node-1]  30/08 00:37:24,527 WARNING [136742810158656] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Success, number: 0
[realsense2_camera_node-1]  30/08 00:37:24,537 WARNING [136742810158656] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Success, number: 0
[realsense2_camera_node-1]  30/08 00:37:24,547 WARNING [136742810158656] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Success, number: 0
[realsense2_camera_node-1]  30/08 00:37:24,557 WARNING [136742810158656] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Success, number: 0
[realsense2_camera_node-1]  30/08 00:37:24,568 WARNING [136742810158656] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Success, number: 0
[realsense2_camera_node-1]  30/08 00:37:24,578 WARNING [136742810158656] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Success, number: 0
[realsense2_camera_node-1]  30/08 00:37:24,588 WARNING [136742810158656] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Success, number: 0
[realsense2_camera_node-1] [INFO] [1724945844.599038382] [camera.camera]: Starting Sensor: RGB Camera
[realsense2_camera_node-1] [INFO] [1724945844.609751625] [camera.camera]: Open profile: stream_type: Color(0), Format: RGB8, Width: 1280, Height: 720, FPS: 30
[realsense2_camera_node-1] [INFO] [1724945844.610078523] [camera.camera]: RealSense Node Is Up!

There are two things I don't understand: the resolution of the color image doesn't change, and the way the related profile information is passed in the yaml file is wrong.

MartyG-RealSense commented 2 weeks ago

The problem might be related to the use of 4.51.1 as I believe that the resolution profiles were defined a little differently in that old wrapper version.

ros2 launch realsense2_camera rs_launch.py depth_module.profile:=640x480x15 rgb_camera.profile:=640x480x15

Poodlee commented 2 weeks ago

Screenshot from 2024-08-30 00-58-14

[realsense2_camera_node-1] [INFO] [1724947068.898848032] [camera.camera]: Set ROS param gyro_fps to default: 200
[realsense2_camera_node-1] [INFO] [1724947068.898871650] [camera.camera]: Set ROS param accel_fps to default: 63
[realsense2_camera_node-1] [INFO] [1724947068.901928003] [camera.camera]: Stopping Sensor: Stereo Module
[realsense2_camera_node-1] [INFO] [1724947068.923732997] [camera.camera]: Starting Sensor: Stereo Module
[realsense2_camera_node-1] [INFO] [1724947068.929486500] [camera.camera]: Open profile: stream_type: Depth(0), Format: Z16, Width: 640, Height: 480, FPS: 15
[realsense2_camera_node-1] [INFO] [1724947068.929596266] [camera.camera]: Stopping Sensor: RGB Camera
[realsense2_camera_node-1]  30/08 00:57:48,929 WARNING [129651617826368] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
[realsense2_camera_node-1]  30/08 00:57:48,940 WARNING [129651617826368] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
[realsense2_camera_node-1]  30/08 00:57:48,950 WARNING [129651617826368] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
[realsense2_camera_node-1]  30/08 00:57:48,960 WARNING [129651617826368] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
[realsense2_camera_node-1]  30/08 00:57:48,970 WARNING [129651617826368] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
[realsense2_camera_node-1]  30/08 00:57:48,981 WARNING [129651617826368] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
[realsense2_camera_node-1]  30/08 00:57:48,991 WARNING [129651617826368] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
[realsense2_camera_node-1]  30/08 00:57:49,001 WARNING [129651617826368] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
[realsense2_camera_node-1]  30/08 00:57:49,011 WARNING [129651617826368] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
[realsense2_camera_node-1]  30/08 00:57:49,022 WARNING [129651617826368] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
[realsense2_camera_node-1]  30/08 00:57:49,032 WARNING [129651617826368] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
[realsense2_camera_node-1] [INFO] [1724947069.042878163] [camera.camera]: Starting Sensor: RGB Camera
[realsense2_camera_node-1] [INFO] [1724947069.048862747] [camera.camera]: Open profile: stream_type: Color(0), Format: RGB8, Width: 640, Height: 480, FPS: 15

I confirmed that it works properly when I run rgb_camera.profile:=640x480x15 as you said. thank you.

So, what part of the launch file I configured is causing the problem?

MartyG-RealSense commented 2 weeks ago

In your yaml file, please try editing depth_module.depth_profile to be depth_module.profile and change rgb_camera.color_profile back to rgb_camera.profile

Poodlee commented 2 weeks ago

Screenshot from 2024-08-30 01-29-50

Screenshot from 2024-08-30 01-28-33 I modified the .yaml file as you suggested and ran the original launch file again. As a result, the resolution was set to 1280x720 again. Is there an error in the node setup in launch.py?

MartyG-RealSense commented 2 weeks ago

A yaml file imports settings into the launch so that they do not have to be defined in the launch file or in a launch command. So the problem may be that a setting or settings is being imported from the yaml that is invalid and causes the launch to use the default resolution instead.

Poodlee commented 2 weeks ago

Thank you. I have finally solved the problem. After investigating, I found that there was a part in the launch file that was configured to use the newly installed realsense-ros as a binary. Therefore, even after I modified the source code, it continued to run the binary version.

After removing the binary installation procedure, it is now working properly. Thank you.

MartyG-RealSense commented 2 weeks ago

You are very welcome, @Poodlee - it's great to hear that you found the solution. Thanks very much for the update!