16#define MCAP_IMPLEMENTATION
17#define MCAP_COMPRESSION_NO_LZ4
18#define MCAP_COMPRESSION_NO_ZSTD
19#define MCAP_PUBLIC __attribute__((visibility("hidden")))
21#pragma GCC diagnostic push
23#pragma GCC diagnostic ignored "-Warray-bounds"
25#pragma GCC diagnostic pop
34 template <
typename... t_String>
38 (result += ... += std::forward<t_String>(strings));
44 return (std::chrono::duration_cast<std::chrono::nanoseconds>(
49 uint32_t getRandomUInt32()
56 return (distrib(gen));
100 return (
pimpl_->names_.names());
105 return (
pimpl_->values_.values());
110 if (not
pimpl_->version_updated_)
118 const int32_t sec =
static_cast<int32_t
>(timestamp / std::nano::den);
119 const uint32_t nanosec = timestamp % std::nano::den;
121 pimpl_->names_.header().stamp().sec(sec);
122 pimpl_->values_.header().stamp().sec(sec);
123 pimpl_->names_.header().stamp().nanosec(nanosec);
124 pimpl_->values_.header().stamp().nanosec(nanosec);
141 return (
names()[index]);
151 return (
pimpl_->names_.names().size());
156 pimpl_->setVersion(version);
166 template <
class t_Message>
176 size_t current_alignment{ 0 };
189 pjmsg_mcap_wrapper_private::pjmsg::Message<t_Message>::type,
191 pjmsg_mcap_wrapper_private::pjmsg::Message<t_Message>::schema);
207 reinterpret_cast<char *
>(buffer.
data()), buffer.
size());
254 str_concat(
"Failed to open ", filename.
native(),
" for writing: ", res.
message));
259 writer_, str_concat(topic_prefix,
"/names"));
262 writer_, str_concat(topic_prefix,
"/values"));
265 template <
class t_Message>
266 void write(
const t_Message &message)
284 pimpl_->initialize(filename, topic_prefix);
290 pimpl_->writer_.dataSink()->flush();
295 if (message.
pimpl_->version_updated_)
298 message.
pimpl_->version_updated_ =
false;
This class offers an interface to calculate the encoded size of a type serialized using a support enc...
size_t calculate_serialized_size(const _T &data, size_t ¤t_alignment)
Generic template which calculates the encoded size of an instance of an unknown type.
This class offers an interface to serialize/deserialize some basic types using CDR protocol inside an...
Cdr_DllAPI bool set_encoding_flag(EncodingAlgorithmFlag encoding_flag)
Sets the EncodingAlgorithmFlag for the encapsulation when the CDR type is CdrVersion::DDS_CDR,...
Cdr_DllAPI Cdr & serialize_encapsulation()
This function writes the encapsulation of the CDR stream. If the CDR stream should contain an encapsu...
static Cdr_DllAPI const Endianness DEFAULT_ENDIAN
Default endianess in the system.
Cdr_DllAPI void set_dds_cdr_options(const std::array< uint8_t, 2 > &options)
This function sets the option flags when the CDR type is eprosima::fastcdr::DDS_CDR.
Cdr_DllAPI size_t get_serialized_data_length() const
This function returns the length of the serialized data inside the stream.
This class represents a stream of bytes that contains (or will contain) serialized data....
Provides a write interface to an MCAP file.
void addSchema(Schema &schema)
Add a new schema to the MCAP file and set schema.id to a generated schema id. The schema id is used w...
Status open(std::string_view filename, const McapWriterOptions &options)
Open a new MCAP file for writing and write the header.
void addChannel(Channel &channel)
Add a new channel to the MCAP file and set channel.id to a generated channel id. The channel id is us...
Status write(const Message &message)
Write a message to the output stream.
void close()
Write the MCAP footer, flush pending writes to the output stream, and reset internal state....
void setVersion(const uint32_t version)
plotjuggler_msgs::msg::StatisticsNames names_
plotjuggler_msgs::msg::StatisticsValues values_
void resize(const std::size_t size)
std::vector< std::string > & names()
void setVersion(const uint32_t version)
std::vector< double > & values()
std::string & name(const std::size_t index)
double & value(const std::size_t index)
const std::unique_ptr< Implementation > pimpl_
void setStamp(const uint64_t timestamp)
void reserve(const std::size_t size)
uint32_t getSize(const t_Message &message)
void initialize(mcap::McapWriter &writer, const std::string_view &msg_topic)
eprosima::fastcdr::CdrSizeCalculator cdr_size_calculator_
void write(mcap::McapWriter &writer, std::vector< std::byte > &buffer, const t_Message &message)
void write(const t_Message &message)
std::tuple< Channel< plotjuggler_msgs::msg::StatisticsNames >, Channel< plotjuggler_msgs::msg::StatisticsValues > > channels_
std::vector< std::byte > buffer_
void initialize(const std::filesystem::path &filename, const std::string &topic_prefix)
void write(const Message &message)
void initialize(const std::filesystem::path &filename, const std::string &topic_prefix)
const std::unique_ptr< Implementation > pimpl_
@ PLAIN_CDR
Specifies that the content is PLAIN_CDR.
CdrVersion
This enumeration represents the kinds of CDR serialization supported by eprosima::fastcdr::CDR.
@ XCDRv1
XCDRv1 encoding defined by standard DDS X-Types 1.3.
Describes a Channel that messages are written to. A Channel represents a single connection from a pub...
Configuration options for McapWriter.
bool noChunking
Do not write Chunks to the file, instead writing Schema, Channel, and Message records directly into t...
A single Message published to a Channel.
Timestamp logTime
Nanosecond timestamp when this message was recorded or received for recording.
const std::byte * data
A pointer to the message payload. For readers, this pointer is only valid for the lifetime of an onMe...
Timestamp publishTime
Nanosecond timestamp when this message was initially published. If not available, this should be set ...
uint64_t dataSize
Size of the message payload in bytes, pointed to via data.
Describes a schema used for message encoding and decoding and/or describing the shape of messages....
Wraps a status code and string message carrying additional context.
This class represents the structure StatisticsNames defined by the user in the IDL file.
This class represents the structure StatisticsValues defined by the user in the IDL file.