Skip to content

Commit

Permalink
fix(params): prevent parameter retrieval crashes in ROS2
Browse files Browse the repository at this point in the history
- Add check for node's fully qualified name to prevent deadlocks
- Add 2.0s timeout to spin_until_future_complete
- Fix crashes when retrieving parameters via Roslibjs

Fixes #972
  • Loading branch information
Mehsias authored Dec 5, 2024
1 parent 460d202 commit 5d36f77
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rosapi/src/rosapi/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def _get_param_names(node_name):
# This method is called in a service callback; calling a service of the same node
# will cause a deadlock.
global _parent_node_name
if node_name == _parent_node_name:
if node_name == _parent_node_name or node_name == _node.get_fully_qualified_name():
return []

client = _node.create_client(ListParameters, f"{node_name}/list_parameters")
Expand All @@ -238,7 +238,7 @@ def _get_param_names(node_name):
request = ListParameters.Request()
future = client.call_async(request)
if _node.executor:
_node.executor.spin_until_future_complete(future)
_node.executor.spin_until_future_complete(future, timeout_sec=2.0)
else:
rclpy.spin_until_future_complete(_node, future)
response = future.result()
Expand Down

0 comments on commit 5d36f77

Please sign in to comment.