Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queue size parameter #150

Open
wants to merge 1 commit into
base: dev-ros
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/ros_tcp_endpoint/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class SysCommands:
def __init__(self, tcp_server):
self.tcp_server = tcp_server

def subscribe(self, topic, message_name):
def subscribe(self, topic, message_name, queue_size=10):
if topic == "":
self.tcp_server.send_unity_error(
"Can't subscribe to a blank topic name! SysCommand.subscribe({}, {})".format(
Expand All @@ -155,10 +155,10 @@ def subscribe(self, topic, message_name):
if old_node is not None:
self.tcp_server.unregister_node(old_node)

new_subscriber = RosSubscriber(topic, message_class, self.tcp_server)
new_subscriber = RosSubscriber(topic, message_class, self.tcp_server, queue_size)
self.tcp_server.subscribers_table[topic] = new_subscriber

self.tcp_server.loginfo("RegisterSubscriber({}, {}) OK".format(topic, message_class))
self.tcp_server.loginfo("RegisterSubscriber({}, {}, queue {}) OK".format(topic, message_class, queue_size))

def publish(self, topic, message_name, queue_size=10, latch=False):
if topic == "":
Expand All @@ -184,7 +184,11 @@ def publish(self, topic, message_name, queue_size=10, latch=False):

self.tcp_server.publishers_table[topic] = new_publisher

self.tcp_server.loginfo("RegisterPublisher({}, {}) OK".format(topic, message_class))
if latch:
latched_text = "latched"
else:
latched_text = "unlatched"
self.tcp_server.loginfo("RegisterPublisher({}, {}, queue {}, {}) OK".format(topic, message_class, queue_size, latched_text))

def ros_service(self, topic, message_name):
if topic == "":
Expand Down
2 changes: 1 addition & 1 deletion src/ros_tcp_endpoint/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, topic, message_class, tcp_server, queue_size=10):
self.queue_size = queue_size

# Start Subscriber listener function
self.sub = rospy.Subscriber(self.topic, self.msg, self.send)
self.sub = rospy.Subscriber(self.topic, self.msg, self.send, queue_size=queue_size)

def send(self, data):
"""
Expand Down