diff --git a/ROSBRIDGE_PROTOCOL.md b/ROSBRIDGE_PROTOCOL.md index e58850d61..4a7e82468 100644 --- a/ROSBRIDGE_PROTOCOL.md +++ b/ROSBRIDGE_PROTOCOL.md @@ -93,12 +93,12 @@ ROS operations: * **call_service** - a service call * **service_response** - a service response * Actions: - * **advertise_action** - advertise an external action server - * **unadvertise_action** - unadvertise an external action server - * **send_action_goal** - a goal sent to an action server - * **cancel_action_goal** - cancel an in-progress action goal - * **action_feedback** - feedback messages from an action server - * **action_result** - an action result + * **advertise_action** - advertise an external action server + * **unadvertise_action** - unadvertise an external action server + * **send_action_goal** - a goal sent to an action server + * **cancel_action_goal** - cancel an in-progress action goal + * **action_feedback** - feedback messages from an action server + * **action_result** - an action result In general, actions or operations that the client takes (such as publishing and subscribing) have opcodes which are verbs (subscribe, call_service, unadvertise diff --git a/rosbridge_library/src/rosbridge_library/internal/subscribers.py b/rosbridge_library/src/rosbridge_library/internal/subscribers.py index 0bb94a809..a64c90b7f 100644 --- a/rosbridge_library/src/rosbridge_library/internal/subscribers.py +++ b/rosbridge_library/src/rosbridge_library/internal/subscribers.py @@ -176,6 +176,11 @@ def subscribe(self, client_id, callback): # In any case, the first message is handled using new_sub_callback, # which adds the new callback to the subscriptions dictionary. self.new_subscriptions.update({client_id: callback}) + infos = self.node_handle.get_publishers_info_by_topic(self.topic) + if any(pub.qos_profile.durability == DurabilityPolicy.TRANSIENT_LOCAL for pub in infos): + self.qos.durability = DurabilityPolicy.TRANSIENT_LOCAL + if any(pub.qos_profile.reliability == ReliabilityPolicy.BEST_EFFORT for pub in infos): + self.qos.reliability = ReliabilityPolicy.BEST_EFFORT if self.new_subscriber is None: self.new_subscriber = self.node_handle.create_subscription( self.msg_class, @@ -196,7 +201,7 @@ def unsubscribe(self, client_id): with self.rlock: if client_id in self.new_subscriptions: del self.new_subscriptions[client_id] - else: + if client_id in self.subscriptions: del self.subscriptions[client_id] def has_subscribers(self):