grepros 1.2.2
grep for ROS bag files and live topics
Loading...
Searching...
No Matches
BagSource Class Reference

Produces messages from ROS bagfiles. More...

Inheritance diagram for BagSource:
Inheritance graph

Public Member Functions

 __init__ (self, args=None, **kwargs)
 
 close (self)
 Closes current bag, if any.
 
 close_batch (self)
 Closes current bag, if any.
 
 configure (self, args=None, **kwargs)
 Updates source configuration.
 
 format_message_meta (self, topic, msg, stamp, index=None)
 Returns message metainfo string.
 
 format_meta (self)
 Returns bagfile metainfo string.
 
 get_batch (self)
 Returns name of current bagfile, or self if reading stream.
 
 get_message_class (self, typename, typehash=None)
 Returns ROS message type class.
 
 get_message_definition (self, msg_or_type)
 Returns ROS message type definition full text, including subtype definitions.
 
 get_message_meta (self, topic, msg, stamp, index=None)
 Returns message metainfo data dict.
 
 get_message_type_hash (self, msg_or_type)
 Returns ROS message type MD5 hash.
 
 get_meta (self)
 Returns bagfile metainfo data dict.
 
 init_progress (self)
 Initializes progress bar, if any, for current bag.
 
 is_processable (self, topic, msg, stamp, index=None)
 Returns whether message passes source filters; registers status.
 
 notify (self, status)
 Reports match status of last produced message.
 
 read (self)
 Yields messages from ROS bagfiles, as (topic, msg, ROS time).
 
 validate (self)
 Returns whether ROS environment is set and arguments valid, prints error if not.
 
- Public Member Functions inherited from Source
 __init__ (self, args=None, **kwargs)
 
 __enter__ (self)
 Context manager entry.
 
 __exit__ (self, exc_type, exc_value, traceback)
 Context manager exit, closes source.
 
 __iter__ (self)
 Yields messages from source, as (topic, msg, ROS time).
 
 bind (self, sink)
 Attaches sink to source.
 
 close (self)
 Shuts down input, closing any files or connections.
 
 close_batch (self)
 Shuts down input batch if any (like bagfile), else all input.
 
 configure (self, args=None, **kwargs)
 Updates source configuration.
 
 configure_progress (self, **kwargs)
 Configures progress bar options, updates current bar if any.
 
 format_message_meta (self, topic, msg, stamp, index=None)
 Returns message metainfo string.
 
 format_meta (self)
 Returns source metainfo string.
 
 get_batch (self)
 Returns source batch identifier if any (like bagfile name if BagSource).
 
 get_message_class (self, typename, typehash=None)
 Returns message type class.
 
 get_message_definition (self, msg_or_type)
 Returns ROS message type definition full text, including subtype definitions.
 
 get_message_meta (self, topic, msg, stamp, index=None)
 Returns message metainfo data dict.
 
 get_message_type_hash (self, msg_or_type)
 Returns ROS message type MD5 hash.
 
 get_meta (self)
 Returns source metainfo data dict.
 
 init_progress (self)
 Initializes progress bar, if any.
 
 is_processable (self, topic, msg, stamp, index=None)
 Returns whether message passes source filters; registers status.
 
 notify (self, status)
 Reports match status of last produced message.
 
 read (self)
 Yields messages from source, as (topic, msg, ROS time).
 
 thread_excepthook (self, text, exc)
 Handles exception, used by background threads.
 
 update_progress (self, count, running=True)
 Updates progress bar, if any, with source processed count, pauses bar if not running.
 
 validate (self)
 Returns whether arguments are valid and source prerequisites are met.
 
- Public Member Functions inherited from ConditionMixin
 __init__ (self, args=None, **kwargs)
 
 close_batch (self)
 Clears cached messages.
 
 conditions_get_topics (self)
 Returns a list of all topics used in conditions (may contain wildcards).
 
 conditions_register_message (self, topic, msg)
 Retains message for condition evaluation if in condition topic.
 
 conditions_set_topic_state (self, topic, pure)
 Sets whether topic is purely used for conditions not matching.
 
 has_conditions (self)
 Returns whether there are any conditions configured.
 
 is_conditions_topic (self, topic, pure=True)
 Returns whether topic is used for checking condition.
 
 is_processable (self, topic, msg, stamp, index=None)
 Returns whether message passes passes current state conditions, if any.
 
 validate (self)
 Returns whether conditions have valid syntax, sets options, prints errors.
 

Public Attributes

 bar
 
 topics
 
 valid
 
- Public Attributes inherited from Source
 args
 
 bar
 ProgressBar instance, if any.
 
 preprocess
 Apply all filter arguments when reading, not only topic and type.
 
 sink
 outputs.Sink instance bound to this source
 
 topics
 All topics in source, as {(topic, typenane, typehash): total message count or None}.
 
 valid
 Result of validate()
 
- Public Attributes inherited from ConditionMixin
 args
 

Static Public Attributes

 DEFAULT_ARGS
 Constructor argument defaults.
 
str MESSAGE_META_TEMPLATE = "{topic} {index}/{total} ({type} {dt} {stamp})"
 Template for message metainfo line.
 
str META_TEMPLATE
 Template for bag metainfo header.
 
- Static Public Attributes inherited from Source
 DEFAULT_ARGS
 Constructor argument defaults.
 
str MESSAGE_META_TEMPLATE = "{topic} #{index} ({type} {dt} {stamp})"
 Template for message metainfo line.
 
- Static Public Attributes inherited from ConditionMixin
 DEFAULT_ARGS = dict(CONDITION=())
 Constructor argument defaults.
 
 TOPIC_RGX = re.compile(r"<topic\s+([^\s><]+)\s*>")
 

Detailed Description

Produces messages from ROS bagfiles.

Definition at line 522 of file inputs.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  args = None,
**  kwargs 
)
Parameters
argsarguments as namespace or dictionary, case-insensitive; or a single path as the ROS bagfile to read, or a stream to read from, or one or more Bag instances

Bag-specific arguments:

Parameters
args.filenames of ROS bagfiles to read if not all in directory, or a stream to read from; or one or more Bag instances
args.pathpaths to scan if not current directory
args.recurserecurse into subdirectories when looking for bagfiles
args.orderby"topic" or "type" if any to group results by
args.decompressdecompress archived bags to file directory
args.reindexmake a copy of unindexed bags and reindex them (ROS1 only)
args.timescaleemit messages on original timeline from first message at given rate, 0 disables
args.timescale_emissiontimeline from first matched message not first in bag, requires notify() for each message
args.writeoutputs, to skip in input files
args.bagone or more Bag instances

General arguments:

Parameters
args.topicROS topics to read if not all
args.typeROS message types to read if not all
args.skip_topicROS topics to skip
args.skip_typeROS message types to skip
args.start_timeearliest timestamp of messages to read
args.end_timelatest timestamp of messages to read
args.start_indexmessage index within topic to start from
args.end_indexmessage index within topic to stop at
args.uniqueemit messages that are unique in topic
args.select_fieldmessage fields to use for uniqueness if not all
args.noselect_fieldmessage fields to skip for uniqueness
args.nth_messageread every Nth message in topic, starting from first
args.nth_intervalminimum time interval between messages in topic, as seconds or ROS duration
args.conditionPython expressions that must evaluate as true for message to be processable, see ConditionMixin
args.progresswhether to print progress bar
args.stop_on_errorstop execution on any error like unknown message type
args.verbosewhether to print error stacktraces
kwargsany and all arguments as keyword overrides, case-insensitive

Reimplemented from Source.

Definition at line 588 of file inputs.py.

Member Function Documentation

◆ close()

close (   self)

Closes current bag, if any.

Reimplemented from Source.

Definition at line 677 of file inputs.py.

◆ close_batch()

close_batch (   self)

Closes current bag, if any.

Reimplemented from Source.

Definition at line 684 of file inputs.py.

◆ configure()

configure (   self,
  args = None,
**  kwargs 
)

Updates source configuration.

Parameters
argsarguments as namespace or dictionary, case-insensitive
kwargsany and all arguments as keyword overrides, case-insensitive

Reimplemented from Source.

Definition at line 645 of file inputs.py.

◆ format_message_meta()

format_message_meta (   self,
  topic,
  msg,
  stamp,
  index = None 
)

Returns message metainfo string.

Reimplemented from Source.

Definition at line 700 of file inputs.py.

◆ format_meta()

format_meta (   self)

Returns bagfile metainfo string.

Reimplemented from Source.

Definition at line 696 of file inputs.py.

◆ get_batch()

get_batch (   self)

Returns name of current bagfile, or self if reading stream.

Reimplemented from Source.

Definition at line 706 of file inputs.py.

◆ get_message_class()

get_message_class (   self,
  typename,
  typehash = None 
)

Returns ROS message type class.

Reimplemented from Source.

Definition at line 733 of file inputs.py.

◆ get_message_definition()

get_message_definition (   self,
  msg_or_type 
)

Returns ROS message type definition full text, including subtype definitions.

Reimplemented from Source.

Definition at line 738 of file inputs.py.

◆ get_message_meta()

get_message_meta (   self,
  topic,
  msg,
  stamp,
  index = None 
)

Returns message metainfo data dict.

Reimplemented from Source.

Definition at line 724 of file inputs.py.

◆ get_message_type_hash()

get_message_type_hash (   self,
  msg_or_type 
)

Returns ROS message type MD5 hash.

Reimplemented from Source.

Definition at line 743 of file inputs.py.

◆ get_meta()

get_meta (   self)

Returns bagfile metainfo data dict.

Reimplemented from Source.

Definition at line 710 of file inputs.py.

◆ init_progress()

init_progress (   self)

Initializes progress bar, if any, for current bag.

Reimplemented from Source.

Definition at line 779 of file inputs.py.

◆ is_processable()

is_processable (   self,
  topic,
  msg,
  stamp,
  index = None 
)

Returns whether message passes source filters; registers status.

Reimplemented from Source.

Definition at line 758 of file inputs.py.

◆ notify()

notify (   self,
  status 
)

Reports match status of last produced message.

Reimplemented from Source.

Definition at line 748 of file inputs.py.

◆ read()

read (   self)

Yields messages from ROS bagfiles, as (topic, msg, ROS time).

Reimplemented from Source.

Definition at line 607 of file inputs.py.

◆ validate()

validate (   self)

Returns whether ROS environment is set and arguments valid, prints error if not.

Reimplemented from Source.

Definition at line 649 of file inputs.py.

Member Data Documentation

◆ bar

bar

Definition at line 691 of file inputs.py.

◆ DEFAULT_ARGS

DEFAULT_ARGS
static
Initial value:
= dict(BAG=(), FILE=(), PATH=(), RECURSE=False, TOPIC=(), TYPE=(),
SKIP_TOPIC=(), SKIP_TYPE=(), START_TIME=None, END_TIME=None,
START_INDEX=None, END_INDEX=None, CONDITION=(), AFTER=0, ORDERBY=None,
DECOMPRESS=False, REINDEX=False, WRITE=(), PROGRESS=False,
STOP_ON_ERROR=False, TIMESCALE=0, TIMESCALE_EMISSION=False, VERBOSE=False)

Constructor argument defaults.

Definition at line 534 of file inputs.py.

◆ MESSAGE_META_TEMPLATE

str MESSAGE_META_TEMPLATE = "{topic} {index}/{total} ({type} {dt} {stamp})"
static

Template for message metainfo line.

Definition at line 526 of file inputs.py.

◆ META_TEMPLATE

str META_TEMPLATE
static
Initial value:
= "\nFile {file} ({size}), {tcount} topics, {mcount:,d} messages\n" \
"File period {startdt} - {enddt}\n" \
"File span {delta} ({start} - {end})"

Template for bag metainfo header.

Definition at line 529 of file inputs.py.

◆ topics

topics

Definition at line 809 of file inputs.py.

◆ valid

valid

Definition at line 652 of file inputs.py.


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