Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
grepros.inputs.TopicSource Class Reference
Inheritance diagram for grepros.inputs.TopicSource:
Inheritance graph
[legend]

Public Member Functions

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

Public Attributes

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

Static Public Attributes

 DEFAULT_ARGS
 Constructor argument defaults. More...
 
int MASTER_INTERVAL = 2
 Seconds between refreshing available topics from ROS master. More...
 
- Static Public Attributes inherited from grepros.inputs.Source
 DEFAULT_ARGS
 Constructor argument defaults. More...
 
string MESSAGE_META_TEMPLATE = "{topic} #{index} ({type} {dt} {stamp})"
 Template for message metainfo line. More...
 
- Static Public Attributes inherited from grepros.inputs.ConditionMixin
 DEFAULT_ARGS = dict(CONDITION=())
 Constructor argument defaults. More...
 
 TOPIC_RGX = re.compile(r"<topic\s+([^\s><]+)\s*>")
 

Private Member Functions

def _configure (self)
 
def _init_progress (self)
 
def _on_message (self, topic, msg)
 
def _run_refresh (self)
 
def _update_progress (self, count, running=True)
 

Private Attributes

 _queue
 
 _running
 
 _subs
 

Detailed Description

Produces messages from live ROS topics.

Definition at line 806 of file inputs.py.

Constructor & Destructor Documentation

◆ __init__()

def grepros.inputs.TopicSource.__init__ (   self,
  args = None,
**  kwargs 
)
@param   args                   arguments as namespace or dictionary, case-insensitive
@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
@param   args.nth_interval      minimum time interval between messages in topic
@param   args.condition         Python expressions that must evaluate as true
                        for message to be processable, see ConditionMixin
@param   args.queue_size_in     subscriber queue size (default 10)
@param   args.ros_time_in       stamp messages with ROS time instead of wall time
@param   args.progress          whether to print progress bar
@param   args.stop_on_error     stop execution on any error like unknown message type
@param   kwargs                 any and all arguments as keyword overrides, case-insensitive

Reimplemented from grepros.inputs.Source.

Definition at line 817 of file inputs.py.

Member Function Documentation

◆ _configure()

def grepros.inputs.TopicSource._configure (   self)
private
Adjusts start/end time filter values to current time.

Definition at line 1002 of file inputs.py.

◆ _init_progress()

def grepros.inputs.TopicSource._init_progress (   self)
private
Initializes progress bar, if any.

Definition at line 986 of file inputs.py.

◆ _on_message()

def grepros.inputs.TopicSource._on_message (   self,
  topic,
  msg 
)
private
Subscription callback handler, queues message for yielding.

Definition at line 1017 of file inputs.py.

◆ _run_refresh()

def grepros.inputs.TopicSource._run_refresh (   self)
private
Periodically refreshes topics and subscriptions from ROS live.

Definition at line 1009 of file inputs.py.

◆ _update_progress()

def grepros.inputs.TopicSource._update_progress (   self,
  count,
  running = True 
)
private
Updates progress bar, if any.

Definition at line 993 of file inputs.py.

◆ bind()

def grepros.inputs.TopicSource.bind (   self,
  sink 
)
Attaches sink to source and blocks until connected to ROS live.

Reimplemented from grepros.inputs.Source.

Definition at line 882 of file inputs.py.

◆ close()

def grepros.inputs.TopicSource.close (   self)
Shuts down subscribers and stops producing messages.

Reimplemented from grepros.inputs.Source.

Definition at line 893 of file inputs.py.

◆ format_meta()

def grepros.inputs.TopicSource.format_meta (   self)
Returns source metainfo string.

Reimplemented from grepros.inputs.Source.

Definition at line 936 of file inputs.py.

◆ get_message_class()

def grepros.inputs.TopicSource.get_message_class (   self,
  typename,
  typehash = None 
)
Returns message type class, from active subscription if available.

Reimplemented from grepros.inputs.Source.

Definition at line 916 of file inputs.py.

◆ get_message_definition()

def grepros.inputs.TopicSource.get_message_definition (   self,
  msg_or_type 
)
Returns ROS message type definition full text, including subtype definitions.

Reimplemented from grepros.inputs.Source.

Definition at line 922 of file inputs.py.

◆ get_message_meta()

def grepros.inputs.TopicSource.get_message_meta (   self,
  topic,
  msg,
  stamp,
  index = None 
)
Returns message metainfo data dict.

Reimplemented from grepros.inputs.Source.

Definition at line 908 of file inputs.py.

◆ get_message_type_hash()

def grepros.inputs.TopicSource.get_message_type_hash (   self,
  msg_or_type 
)
Returns ROS message type MD5 hash.

Reimplemented from grepros.inputs.Source.

Definition at line 929 of file inputs.py.

◆ get_meta()

def grepros.inputs.TopicSource.get_meta (   self)
Returns source metainfo data dict.

Reimplemented from grepros.inputs.Source.

Definition at line 903 of file inputs.py.

◆ is_processable()

def grepros.inputs.TopicSource.is_processable (   self,
  topic,
  msg,
  stamp,
  index = None 
)
Returns whether message passes source filters.

Reimplemented from grepros.inputs.Source.

Definition at line 947 of file inputs.py.

◆ read()

def grepros.inputs.TopicSource.read (   self)
Yields messages from subscribed ROS topics, as (topic, msg, ROS time).

Reimplemented from grepros.inputs.Source.

Definition at line 850 of file inputs.py.

◆ refresh_topics()

def grepros.inputs.TopicSource.refresh_topics (   self)
Refreshes topics and subscriptions from ROS live.

Definition at line 959 of file inputs.py.

◆ validate()

def grepros.inputs.TopicSource.validate (   self)
Returns whether ROS environment is set, prints error if not.

Reimplemented from grepros.inputs.Source.

Definition at line 888 of file inputs.py.

Member Data Documentation

◆ _queue

grepros.inputs.TopicSource._queue
private

Definition at line 845 of file inputs.py.

◆ _running

grepros.inputs.TopicSource._running
private

Definition at line 844 of file inputs.py.

◆ _subs

grepros.inputs.TopicSource._subs
private

Definition at line 846 of file inputs.py.

◆ bar

grepros.inputs.TopicSource.bar

Definition at line 989 of file inputs.py.

◆ DEFAULT_ARGS

grepros.inputs.TopicSource.DEFAULT_ARGS
static
Initial value:
= dict(TOPIC=(), TYPE=(), SKIP_TOPIC=(), SKIP_TYPE=(), START_TIME=None,
END_TIME=None, START_INDEX=None, END_INDEX=None, CONDITION=(),
QUEUE_SIZE_IN=10, ROS_TIME_IN=False, PROGRESS=False, STOP_ON_ERROR=False)

Constructor argument defaults.

Definition at line 813 of file inputs.py.

◆ MASTER_INTERVAL

int grepros.inputs.TopicSource.MASTER_INTERVAL = 2
static

Seconds between refreshing available topics from ROS master.

Definition at line 810 of file inputs.py.

◆ valid

grepros.inputs.TopicSource.valid

Definition at line 890 of file inputs.py.


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


grepros
Author(s): Erki Suurjaak
autogenerated on Sat Jan 6 2024 03:11:30