grepros

grep for ROS bag files and live topics

Index
Installation
Using the program
Matching and filtering
Limits
Filtering
Conditions
Outputs
Command-line options
Plugins
Changelog

API documentation
View the Project on GitHub suurjaak/grepros

Matching and filtering

Any number of patterns can be specified, message matches if all patterns find a match.
If no patterns are given, any message matches.

Match messages containing all of the words:

cpu memory speed

Match messages where frame_id contains "world":

frame_id=world

Match messages where header.frame_id is present:

header.frame_id=.*

Match as plaintext, not Python regular expression patterns:

-F
--fixed-strings

Select non-matching messages instead:

-v
--invert-match

Use case-sensitive matching in patterns (default is insensitive):

-I
--no-ignore-case

Limits

Stop after matching a specified number of messages (per each file if bag input):

-m          100
--max-count 100

Read only a specified number of topics (per each file if bag input):

--max-topics 10

Emit a specified number of matches per topic (per each file if bag input):

--max-per-topic 20

Emit every Nth match in topic:

--every-nth-match 10  # (skips 9 matches in topic after each match emitted)

Filtering

Read specific topics only (supports * wildcards):

-t      *lidar* *ins*
--topic /robot/sensors/*

Skip specific topics (supports * wildcards):

-nt        *lidar* *ins*
--no-topic /robot/sensors/*

Read specific message types only (supports * wildcards):

-d     *Twist*
--type sensor_msgs/*

Skip specific message types from reading (supports * wildcards):

-nd       *Twist*
--no-type sensor_msgs/*

Set specific message fields to scan (supports nested.paths and * wildcards):

-sf            twist.linear
--select-field *data

Skip specific message fields in scan (supports nested.paths and * wildcards):

-ns               twist.linear
--no-select-field *data

Only emit matches that are unique in topic,
taking --select-field and --no-select-field into account (per each file if bag input):

--unique-only

Start reading from a specific timestamp:

-t0          2021-11     # (using partial ISO datetime)
--start-time 1636900000  # (using UNIX timestamp)
--start-time +100        # (seconds from bag start time, or from script startup time if live input)
--start-time -100        # (seconds from bag end time, or script startup time if live input)

Stop readng at a specific timestamp:

-t1        2021-11     # (using partial ISO datetime)
--end-time 1636900000  # (using UNIX timestamp)
--end-time +100        # (seconds from bag start time, or from script startup time if live input)
--end-time -100        # (seconds from bag end time, or from script startup time if live input)

Start reading from a specific message index in topic:

-n0           -100  # (counts back from topic total message count in bag)
--start-index   10  # (1-based index)

Stop reading at a specific message index in topic:

-n1         -100  # (counts back from topic total message count in bag)
--end-index   10  # (1-based index)

Read every Nth message in topic:

--every-nth-message 10  # (skips 9 messages in topic with each step)

Read messages in topic with timestamps at least N seconds apart:

--every-nth-interval 5  # (samples topic messages no more often than every 5 seconds)

Conditions

--condition "PYTHON EXPRESSION"

Specify one or more Python expressions that must evaluate as true to search encountered messages. Expressions can access topics, by name or * wildcard, and refer to message fields directly.

# (Match while last message in '/robot/enabled' has data=true)
--condition ".data"

# (Match if at least 10 messages have been encountered in /robot/alerts)
--condition "len() > 10"

# (Match if last two messages in /robot/mode have equal .value)
--condition "[-2].value == [-1].value"

# (Match while control is enabled and robot is moving straight and level)
--condition ".data and .linear.x > 0 and .angular.z < 0.02"
Condition namespace:
Item Description
msg current message from data source
topic full name of current message topic
topic by full name or * wildcard
len() number of messages encountered in topic
bool() whether any message encountered in topic
.xyz attribute xyz of last message in topic
[index] topic message at position (from first encountered if index >= 0, last encountered if < 0)
[index].xyz attribute xyz of topic message at position
value in msg whether any field in current message contains value
value in whether any field in last topic message contains value
value in [index] whether any field in topic message at position contains value
Condition is automatically false if trying to access attributes of a message not yet received.