From 2924aaa11c64dfe00019eb4b4f1ca913f206b8e3 Mon Sep 17 00:00:00 2001 From: Sebastian Castro <4603398+sea-bass@users.noreply.github.com> Date: Mon, 7 Oct 2024 07:17:14 -0400 Subject: [PATCH 1/6] rosapi: Don't start parameter services that aren't spun (backport #944) (#956) Co-authored-by: Brad Martin <52003535+bmartin427@users.noreply.github.com> --- rosapi/src/rosapi/params.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rosapi/src/rosapi/params.py b/rosapi/src/rosapi/params.py index 99cc5d01b..1d89e57e0 100644 --- a/rosapi/src/rosapi/params.py +++ b/rosapi/src/rosapi/params.py @@ -74,7 +74,9 @@ def init(parent_node_name): parent_node_basename = parent_node_name.split("/")[-1] param_node_name = f"{parent_node_basename}_params" _node = rclpy.create_node( - param_node_name, cli_args=["--ros-args", "-r", f"__node:={param_node_name}"] + param_node_name, + cli_args=["--ros-args", "-r", f"__node:={param_node_name}"], + start_parameter_services=False, ) _parent_node_name = get_absolute_node_name(parent_node_name) From 1e82edcd87c2c37061964d858498b0d844e2640c Mon Sep 17 00:00:00 2001 From: Sebastian Castro <4603398+sea-bass@users.noreply.github.com> Date: Mon, 7 Oct 2024 07:18:56 -0400 Subject: [PATCH 2/6] rosbridge_websocket: Stop websocket server if ROS shuts down (backport #946) (#957) Signed-off-by: Brad Martin Co-authored-by: Brad Martin <52003535+bmartin427@users.noreply.github.com> --- rosbridge_server/scripts/rosbridge_websocket.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rosbridge_server/scripts/rosbridge_websocket.py b/rosbridge_server/scripts/rosbridge_websocket.py index bfa968d15..49d2a52b6 100755 --- a/rosbridge_server/scripts/rosbridge_websocket.py +++ b/rosbridge_server/scripts/rosbridge_websocket.py @@ -337,7 +337,13 @@ def main(args=None): executor = rclpy.executors.SingleThreadedExecutor() executor.add_node(node) - spin_callback = PeriodicCallback(lambda: executor.spin_once(timeout_sec=0.01), 1) + + def spin_ros(): + executor.spin_once(timeout_sec=0.01) + if not rclpy.ok(): + shutdown_hook() + + spin_callback = PeriodicCallback(spin_ros, 1) spin_callback.start() try: start_hook() From db8575a802b4ac6fd7be35752169c8eed0e8f3c6 Mon Sep 17 00:00:00 2001 From: Sebastian Castro <4603398+sea-bass@users.noreply.github.com> Date: Mon, 7 Oct 2024 07:19:26 -0400 Subject: [PATCH 3/6] Avoid stale subscription when unsubscribing during resubscription (backport #948) (#958) If a client asks to subscribe to the same topic more than once, then disconnects, only a pending 'new' subscription may get deleted, leaving the 'old' subscription active indefinitely. Signed-off-by: Brad Martin Co-authored-by: Brad Martin <52003535+bmartin427@users.noreply.github.com> --- rosbridge_library/src/rosbridge_library/internal/subscribers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosbridge_library/src/rosbridge_library/internal/subscribers.py b/rosbridge_library/src/rosbridge_library/internal/subscribers.py index 0bb94a809..c698c0b79 100644 --- a/rosbridge_library/src/rosbridge_library/internal/subscribers.py +++ b/rosbridge_library/src/rosbridge_library/internal/subscribers.py @@ -196,7 +196,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): From 144a5402bed290a6929fbdd6abbac75cdabf79ed Mon Sep 17 00:00:00 2001 From: Sebastian Castro <4603398+sea-bass@users.noreply.github.com> Date: Mon, 7 Oct 2024 07:19:49 -0400 Subject: [PATCH 4/6] docs: update ROSBRIDGE_PROTOCOL.md - correcting indentation (backport #949) (#959) Add whitespace in front of all ROS action operations -- for correct indentation in Markdown Co-authored-by: ManuETR <37251724+ManuETR@users.noreply.github.com> --- ROSBRIDGE_PROTOCOL.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 From a3fc252da757101da54f381426a9dd304a675cd0 Mon Sep 17 00:00:00 2001 From: Sebastian Castro <4603398+sea-bass@users.noreply.github.com> Date: Mon, 7 Oct 2024 07:20:11 -0400 Subject: [PATCH 5/6] fix: update new subs with dds from publisher (backport #940) (#960) Co-authored-by: Dimitri Nikitopoulos --- .../src/rosbridge_library/internal/subscribers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rosbridge_library/src/rosbridge_library/internal/subscribers.py b/rosbridge_library/src/rosbridge_library/internal/subscribers.py index c698c0b79..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, From 3ad97781b1259a4294d7ffc47740e3aec3256707 Mon Sep 17 00:00:00 2001 From: Sebastian Castro <4603398+sea-bass@users.noreply.github.com> Date: Mon, 7 Oct 2024 07:20:27 -0400 Subject: [PATCH 6/6] Update pre-commit and fix issues (backport #954) (#961) --- .pre-commit-config.yaml | 12 ++++++------ .../capabilities/advertise_action.py | 2 +- .../capabilities/advertise_service.py | 2 +- .../src/rosbridge_library/capability.py | 2 +- rosbridge_library/src/rosbridge_library/protocol.py | 1 - .../test_non-ros_service_client_complex-srv.py | 2 +- .../test/internal/publishers/test_multi_publisher.py | 4 ++-- rosbridge_server/CHANGELOG.rst | 2 +- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9af419349..ead1b8c64 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ # See https://pre-commit.com for more information repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.6.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -16,27 +16,27 @@ repos: - id: trailing-whitespace - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 24.8.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 3.9.2 + rev: 7.1.1 hooks: - id: flake8 - repo: https://github.com/PyCQA/bandit - rev: 1.7.0 + rev: 1.7.10 hooks: - id: bandit args: ["--skip", "B101,B110,B311"] - repo: https://github.com/codespell-project/codespell - rev: v2.1.0 + rev: v2.3.0 hooks: - id: codespell diff --git a/rosbridge_library/src/rosbridge_library/capabilities/advertise_action.py b/rosbridge_library/src/rosbridge_library/capabilities/advertise_action.py index 1478a3b24..ffb9eb1cb 100644 --- a/rosbridge_library/src/rosbridge_library/capabilities/advertise_action.py +++ b/rosbridge_library/src/rosbridge_library/capabilities/advertise_action.py @@ -77,7 +77,7 @@ async def execute_callback(self, goal: Any) -> Any: # generate a unique ID goal_id = f"action_goal:{self.action_name}:{self.next_id()}" - def done_callback(fut: rclpy.task.Future()) -> None: + def done_callback(fut: rclpy.task.Future) -> None: if fut.cancelled(): goal.abort() self.protocol.log("info", f"Aborted goal {goal_id}") diff --git a/rosbridge_library/src/rosbridge_library/capabilities/advertise_service.py b/rosbridge_library/src/rosbridge_library/capabilities/advertise_service.py index 62a390836..2664c79a3 100644 --- a/rosbridge_library/src/rosbridge_library/capabilities/advertise_service.py +++ b/rosbridge_library/src/rosbridge_library/capabilities/advertise_service.py @@ -31,7 +31,7 @@ def next_id(self): async def handle_request(self, req, res): # generate a unique ID - request_id = f"service_request:{self.service_name }:{self.next_id()}" + request_id = f"service_request:{self.service_name}:{self.next_id()}" future = rclpy.task.Future() self.request_futures[request_id] = future diff --git a/rosbridge_library/src/rosbridge_library/capability.py b/rosbridge_library/src/rosbridge_library/capability.py index 785b17914..2ab6d4dc7 100644 --- a/rosbridge_library/src/rosbridge_library/capability.py +++ b/rosbridge_library/src/rosbridge_library/capability.py @@ -79,7 +79,7 @@ def basic_type_check(self, msg, types_info): """Performs basic typechecking on fields in msg. Keyword arguments: - msg -- a message, deserialized into a dictoinary + msg -- a message, deserialized into a dictionary types_info -- a list of tuples (mandatory, fieldname, fieldtype) where mandatory - boolean, is the field mandatory fieldname - the name of the field in the message diff --git a/rosbridge_library/src/rosbridge_library/protocol.py b/rosbridge_library/src/rosbridge_library/protocol.py index c3a2f418d..9d91076c9 100644 --- a/rosbridge_library/src/rosbridge_library/protocol.py +++ b/rosbridge_library/src/rosbridge_library/protocol.py @@ -311,7 +311,6 @@ def serialize(self, msg, cid=None): return None def deserialize(self, msg, cid=None): - """Turns the wire-level representation into a dictionary of values Default behaviour assumes JSON. Override to use a different container. diff --git a/rosbridge_library/test/experimental/complex_srv+tcp/test_non-ros_service_client_complex-srv.py b/rosbridge_library/test/experimental/complex_srv+tcp/test_non-ros_service_client_complex-srv.py index 673c3164a..eefc39f27 100755 --- a/rosbridge_library/test/experimental/complex_srv+tcp/test_non-ros_service_client_complex-srv.py +++ b/rosbridge_library/test/experimental/complex_srv+tcp/test_non-ros_service_client_complex-srv.py @@ -35,7 +35,7 @@ def request_service(): "position": {"y": 0.0, "x": 0.0, "z": 0.0}, "orientation": {"y": 0.0, "x": 0.0, "z": 0.0, "w": 0.0}, } - } + }, # "count" : request_byte_count # count is the parameter for send_bytes as defined in srv-file (always put into args field!) } service_request = json.dumps(service_request_object) diff --git a/rosbridge_library/test/internal/publishers/test_multi_publisher.py b/rosbridge_library/test/internal/publishers/test_multi_publisher.py index 01b1f8295..62e96cbcf 100755 --- a/rosbridge_library/test/internal/publishers/test_multi_publisher.py +++ b/rosbridge_library/test/internal/publishers/test_multi_publisher.py @@ -109,7 +109,7 @@ def test_publish(self): """Make sure that publishing works""" topic = "/test_publish" msg_type = "std_msgs/String" - msg = {"data": "why halo thar"} + msg = {"data": "why hello there"} received = {"msg": None} @@ -133,7 +133,7 @@ def test_publish_twice(self): """Make sure that publishing works""" topic = "/test_publish_twice" msg_type = "std_msgs/String" - msg = {"data": "why halo thar"} + msg = {"data": "why hello there"} received = {"msg": None} diff --git a/rosbridge_server/CHANGELOG.rst b/rosbridge_server/CHANGELOG.rst index fb0938382..c74a37fd9 100644 --- a/rosbridge_server/CHANGELOG.rst +++ b/rosbridge_server/CHANGELOG.rst @@ -486,7 +486,7 @@ Changelog for package rosbridge_server * merging changes of groovy-devel into hydro-devel * Specific IP address binding using roslauch * added parameter lookup to rosbridge_tcp.py, modules where those are used, and default parameters to launch file; internal default-values still get used when launch-file does not provide them; internal defaults can be changed within rosbridge_tcp.py -* increaing max_msg_length - still hardcoded +* increasing max_msg_length - still hardcoded * preparing pull request for upstream.. * cleanup: files, notes, some code * cleanup tcp-server