Fixposition SDK 0.0.0-heads/main-0-g7b59b93
Collection of c++ libraries and apps for use with Fixposition products
Loading...
Searching...
No Matches
fpsdk::ros1::bagwriter::BagWriter Class Reference

ROS1 bag writer helper. More...

#include <bagwriter.hpp>

Public Types

using RosTime = fpsdk::common::time::RosTime
 Shortcut.
 

Public Member Functions

bool Open (const std::string &path, const int compress)
 Open bag for writing.
 
void Close ()
 Close bag.
 
void WriteMessage (const rosbag::MessageInstance &msg, const std::string &topic="")
 Write a message to the bag, do nothing if no bag is open.
 
template<typename T >
void WriteMessage (const T &msg, const std::string &topic, const ros::Time &time={})
 Write a message to the bag, do nothing if no bag is open.
 
template<typename T >
void WriteMessage (const T &msg, const std::string &topic, const RosTime &time={})
 Write a message to the bag, do nothing if no bag is open.
 
void AddMsgDef (const std::string &topic, const std::string &msg_name, const std::string &msg_md5, const std::string &msg_def)
 Add ROS message definition.
 
bool WriteMessage (const std::vector< uint8_t > &data, const std::string &topic, const ros::Time &time={})
 Write raw binary (serialised) message.
 
bool WriteMessage (const std::vector< uint8_t > &data, const std::string &topic, const RosTime &time={})
 Write raw binary (serialised) message.
 

Detailed Description

ROS1 bag writer helper.

Definition at line 47 of file bagwriter.hpp.

Member Typedef Documentation

◆ RosTime

Member Function Documentation

◆ Open()

bool fpsdk::ros1::bagwriter::BagWriter::Open ( const std::string & path,
const int compress )

Open bag for writing.

Parameters
pathPath/filename of the bag file
compressCompress bag, 0 = no compression, 1 = LZ4, 2+ = BZ2
Returns
true if bag was sucessfully opened

◆ WriteMessage() [1/5]

void fpsdk::ros1::bagwriter::BagWriter::WriteMessage ( const rosbag::MessageInstance & msg,
const std::string & topic = "" )

Write a message to the bag, do nothing if no bag is open.

Parameters
[in]msgThe message
[in]topicOptional topic name, if not given the original topic name is used

The bag record time of the msg is used in the output bag. This time is stored and used for writing messages that have no time (templated method below).

◆ WriteMessage() [2/5]

template<typename T >
void fpsdk::ros1::bagwriter::BagWriter::WriteMessage ( const T & msg,
const std::string & topic,
const ros::Time & time = {} )
inline

Write a message to the bag, do nothing if no bag is open.

Template Parameters
TROS message type
Parameters
[in]msgThe message
[in]topicTopic name
[in]timeOptional bag record time, if ros::Time() is given the time from the last written message (see method above) is used

Definition at line 89 of file bagwriter.hpp.

◆ WriteMessage() [3/5]

template<typename T >
void fpsdk::ros1::bagwriter::BagWriter::WriteMessage ( const T & msg,
const std::string & topic,
const RosTime & time = {} )
inline

Write a message to the bag, do nothing if no bag is open.

Template Parameters
TROS message type
Parameters
[in]msgThe message
[in]topicTopic name
[in]timeOptional bag record time, if ros::Time() is given the time from the last written message (see method above) is used

Definition at line 111 of file bagwriter.hpp.

◆ AddMsgDef()

void fpsdk::ros1::bagwriter::BagWriter::AddMsgDef ( const std::string & topic,
const std::string & msg_name,
const std::string & msg_md5,
const std::string & msg_def )

Add ROS message definition.

Note
No checks on the provided data are done!
Parameters
[in]topicThe topic name
[in]msg_nameThe message name (a.k.a. data type)
[in]msg_md5The message MD5 sum
[in]msg_defThe message definition

◆ WriteMessage() [4/5]

bool fpsdk::ros1::bagwriter::BagWriter::WriteMessage ( const std::vector< uint8_t > & data,
const std::string & topic,
const ros::Time & time = {} )

Write raw binary (serialised) message.

Note
No checks on the provided data are done!
Parameters
[in]dataThe binary message data
[in]topicThe topic name
[in]timeOptional bag record time, if not given the time from the last written message is used
Returns
true if message was added, false otherwise (message definition missing)

◆ WriteMessage() [5/5]

bool fpsdk::ros1::bagwriter::BagWriter::WriteMessage ( const std::vector< uint8_t > & data,
const std::string & topic,
const RosTime & time = {} )

Write raw binary (serialised) message.

Note
No checks on the provided data are done!
Parameters
[in]dataThe binary message data
[in]topicThe topic name
[in]timeOptional bag record time, if not given the time from the last written message is used
Returns
true if message was added, false otherwise (message definition missing)

The documentation for this class was generated from the following file: