grepros 1.3.0
grep for ROS bag files and live topics
Loading...
Searching...
No Matches
BagSource Class Reference
Inheritance diagram for BagSource:
Inheritance graph

Public Member Functions

 __init__ (self, args=None, **kwargs)
 
 close (self)
 
 close_batch (self)
 
 configure (self, args=None, **kwargs)
 
 format_message_meta (self, topic, msg, stamp, index=None)
 
 format_meta (self)
 
 get_batch (self)
 
 get_message_class (self, typename, typehash=None)
 
 get_message_definition (self, msg_or_type)
 
 get_message_meta (self, topic, msg, stamp, index=None)
 
 get_message_type_hash (self, msg_or_type)
 
 get_meta (self)
 
 init_progress (self)
 
 is_processable (self, topic, msg, stamp, index=None)
 
 notify (self, status)
 
 read (self)
 
 validate (self)
 
- Public Member Functions inherited from Source
 __enter__ (self)
 
 __exit__ (self, exc_type, exc_value, traceback)
 
 __iter__ (self)
 
 bind (self, sink)
 
 configure_progress (self, **kwargs)
 
 thread_excepthook (self, text, exc)
 
 update_progress (self, count, running=True)
 
- Public Member Functions inherited from ConditionMixin
 conditions_get_topics (self)
 
 conditions_register_message (self, topic, msg)
 
 conditions_set_topic_state (self, topic, pure)
 
 has_conditions (self)
 
 is_conditions_topic (self, topic, pure=True)
 

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 514 of file inputs.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  args = None,
**  kwargs 
)
@param   args                   arguments 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 {@link grepros.api.Bag Bag} instances
<!--sep-->

Bag-specific arguments:
@param   args.file              names of ROS bagfiles to read if not all in directory,
                                or a stream to read from;
                                or one or more {@link grepros.api.Bag Bag} instances
@param   args.path              paths to scan if not current directory
@param   args.recurse           recurse into subdirectories when looking for bagfiles
@param   args.orderby           "topic" or "type" if any to group results by
@param   args.decompress        decompress archived bags to file directory
@param   args.reindex           make a copy of unindexed bags and reindex them (ROS1 only)
@param   args.timescale         emit messages on original timeline from first message
                                at given rate, 0 disables
@param   args.timescale_emission
                                timeline from first matched message not first in bag,
                                requires notify() for each message
@param   args.write             outputs, to skip in input files
@param   args.bag               one or more {@link grepros.api.Bag Bag} instances
<!--sep-->

General arguments:
@param   args.topic             ROS topics to read if not all
@param   args.type              ROS message types to read if not all
@param   args.skip_topic        ROS topics to skip
@param   args.skip_type         ROS message types to skip
@param   args.start_time        earliest timestamp of messages to read
@param   args.end_time          latest timestamp of messages to read
@param   args.start_index       message index within topic to start from
@param   args.end_index         message index within topic to stop at
@param   args.unique            emit messages that are unique in topic
@param   args.select_field      message fields to use for uniqueness if not all
@param   args.noselect_field    message fields to skip for uniqueness
@param   args.nth_message       read every Nth message in topic, starting from first
@param   args.nth_interval      minimum time interval between messages in topic,
                                as seconds or ROS duration
@param   args.condition         Python expressions that must evaluate as true
                                for message to be processable, see ConditionMixin
@param   args.progress          whether to print progress bar
@param   args.stop_on_error     stop execution on any error like unknown message type
@param   args.verbose           whether to print error stacktraces
@param   kwargs                 any and all arguments as keyword overrides, case-insensitive

Reimplemented from Source.

Definition at line 532 of file inputs.py.

Member Function Documentation

◆ close()

close (   self)
Closes current bag, if any.

Reimplemented from Source.

Definition at line 668 of file inputs.py.

◆ close_batch()

close_batch (   self)
Closes current bag, if any.

Reimplemented from Source.

Definition at line 675 of file inputs.py.

◆ configure()

configure (   self,
  args = None,
**  kwargs 
)
Updates source configuration.

@param   args    arguments as namespace or dictionary, case-insensitive
@param   kwargs  any and all arguments as keyword overrides, case-insensitive

Reimplemented from Source.

Definition at line 630 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 691 of file inputs.py.

◆ format_meta()

format_meta (   self)
Returns bagfile metainfo string.

Reimplemented from Source.

Definition at line 687 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 697 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 724 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 729 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 715 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 734 of file inputs.py.

◆ get_meta()

get_meta (   self)
Returns bagfile metainfo data dict.

Reimplemented from Source.

Definition at line 701 of file inputs.py.

◆ init_progress()

init_progress (   self)
Initializes progress bar, if any, for current bag.

Reimplemented from Source.

Definition at line 770 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 749 of file inputs.py.

◆ notify()

notify (   self,
  status 
)
Reports match status of last produced message.

Reimplemented from Source.

Definition at line 739 of file inputs.py.

◆ read()

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

Reimplemented from Source.

Definition at line 598 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 640 of file inputs.py.

Member Data Documentation

◆ bar

bar

Definition at line 682 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 526 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 518 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 521 of file inputs.py.

◆ topics

topics

Definition at line 798 of file inputs.py.

◆ valid

valid

Definition at line 643 of file inputs.py.


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