Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(
topic: str,
publish: Callable[[OutgoingMessage[ROSMessageT], int | None, str], None] | None,
node_handle: Node,
qos_depth: int = 10,
) -> None:
"""
Create a subscription.
Expand All @@ -92,6 +93,7 @@ def __init__(
self.topic = topic
self.publish = publish
self.node_handle = node_handle
self.subscriber_qos_depth = qos_depth

self.clients = {}

Expand Down Expand Up @@ -156,6 +158,7 @@ def subscribe(
self.node_handle,
msg_type=msg_type,
raw=raw,
qos_depth=self.subscriber_qos_depth,
)

def unsubscribe(self, sid: str | None = None) -> None:
Expand Down Expand Up @@ -248,9 +251,10 @@ class Subscribe(Capability):
)
unsubscribe_msg_fields = ((True, "topic", str),)

parameter_names = ("topics_glob",)
parameter_names = ("topics_glob", "subscriber_qos_depth")

topics_glob: list[str] | None = None
subscriber_qos_depth: int = 10

def __init__(self, protocol: Protocol) -> None:
# Call superclass constructor
Expand Down Expand Up @@ -296,7 +300,7 @@ def subscribe(self, msg: dict[str, Any]) -> None:
client_id = self.protocol.client_id
cb = partial(self.publish, topic)
self._subscriptions[topic] = Subscription(
client_id, topic, cb, self.protocol.node_handle
client_id, topic, cb, self.protocol.node_handle, qos_depth=self.subscriber_qos_depth
)

# Register the subscriber
Expand Down
12 changes: 10 additions & 2 deletions rosbridge_library/src/rosbridge_library/internal/subscribers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(
node_handle: Node,
msg_type: str | None = None,
raw: bool = False,
qos_depth: int = 10,
) -> None:
"""
Register a subscriber on the specified topic.
Expand Down Expand Up @@ -135,7 +136,7 @@ def __init__(
# - https://github.com/RobotWebTools/rosbridge_suite/issues/551
# - https://github.com/RobotWebTools/rosbridge_suite/issues/769
qos = QoSProfile(
depth=10,
depth=qos_depth,
durability=DurabilityPolicy.VOLATILE,
reliability=ReliabilityPolicy.BEST_EFFORT,
)
Expand Down Expand Up @@ -304,6 +305,7 @@ def subscribe(
node_handle: Node,
msg_type: str | None = None,
raw: bool = False,
qos_depth: int = 10,
) -> None:
"""
Subscribe to a topic.
Expand All @@ -316,7 +318,13 @@ def subscribe(
with self._lock:
if topic not in self._subscribers:
self._subscribers[topic] = MultiSubscriber(
topic, client_id, callback, node_handle, msg_type=msg_type, raw=raw
topic,
client_id,
callback,
node_handle,
msg_type=msg_type,
raw=raw,
qos_depth=qos_depth,
)
else:
self._subscribers[topic].subscribe(client_id, callback)
Expand Down
3 changes: 3 additions & 0 deletions rosbridge_server/launch/rosbridge_websocket_launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<arg name="services_glob" default="" />
<arg name="params_glob" default="" />
<arg name="params_timeout" default="5.0" />
<arg name="subscriber_qos_depth" default="10" />

<arg name="respawn" default="false"/>

Expand All @@ -53,6 +54,7 @@
<param name="topics_glob" value="$(var topics_glob)"/>
<param name="services_glob" value="$(var services_glob)"/>
<param name="params_glob" value="$(var params_glob)"/>
<param name="subscriber_qos_depth" value="$(var subscriber_qos_depth)"/>
</node>
</group>

Expand All @@ -77,6 +79,7 @@
<param name="topics_glob" value="$(var topics_glob)"/>
<param name="services_glob" value="$(var services_glob)"/>
<param name="params_glob" value="$(var params_glob)"/>
<param name="subscriber_qos_depth" value="$(var subscriber_qos_depth)"/>
</node>
</group>

Expand Down
1 change: 1 addition & 0 deletions rosbridge_server/scripts/rosbridge_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
("call_services_in_new_thread", bool, True, "Call services in a new threads."),
("default_call_service_timeout", float, 5.0, "Default timeout for service calls."),
("send_action_goals_in_new_thread", bool, True, "Send action goals in a new threads."),
("subscriber_qos_depth", int, 10, "Default QoS queue depth for topic subscriptions."),
)


Expand Down
Loading