class mola::Rosbag2Dataset
Overview
RawDataSource for datasets in rosbag2 format.
It reads a rosbag2 file, and exposes it as a dataset with N entries, N being the number of messages in the bag. Reading them via the offline API (OfflineDatasetSource) returns empty shared_ptr observations for those messages that do not have a direct mapping to mrpt::obs classes. The dataset can be also played in an online (real-time, or with a custom time wrapping) fashion via the RawDataSourceBase API.
See example configuration files to see how to define what topics to publish, and how to optionally override the sensor poses in the local robot frame.
#include <Rosbag2Dataset.h> class Rosbag2Dataset: public mola::RawDataSourceBase, public mola::OfflineDatasetSource, public mola::Dataset_UI, public mola::TransformTreeSource { public: // structs struct DatasetEntry; // methods virtual void spinOnce(); virtual size_t datasetSize() const; virtual mrpt::obs::CSensoryFrame::Ptr datasetGetObservations(size_t timestep) const; virtual size_t datasetUI_size() const; virtual size_t datasetUI_lastQueriedTimestep() const; virtual double datasetUI_playback_speed() const; virtual void datasetUI_playback_speed(double speed); virtual bool datasetUI_paused() const; virtual void datasetUI_paused(bool paused); virtual void datasetUI_teleport(size_t timestep); virtual std::optional<double> datasetUI_time() const; virtual std::optional<double> datasetUI_total_time() const; virtual std::optional<TransformTree> transform_tree( const std::string& root, const std::optional<mrpt::Clock::time_point>& timestamp = std::nullopt ) const; virtual std::string transform_tree_default_root() const; };
Inherited Members
public: // structs struct DiagnosticsOutput; struct SensorViewerImpl; // methods virtual void initialize(const Yaml& cfg) = 0; virtual void spinOnce() = 0; ExecutableBase& operator = (const ExecutableBase&); ExecutableBase& operator = (ExecutableBase&&); RawDataSourceBase& operator = (const RawDataSourceBase&); RawDataSourceBase& operator = (RawDataSourceBase&&); virtual size_t datasetSize() const = 0; virtual mrpt::obs::CSensoryFrame::Ptr datasetGetObservations(size_t timestep) const = 0; virtual bool hasGroundTruthTrajectory() const; virtual size_t datasetUI_size() const = 0; virtual size_t datasetUI_lastQueriedTimestep() const = 0; virtual double datasetUI_playback_speed() const = 0; virtual void datasetUI_playback_speed(double speed) = 0; virtual bool datasetUI_paused() const = 0; virtual void datasetUI_paused(bool paused) = 0; virtual void datasetUI_teleport(size_t timestep) = 0; virtual std::optional<double> datasetUI_time() const; virtual std::optional<double> datasetUI_total_time() const; TransformTreeSource& operator = (const TransformTreeSource&); TransformTreeSource& operator = (TransformTreeSource&&); virtual std::optional<TransformTree> transform_tree( const std::string& root, const std::optional<mrpt::Clock::time_point>& timestamp = std::nullopt ) const = 0; virtual std::string transform_tree_default_root() const;
Methods
virtual void spinOnce()
Runs any required action on a timely manner
virtual size_t datasetSize() const
Number of different time steps available to call getObservations()
virtual mrpt::obs::CSensoryFrame::Ptr datasetGetObservations(size_t timestep) const
Returns the set of observations available for the given time step.
virtual size_t datasetUI_size() const
Number of different time steps available to call getObservations()
virtual size_t datasetUI_lastQueriedTimestep() const
Returns the latest requested observation, range [0, datasetSize()]
virtual void datasetUI_teleport(size_t timestep)
Forces continue replaying in this moment in time
virtual std::optional<double> datasetUI_time() const
Current dataset playback time, in seconds elapsed since the beginning of the dataset. Returns std::nullopt if the source cannot tell (default).
virtual std::optional<double> datasetUI_total_time() const
Total dataset duration, in seconds. Returns std::nullopt if unknown (default), e.g. for live sources or datasets read on the fly.
virtual std::optional<TransformTree> transform_tree( const std::string& root, const std::optional<mrpt::Clock::time_point>& timestamp = std::nullopt ) const
Returns all frames reachable below root (that is, the subtree it is the root of), with their poses resolved with respect to it.
Filtering happens here, in the source, since it is what owns the underlying transform buffer: a consumer interested in a robot’s joints never has to receive, nor walk, the frames of unrelated subtrees.
Parameters:
root |
The frame to use as the subtree root, e.g. “base_link”. |
timestamp |
The time to look the transforms up at. If not provided, or if no data is buffered for it, the latest available transform of each frame is used instead. |
Returns:
The subtree, or std::nullopt if root is not a known frame.
virtual std::string transform_tree_default_root() const
Returns the frame this source considers the robot’s body frame (its base_link_frame_id parameter, or equivalent), so consumers can default to it instead of hardcoding a name. Empty if the source has none.