版本
- Xavier Jetpack 4.3
- realsense SDK 2.34.0及以下的C++ API
- 相机firmware 05.12.03.00.
存在问题
直接参考官方示例rs-muliticam
会报错误
terminate called after throwing an instance of 'rs2::error'
what(): failed to set power state
Aborted
解决方案一
不要使用cfg.enable_device(dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));
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));
std::cout<<"serial num = "<<dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER)<<std::endl;
cfg.enable_stream(RS2_STREAM_COLOR, RGB_STREAM_WIDTH, RGB_STREAM_HEIGHT, RS2_FORMAT_BGR8, FRAME_RATE);
cfg.enable_stream(RS2_STREAM_DEPTH, DEPTH_STREAM_WIDTH, DEPTH_STREAM_HEIGHT, RS2_FORMAT_Z16, FRAME_RATE);
//cfg.enable_stream(RS2_STREAM_ACCEL, RS2_FORMAT_MOTION_XYZ32F);
//cfg.enable_stream(RS2_STREAM_GYRO, RS2_FORMAT_MOTION_XYZ32F);
// Start streaming with default recommended configuration
pipe.start(cfg);
pipelines.emplace_back(pipe);
}
解决方案二
修改pipe.start(cfg)
的顺序,先启动二号,再启动一号
auto devs = ctx.query_devices();
rs2::pipeline pipe1(ctx);
rs2::config cfg1;
//uncomment this will rise a `failed to set power state`bug
cfg1.enable_device(devs[0].get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));
std::cout<<"serial num = "<<devs[0].get_info(RS2_CAMERA_INFO_SERIAL_NUMBER)<<std::endl;
cfg1.enable_stream(RS2_STREAM_COLOR, RGB_STREAM_WIDTH, RGB_STREAM_HEIGHT, RS2_FORMAT_BGR8, FRAME_RATE);
cfg1.enable_stream(RS2_STREAM_DEPTH, DEPTH_STREAM_WIDTH, DEPTH_STREAM_HEIGHT, RS2_FORMAT_Z16, FRAME_RATE);
// Start streaming with default recommended configuration
pipelines.emplace_back(pipe1);
rs2::pipeline pipe2(ctx);
rs2::config cfg2;
//uncomment this will rise a `failed to set power state`bug
cfg2.enable_device(devs[1].get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));
std::cout<<"serial num = "<<devs[1].get_info(RS2_CAMERA_INFO_SERIAL_NUMBER)<<std::endl;
cfg2.enable_stream(RS2_STREAM_COLOR, RGB_STREAM_WIDTH, RGB_STREAM_HEIGHT, RS2_FORMAT_BGR8, FRAME_RATE);
cfg2.enable_stream(RS2_STREAM_DEPTH, DEPTH_STREAM_WIDTH, DEPTH_STREAM_HEIGHT, RS2_FORMAT_Z16, FRAME_RATE);
// Start streaming with default recommended configuration
pipelines.emplace_back(pipe2);
pipe2.start(cfg2);
pipe1.start(cfg1);