Items with no label
3335 Discussions

rosbag repeated replay question

lbloy
Beginner
1,169 Views

I'd like to be able to playback from a saved rosbag file, but I'd like the playback to not repeat. This is clearly doable from looking at the realsense-viewer, but I'm not sure how to do it from a more straight forward pipe instance as shown in

https://github.com/IntelRealSense/librealsense/blob/master/src/media/readme.md librealsense/readme.md at master · IntelRealSense/librealsense · GitHub

by using

auto dev = profile.get_device(); 

if(auto p = dev.as())

 

{

 

//Use p for playback functionality

 

}

I can pause and resume the streams, but I'm not sure where access to the repeating functionality is managed?

Thanks.

0 Kudos
1 Reply
MartyG
Honored Contributor III
287 Views

Judging by the example script in the playback documentation, I would guess that you would put pipe.stop() at the end of your playback script to stop it looping.

rs2::config cfg;

cfg.enable_device_from_file("path_to_input_file.bag");

rs2::pipeline pipe;

pipe.start(cfg); //File will be opened in read mode at this point

for (int i = 0; i < 30; i++)

{

rs2::frameset frames;

if (pipe.poll_for_frames(&frames))

{

//use frames here

}

//Note that we use poll_for_frames instead of wait_for_frames

//This is because the file only contains a finite amount of frames

// and if we use wait_for_frames then after reading the entire file

// we will fail to wait for the next frame (and get an exception)

}

pipe.stop(); //File will be closed at this point

0 Kudos
Reply