"failed to set power state" error for multiple realsense

As discussed in https://github.com/IntelRealSense/librealsense/issues/5828 .

I met a strange “failed to set power state” error by running rs-multicam example.

I have a D435i and a D415 camera with both firmware 05.12.03.00.

First , the cameras both connected to the same usb3.0 hub on a ubuntu16.04 PC, it is OK.

Second, the cameras both connected to the same usb3.0 hub on Xavier with Jectpack 4.3 .

If using the realsense-viewer, I can see both camera stream , but if using c++ api , it crashed.

the test code is

    rs2::context                          ctx;        // Create librealsense context for managing devices
    std::vector<rs2::pipeline>            pipelines;

    // Start a streaming pipe per each connected device
    for (auto&& dev : ctx.query_devices())
    {
        rs2::pipeline pipe(ctx);
        rs2::config cfg;
        cfg.enable_device(dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));
        pipe.start(cfg);
        pipelines.emplace_back(pipe);
    }

It gives me

terminate called after throwing an instance of 'rs2::error'
  what():  failed to set power state
Aborted

Although I fix the issue by comment cfg.enable_device(dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER)); this line, which caused the issue for some reason.

    rs2::context ctx;// Create librealsense context for managing devices
    // Declare RealSense pipeline, encapsulating the actual device and sensors
    std::vector<rs2::pipeline> pipelines;

    // Start a streaming pipe per each connected device
    for (auto&& dev : ctx.query_devices())
    {
        rs2::pipeline pipe(ctx);
        rs2::config cfg;
        //uncomment this will rise a `failed to set power state`bug
        //cfg.enable_device(dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));
        pipe.start(cfg);
        pipelines.emplace_back(pipe);
    }

It is wield that rs-multicam works on PC but not on Xavier.

Hi,
There are one Type-A port and two type-C port on Xavier devkit. RealSense cameras require significant bandwidth. We would suggest you connect one to the Type-A port, and the other to the Type-C port with type C to A adapter.

thank you.

First, there is no use to connect one to the Type-A port, and the other to the Type-C port with type C to A adapter which I had tried already.

Change the start order will solve this problem. Start camera no.2 first .then camera no.1 . But still can not figure out why.

import pyrealsense2 as rs
import numpy as np
import cv2

devices = rs.context().query_devices()

pipeline_1 = rs.pipeline()
pipeline_2 = rs.pipeline()

config_1 = rs.config()
config_2 = rs.config()
config_1.enable_device(devices[0].get_info(rs.camera_info.serial_number))
config_2.enable_device(devices[1].get_info(rs.camera_info.serial_number))

config_1.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 60)
config_1.enable_stream(rs.stream.color, 640, 480, rs.format.rgb8, 60)
config_2.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 60)
config_2.enable_stream(rs.stream.color, 640, 480, rs.format.rgb8, 60)

pipeline_2.start(config_2)
pipeline_1.start(config_1)

Hi,
Please set sudo nvpmodel -m 0 and sudo jetson_clocks. Check if running the system in max performance helps.

We have tried two D435s and it works fine. One is connected to Type-A port and the other is connected to Type-C port with C to A adapter.

Thank you.

sudo nvpmodel -m 0 and sudo jetson_clocks has already been set before.

How did you test on two D435s? Don’t test on realsense-viewer, but on its API.

As I mentioned , two D435s work OK no matter mounted on a same hub or One is connected to Type-A port and the other is connected to Type-C port with C to A adapter if the start order is right.

For example , it will fail in this situation on Xavier but success on PC with GeForce GTX 1080.

python test code.

import pyrealsense2 as rs
import numpy as np
import cv2

devices = rs.context().query_devices()

pipeline_1 = rs.pipeline()
pipeline_2 = rs.pipeline()

config_1 = rs.config()
config_2 = rs.config()
config_1.enable_device(devices[0].get_info(rs.camera_info.serial_number))
config_2.enable_device(devices[1].get_info(rs.camera_info.serial_number))

config_1.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 60)
config_1.enable_stream(rs.stream.color, 640, 480, rs.format.rgb8, 60)
config_2.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 60)
config_2.enable_stream(rs.stream.color, 640, 480, rs.format.rgb8, 60)

pipeline_1.start(config_1)
pipeline_2.start(config_2)

C++ test code is here

    rs2::context                          ctx;        // Create librealsense context for managing devices
    std::vector<rs2::pipeline>            pipelines;

    // Start a streaming pipe per each connected device
    for (auto&& dev : ctx.query_devices())
    {
        rs2::pipeline pipe(ctx);
        rs2::config cfg;
        cfg.enable_device(dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));
        pipe.start(cfg);
        pipelines.emplace_back(pipe);
    }