Skip to main content

cnspy_rosbag2csv -- Package

A package to convert different [ROS1] messages for POSES. Messages contained in rosbag files can be converted into CSV files in different output formats using ROSBAG2CSV. The other way round is supported by the class CSV2ROSbag, taking multiple CSV files and writing them into a single bag file.

The supported ROS1 message types are defined in ROSMessageTypes (basically all ROS1 geometry_msgs).

The package is easily extendable (Open-Closed-Principle). Just create a new ROSMessageType, and make an addition to

The supported CSV formats for poses are defined in the enum CSVFormatPose of the package cnspy_spatial_csv_formats.

Installation

Install the current code base from GitHub and pip install a link to that cloned copy

git clone https://github.com/aau-cns/cnspy_rosbag2csv.git
cd cnspy_rosbag2csv
pip install -e .

or the official package via

pip install cnspy-rosbag2csv

Dependencies

This package requires a local ROS installation.

It is part of the cnspy eco-system of the cns-github group.
Main dependencies are:

Run from terminal

  • CSV2ROSbag
  • ROSbag2CSV
  • ROSbag_ReTimestamp
  • ROSbagMerge

CSV2ROSbag

Convert multiple trajectory CSV files into a bag file.

rosbag2csv$ python CSV2ROSbag.py -h 
usage: CSV2ROSbag.py [-h] [--bagfile_name BAGFILE_NAME]
                     [--topics [TOPICS [TOPICS ...]]]
                     [--filenames [FILENAMES [FILENAMES ...]]]
                     [--fmt_list [{GEOMETRY_MSGS_POINTSTAMPED,GEOMETRY_MSGS_POSE,GEOMETRY_MSGS_POSESTAMPED,GEOMETRY_MSGS_POSEWITHCOVARIANCE,GEOMETRY_MSGS_POSEWITHCOVARIANCESTAMPED,GEOMETRY_MSGS_QUATERNION,GEOMETRY_MSGS_QUATERNIONSTAMPED,GEOMETRY_MSGS_TRANSFORM,GEOMETRY_MSGS_TRANSFORMSTAMPED,GEOMETRY_MSGS_VECTOR3,GEOMETRY_MSGS_VECTOR3STAMPED,NOT_SUPPORTED} [{GEOMETRY_MSGS_POINTSTAMPED,GEOMETRY_MSGS_POSE,GEOMETRY_MSGS_POSESTAMPED,GEOMETRY_MSGS_POSEWITHCOVARIANCE,GEOMETRY_MSGS_POSEWITHCOVARIANCESTAMPED,GEOMETRY_MSGS_QUATERNION,GEOMETRY_MSGS_QUATERNIONSTAMPED,GEOMETRY_MSGS_TRANSFORM,GEOMETRY_MSGS_TRANSFORMSTAMPED,GEOMETRY_MSGS_VECTOR3,GEOMETRY_MSGS_VECTOR3STAMPED,NOT_SUPPORTED} ...]]]
                     [--result_dir RESULT_DIR] [--verbose]

CSV2ROSbag: read CSV files and convert lines to specified ROS msg and store
them into a rosbag

optional arguments:
  -h, --help            show this help message and exit
  --bagfile_name BAGFILE_NAME
                        name of bag file (no path!)
  --topics [TOPICS [TOPICS ...]]
                        topics to create
  --filenames [FILENAMES [FILENAMES ...]]
                        csv filename of corresponding topic
  --fmt_list [{GEOMETRY_MSGS_POINTSTAMPED,GEOMETRY_MSGS_POSE,GEOMETRY_MSGS_POSESTAMPED,GEOMETRY_MSGS_POSEWITHCOVARIANCE,GEOMETRY_MSGS_POSEWITHCOVARIANCESTAMPED,GEOMETRY_MSGS_QUATERNION,GEOMETRY_MSGS_QUATERNIONSTAMPED,GEOMETRY_MSGS_TRANSFORM,GEOMETRY_MSGS_TRANSFORMSTAMPED,GEOMETRY_MSGS_VECTOR3,GEOMETRY_MSGS_VECTOR3STAMPED,NOT_SUPPORTED} [{GEOMETRY_MSGS_POINTSTAMPED,GEOMETRY_MSGS_POSE,GEOMETRY_MSGS_POSESTAMPED,GEOMETRY_MSGS_POSEWITHCOVARIANCE,GEOMETRY_MSGS_POSEWITHCOVARIANCESTAMPED,GEOMETRY_MSGS_QUATERNION,GEOMETRY_MSGS_QUATERNIONSTAMPED,GEOMETRY_MSGS_TRANSFORM,GEOMETRY_MSGS_TRANSFORMSTAMPED,GEOMETRY_MSGS_VECTOR3,GEOMETRY_MSGS_VECTOR3STAMPED,NOT_SUPPORTED} ...]]
                        CSV format
  --result_dir RESULT_DIR
                        directory to store results [otherwise bagfile name
                        will be a directory]
  --verbose

Example

rosbag2csv$ python CSV2ROSbag.py --bagfile_name dummy.bag --topics /pose_est /pose_gt --filenames ../sample_data/ID1-pose-est-cov.csv ../sample_data/ID1-pose-gt.csv --fmt_list GEOMETRY_MSGS_POSEWITHCOVARIANCESTAMPED GEOMETRY_MSGS_POSESTAMPED --verbose

ROSBAG2CSV

Convert a ROS bagfile into multipe CSV files.

rosbag2csv$ python ROSbag2CSV.py -h
usage: ROSbag2CSV.py [-h] [--bagfile BAGFILE] [--topics [TOPICS [TOPICS ...]]]
                     [--filenames [FILENAMES [FILENAMES ...]]]
                     [--result_dir RESULT_DIR] [--verbose]
                     [--format {PoseCov,PoseWithCov,TUM,TUM_short,none}]

ROSbag2CSV: extract and store given topics of a rosbag into a CSV file

optional arguments:
  -h, --help            show this help message and exit
  --bagfile BAGFILE     input bag file
  --topics [TOPICS [TOPICS ...]]
                        desired topics
  --filenames [FILENAMES [FILENAMES ...]]
                        csv filename of corresponding topic
  --result_dir RESULT_DIR
                        directory to store results [otherwise bagfile name
                        will be a directory]
  --verbose
  --format {PoseCov,PoseWithCov,TUM,TUM_short,none}
                        CSV format

Example

rosbag2csv$ python ROSbag2CSV.py --bagfile ../sample_data/dummy.bag --topics /pose_est /pose_gt --verbose --filename ../sample_data/NEW-ID1-pose-est-cov.csv ../sample_data/NEW-ID1-pose-gt.csv --format PoseWithCov

ROSbagMerge

Merges all bag file in a specified directory or from a provided list into one bag file

rosbag2csv$ python ROSbagMerge.py -h
usage: ROSbagMerge.py [-h] [--outbag_name OUTBAG_NAME] [--input_dir INPUT_DIR] [--input_files INPUT_FILES [INPUT_FILES ...]] [--verbose] [--use_header_timestamp] [-l WHITE_LIST [WHITE_LIST ...]]

ROSbagMerge: merge all bag file in a specified directory or from a provided list into one bag file

optional arguments:
  -h, --help            show this help message and exit
  --outbag_name OUTBAG_NAME
                        name of created bag file
  --input_dir INPUT_DIR
                        directory containing bag files to be merged
  --input_files INPUT_FILES [INPUT_FILES ...]
                        a list of files to be merged
  --verbose
  --use_header_timestamp
                        overwrites the bag time with the header time stamp
  -l WHITE_LIST [WHITE_LIST ...], --white_list WHITE_LIST [WHITE_LIST ...]
                        white list of topic names or fractions of it that are expected

Example

rosbag2csv$ python ROSbagMerge.py --outbag_name /tmp/merged.bag --input_files /tmp/uav10/_2024-02-06-16-33-50.bag /tmp/uav11/_2024-02-06-16-33-50.bag /tmp/uav12/_2024-02-06-16-33-50.bag --verbose --white_list mavros hw_api /tf data_handler vrpn_client uvdar/
rosbag2csv$ python ROSbagMerge.py --outbag_name /tmp/sim_tp.bag --input_dir /tmp/MultiAgentUWB/EuRoC_D140_A0_Mesh0/run1/bags --verbose --use_header_timestamp

ROSbag_ReTimestamp

Sets the rosbag time to the timestamp of the msgs header

rosbag2csv$ python ROSbag_ReTimestamp.py -h
usage: ROSbag_ReTimestamp.py [-h] [--outbag_name OUTBAG_NAME] --inbag_name INBAG_NAME [--verbose] [--use_header_timestamp]

ROSbag_ReTimestamp: sets the rosbag time to the timestamp of the msgs header

optional arguments:
  -h, --help            show this help message and exit
  --outbag_name OUTBAG_NAME
                        name of created bag file
  --inbag_name INBAG_NAME
                        name of original bag file
  --verbose
  --use_header_timestamp
                        overwrites the bag time with the header time stamp

License

Software License Agreement (GNU GPLv3 License), refer to the LICENSE file.

Sharing is caring! - Roland Jung

Metadata

Release files for cnspy-rosbag2csv 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cnspy-rosbag2csv 0.2.6
File Size Uploaded
cnspy_rosbag2csv-0.2.6.tar.gz 29.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cnspy-rosbag2csv 0.2.6
File Interpreter ABI Platform
cnspy_rosbag2csv-0.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 67.3 kB

Release files / cnspy_rosbag2csv-0.2.6.tar.gz

Download URL cnspy_rosbag2csv-0.2.6.tar.gz
Size 29.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8e67a9f0346223544604fab04d6d9f0a9df80dbdd7c10a260ddb84eedd5a8b38
BLAKE2b-256 checksum
How to use checksums
db73ccd19948378ce0cfa694764c4bcb2303d128f47a4a3bdf054086450356fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.10

Release files / cnspy_rosbag2csv-0.2.6-py3-none-any.whl

Download URL cnspy_rosbag2csv-0.2.6-py3-none-any.whl
Size 37.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2bd2b78bcaa9f5483f9cef9d8a9ac69831e5cb2c90abdf61a146ebc32322c01
BLAKE2b-256 checksum
How to use checksums
d7b7ada20de926d3993c71006a9c7e09b7e33b286f9b7b4fd9d86a5592d1e56b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.2.6 This release

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

1 release file

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page