Public Member Functions | Public Attributes | List of all members
rosbridge_library.internal.subscribers.MultiSubscriber Class Reference

Public Member Functions

def __init__ (self, topic, msg_type=None)
 
def callback (self, msg, callbacks=None)
 
def has_subscribers (self)
 
def subscribe (self, client_id, callback)
 
def unregister (self)
 
def unsubscribe (self, client_id)
 
def verify_type (self, msg_type)
 

Public Attributes

 lock
 
 msg_class
 
 subscriber
 
 subscriptions
 
 topic
 

Detailed Description

Handles multiple clients for a single subscriber.

Converts msgs to JSON before handing them to callbacks.  Due to subscriber
callbacks being called in separate threads, must lock whenever modifying
or accessing the subscribed clients. 

Definition at line 48 of file subscribers.py.

Constructor & Destructor Documentation

◆ __init__()

def rosbridge_library.internal.subscribers.MultiSubscriber.__init__ (   self,
  topic,
  msg_type = None 
)
Register a subscriber on the specified topic.

Keyword arguments:
topic    -- the name of the topic to register the subscriber on
msg_type -- (optional) the type to register the subscriber as.  If not
provided, an attempt will be made to infer the topic type

Throws:
TopicNotEstablishedException -- if no msg_type was specified by the
caller and the topic is not yet established, so a topic type cannot
be inferred
TypeConflictException        -- if the msg_type was specified by the
caller and the topic is established, and the established type is
different to the user-specified msg_type

Definition at line 55 of file subscribers.py.

Member Function Documentation

◆ callback()

def rosbridge_library.internal.subscribers.MultiSubscriber.callback (   self,
  msg,
  callbacks = None 
)
Callback for incoming messages on the rospy.Subscriber

Passes the message to registered subscriber callbacks.

Keyword Arguments:
msg - the ROS message coming from the subscriber
callbacks - subscriber callbacks to invoke

Definition at line 154 of file subscribers.py.

◆ has_subscribers()

def rosbridge_library.internal.subscribers.MultiSubscriber.has_subscribers (   self)
Return true if there are subscribers 

Definition at line 149 of file subscribers.py.

◆ subscribe()

def rosbridge_library.internal.subscribers.MultiSubscriber.subscribe (   self,
  client_id,
  callback 
)
Subscribe the specified client to this subscriber.

Keyword arguments:
client_id -- the ID of the client subscribing
callback  -- this client's callback, that will be called for incoming
messages

Definition at line 123 of file subscribers.py.

◆ unregister()

def rosbridge_library.internal.subscribers.MultiSubscriber.unregister (   self)

Definition at line 100 of file subscribers.py.

◆ unsubscribe()

def rosbridge_library.internal.subscribers.MultiSubscriber.unsubscribe (   self,
  client_id 
)
Unsubscribe the specified client from this subscriber

Keyword arguments:
client_id -- the ID of the client to unsubscribe

Definition at line 139 of file subscribers.py.

◆ verify_type()

def rosbridge_library.internal.subscribers.MultiSubscriber.verify_type (   self,
  msg_type 
)
Verify that the subscriber subscribes to messages of this type.

Keyword arguments:
msg_type -- the type to check this subscriber against

Throws:
Exception -- if ros_loader cannot load the specified msg type
TypeConflictException -- if the msg_type is different than the type of
this publisher

Definition at line 105 of file subscribers.py.

Member Data Documentation

◆ lock

rosbridge_library.internal.subscribers.MultiSubscriber.lock

Definition at line 95 of file subscribers.py.

◆ msg_class

rosbridge_library.internal.subscribers.MultiSubscriber.msg_class

Definition at line 97 of file subscribers.py.

◆ subscriber

rosbridge_library.internal.subscribers.MultiSubscriber.subscriber

Definition at line 98 of file subscribers.py.

◆ subscriptions

rosbridge_library.internal.subscribers.MultiSubscriber.subscriptions

Definition at line 94 of file subscribers.py.

◆ topic

rosbridge_library.internal.subscribers.MultiSubscriber.topic

Definition at line 96 of file subscribers.py.


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


rosbridge_library
Author(s): Jonathan Mace
autogenerated on Tue Oct 3 2023 02:12:45