From 929fbc5128ab6ce425b617acece7d5adea5e4ec3 Mon Sep 17 00:00:00 2001 From: Samer Khshiboun <99127997+SamerKhshiboun@users.noreply.github.com> Date: Sun, 26 Mar 2023 13:08:32 +0300 Subject: [PATCH] use playback device for rosbags --- realsense2_camera/src/realsense_node_factory.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/realsense2_camera/src/realsense_node_factory.cpp b/realsense2_camera/src/realsense_node_factory.cpp index 92984b8590..1e90ce131a 100644 --- a/realsense2_camera/src/realsense_node_factory.cpp +++ b/realsense2_camera/src/realsense_node_factory.cpp @@ -281,12 +281,8 @@ void RealSenseNodeFactory::init() { { ROS_INFO_STREAM("publish topics from rosbag file: " << rosbag_filename.c_str()); - auto pipe = std::make_shared(); - rs2::config cfg; - cfg.enable_device_from_file(rosbag_filename.c_str(), false); - cfg.enable_all_streams(); - pipe->start(cfg); //File will be opened in read mode at this point - _device = pipe->get_active_profile().get_device(); + rs2::context ctx; + _device = ctx.load_device(rosbag_filename.c_str()); _serial_no = _device.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER); } if (_device)