1 Reply Latest reply on Mar 23, 2018 9:26 AM by MartyG

    rosbag repeated replay question

    Luke.bloy

      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

      librealsense/readme.md at master · IntelRealSense/librealsense · GitHub

       

      by using

      auto dev = profile.get_device();
      if(auto p = dev.as<rs2::playback>())
      {
        //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.

        • 1. Re: rosbag repeated replay question
          MartyG

          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