Skip to content

Commit

Permalink
info: display compression
Browse files Browse the repository at this point in the history
  • Loading branch information
xqms committed Dec 9, 2022
1 parent fef5437 commit 422684f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rosbag_fancy/src/bag_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <std_msgs/Header.h>
#include <std_msgs/UInt8.h>
#include "doctest.h"
#include "rosbag/stream.h"

namespace
{
Expand Down Expand Up @@ -585,6 +586,21 @@ std::vector<BagReader::ConnectionInfo>& BagReader::Iterator::currentChunkConnect
return m_reader->m_d->chunks[m_chunk].connectionInfos;
}

rosbag::CompressionType BagReader::Iterator::currentChunkCompression() const
{
switch(m_it.m_d->m_compression)
{
case ChunkIterator::Private::Compression::None:
return rosbag::compression::Uncompressed;
case ChunkIterator::Private::Compression::BZ2:
return rosbag::compression::BZ2;
case ChunkIterator::Private::Compression::LZ4:
return rosbag::compression::LZ4;
}

throw std::logic_error{"unknown compression"};
}


BagReader::BagReader(const std::string& filename)
: m_d{std::make_unique<Private>(filename)}
Expand Down
4 changes: 4 additions & 0 deletions rosbag_fancy/src/bag_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <ros/time.h>
#include <ros/serialization.h>

#include <rosbag/stream.h>

#include <boost/make_shared.hpp>

namespace rosbag_fancy
Expand Down Expand Up @@ -145,6 +147,8 @@ class BagReader
friend bool operator!= (const Iterator& a, const Iterator& b) { return a.m_chunk != b.m_chunk || a.m_it != b.m_it; };

std::vector<ConnectionInfo>& currentChunkConnections() const;
rosbag::CompressionType currentChunkCompression() const;

void skipChunk();
int chunk() const
{ return m_chunk; }
Expand Down
14 changes: 14 additions & 0 deletions rosbag_fancy/src/cmd_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "bag_reader.h"
#include "mem_str.h"
#include "rosbag/stream.h"

namespace po = boost::program_options;
using namespace rosbag_fancy;
Expand Down Expand Up @@ -99,6 +100,19 @@ int info(const std::vector<std::string>& options)
fmt::print("Duration: {:%H:%M:%S} ({:.2f}s)\n", duration, (reader.endTime() - reader.startTime()).toSec());
fmt::print("Size: {}\n", mem_str::memoryToString(reader.size()));

auto it = reader.begin();
if(it != reader.end())
{
fmt::print("Compression: ");
switch(it.currentChunkCompression())
{
case rosbag::compression::Uncompressed: fmt::print("Uncompressed\n"); break;
case rosbag::compression::BZ2: fmt::print("BZ2\n"); break;
case rosbag::compression::LZ4: fmt::print("LZ4\n"); break;
default: fmt::print("unknown\n");
}
}

fmt::print("Types:\n");
std::map<std::string, std::set<std::string>> types;
for(auto& con : reader.connections())
Expand Down

0 comments on commit 422684f

Please sign in to comment.