|
Ark
|
A subscriber for listening to messages on a communication channel. More...
Public Member Functions | |
| None | __init__ (self, LCM lcm, str channel_name, type channel_type, Callable[[int, str, object], None] callback, list[object] callback_args=[]) |
| Initializes the subscriber with the necessary parameters for subscribing to a communication channel and setting up the callback function. | |
| None | subscriber_callback (self, str channel_name, bytes data) |
| Callback function to handle incoming messages on the subscribed channel. | |
| subscribe (self) | |
| Subscribe to the configured channel. | |
| restart (self) | |
| Reconnect the subscriber to its channel. | |
| None | suspend (self) |
| Suspends the subscriber by unsubscribing from the communication channel. | |
| get_info (self) | |
| Return a dictionary describing this subscriber. | |
| Public Member Functions inherited from comm_handler.comm_handler.CommHandler | |
| __init__ (self, LCM lcm, str channel_name, type channel_type) | |
| Initializes the communication handler with an LCM instance, a channel name, and a channel type. | |
| str | __repr__ (self) |
| Returns a string representation of the communication handler, showing the channel name and the type of message it handles. | |
Public Attributes | |
| str | comm_type = "Subscriber" |
| Public Attributes inherited from comm_handler.comm_handler.CommHandler | |
| str | channel_name = channel_name |
| type | channel_type = channel_type |
| bool | active = True |
Protected Attributes | |
| Callable[[int, str, object], None] | _user_callback = callback |
| list[object] | _callback_args = callback_args |
| _sub = self._lcm.subscribe(self.channel_name, self.subscriber_callback) | |
| Protected Attributes inherited from comm_handler.comm_handler.CommHandler | |
| LCM | _lcm = lcm |
| Initializes the communication handler with an LCM instance, a channel name, and a channel type. | |
A subscriber for listening to messages on a communication channel.
This class subscribes to a specified communication channel and calls a user-defined callback function whenever a new message is received. The message data is passed to the callback along with the timestamp and channel name.
| None comm_handler.subscriber.Subscriber.__init__ | ( | self, | |
| LCM | lcm, | ||
| str | channel_name, | ||
| type | channel_type, | ||
| Callable[[int, str, object], None] | callback, | ||
| list[object] | callback_args = [] ) |
Initializes the subscriber with the necessary parameters for subscribing to a communication channel and setting up the callback function.
| lcm | The LCM instance used for communication. |
| channel_name | The name of the communication channel. |
| channel_type | The type of the message expected for this communication channel. |
| callback | The user-defined callback function to be called with the message data. |
| callback_args | Additional arguments to be passed to the callback function. |
| comm_handler.subscriber.Subscriber.get_info | ( | self | ) |
Return a dictionary describing this subscriber.
Reimplemented from comm_handler.comm_handler.CommHandler.
| comm_handler.subscriber.Subscriber.restart | ( | self | ) |
Reconnect the subscriber to its channel.
Reimplemented from comm_handler.comm_handler.CommHandler.
| comm_handler.subscriber.Subscriber.subscribe | ( | self | ) |
Subscribe to the configured channel.
| None comm_handler.subscriber.Subscriber.subscriber_callback | ( | self, | |
| str | channel_name, | ||
| bytes | data ) |
Callback function to handle incoming messages on the subscribed channel.
This method decodes the message data, records the timestamp, and calls the user-defined callback function with the timestamp, channel name, and message.
| channel_name | The name of the communication channel the message was received from. |
| data | The raw byte data of the message. |
| None comm_handler.subscriber.Subscriber.suspend | ( | self | ) |
Suspends the subscriber by unsubscribing from the communication channel.
This method releases the subscription and logs that the subscriber has been unsubscribed.
Reimplemented from comm_handler.comm_handler.CommHandler.
|
protected |
|
protected |
|
protected |
| str comm_handler.subscriber.Subscriber.comm_type = "Subscriber" |