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

Message producer base class. More...

Inheritance diagram for Source:
Inheritance graph

Classes

class  SourceMessage
 Returned from read() as (topic name, ROS message, ROS timestamp object). More...
 

Public Member Functions

 __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 Attributes

 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()
 

Static Public Attributes

 DEFAULT_ARGS
 Constructor argument defaults.
 
str MESSAGE_META_TEMPLATE = "{topic} #{index} ({type} {dt} {stamp})"
 Template for message metainfo line.
 

Detailed Description

Message producer base class.

Definition at line 35 of file inputs.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  args = None,
**  kwargs 
)
Parameters
argsarguments as namespace or dictionary, case-insensitive
args.start_timeearliest timestamp of messages to read
args.end_timelatest timestamp of messages to read
args.uniqueemit messages that are unique in topic
args.start_indexmessage index within topic to start from
args.end_indexmessage index within topic to stop at
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.progresswhether to print progress bar
kwargsany and all arguments as keyword overrides, case-insensitive

Reimplemented in BagSource, LiveSource, and AppSource.

Definition at line 65 of file inputs.py.

Member Function Documentation

◆ __enter__()

__enter__ (   self)

Context manager entry.

Definition at line 97 of file inputs.py.

◆ __exit__()

__exit__ (   self,
  exc_type,
  exc_value,
  traceback 
)

Context manager exit, closes source.

Definition at line 101 of file inputs.py.

◆ __iter__()

__iter__ (   self)

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

Definition at line 93 of file inputs.py.

◆ bind()

bind (   self,
  sink 
)

Attaches sink to source.

Reimplemented in LiveSource.

Definition at line 109 of file inputs.py.

◆ close()

close (   self)

Shuts down input, closing any files or connections.

Reimplemented in BagSource, LiveSource, and AppSource.

Definition at line 129 of file inputs.py.

◆ close_batch()

close_batch (   self)

Shuts down input batch if any (like bagfile), else all input.

Reimplemented in BagSource.

Definition at line 142 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 in BagSource.

Definition at line 118 of file inputs.py.

◆ configure_progress()

configure_progress (   self,
**  kwargs 
)

Configures progress bar options, updates current bar if any.

Definition at line 221 of file inputs.py.

◆ format_message_meta()

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

Returns message metainfo string.

Reimplemented in BagSource.

Definition at line 150 of file inputs.py.

◆ format_meta()

format_meta (   self)

Returns source metainfo string.

Reimplemented in BagSource, and LiveSource.

Definition at line 146 of file inputs.py.

◆ get_batch()

get_batch (   self)

Returns source batch identifier if any (like bagfile name if BagSource).

Reimplemented in BagSource.

Definition at line 156 of file inputs.py.

◆ get_message_class()

get_message_class (   self,
  typename,
  typehash = None 
)

Returns message type class.

Reimplemented in BagSource, and LiveSource.

Definition at line 170 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 in BagSource, and LiveSource.

Definition at line 174 of file inputs.py.

◆ get_message_meta()

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

Returns message metainfo data dict.

Reimplemented in BagSource, and LiveSource.

Definition at line 163 of file inputs.py.

◆ get_message_type_hash()

get_message_type_hash (   self,
  msg_or_type 
)

Returns ROS message type MD5 hash.

Reimplemented in BagSource, and LiveSource.

Definition at line 178 of file inputs.py.

◆ get_meta()

get_meta (   self)

Returns source metainfo data dict.

Reimplemented in BagSource, and LiveSource.

Definition at line 160 of file inputs.py.

◆ init_progress()

init_progress (   self)

Initializes progress bar, if any.

Reimplemented in BagSource, and LiveSource.

Definition at line 233 of file inputs.py.

◆ is_processable()

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

Returns whether message passes source filters; registers status.

Reimplemented in BagSource, LiveSource, and AppSource.

Definition at line 182 of file inputs.py.

◆ notify()

notify (   self,
  status 
)

Reports match status of last produced message.

Reimplemented in BagSource.

Definition at line 215 of file inputs.py.

◆ read()

read (   self)

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

Reimplemented in BagSource, LiveSource, and AppSource.

Definition at line 105 of file inputs.py.

◆ thread_excepthook()

thread_excepthook (   self,
  text,
  exc 
)

Handles exception, used by background threads.

Definition at line 248 of file inputs.py.

◆ update_progress()

update_progress (   self,
  count,
  running = True 
)

Updates progress bar, if any, with source processed count, pauses bar if not running.

Reimplemented in LiveSource.

Definition at line 239 of file inputs.py.

◆ validate()

validate (   self)

Returns whether arguments are valid and source prerequisites are met.

Reimplemented in BagSource, LiveSource, and AppSource.

Definition at line 122 of file inputs.py.

Member Data Documentation

◆ args

args

Definition at line 79 of file inputs.py.

◆ bar

bar

ProgressBar instance, if any.

Definition at line 85 of file inputs.py.

◆ DEFAULT_ARGS

DEFAULT_ARGS
static
Initial value:
= dict(START_TIME=None, END_TIME=None, START_INDEX=None, END_INDEX=None,
UNIQUE=False, SELECT_FIELD=(), NOSELECT_FIELD=(),
NTH_MESSAGE=1, NTH_INTERVAL=0, PROGRESS=False)

Constructor argument defaults.

Definition at line 45 of file inputs.py.

◆ MESSAGE_META_TEMPLATE

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

Template for message metainfo line.

Definition at line 42 of file inputs.py.

◆ preprocess

preprocess

Apply all filter arguments when reading, not only topic and type.

Definition at line 89 of file inputs.py.

◆ sink

sink

outputs.Sink instance bound to this source

Definition at line 81 of file inputs.py.

◆ topics

topics

All topics in source, as {(topic, typenane, typehash): total message count or None}.

Definition at line 83 of file inputs.py.

◆ valid

valid

Result of validate()

Definition at line 87 of file inputs.py.


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