Skip to content

Commit

Permalink
Add parameter for default call_service timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsowa committed Jan 20, 2025
1 parent e31b6a6 commit a045876
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def __init__(self, protocol):
# Call superclass constructor
Capability.__init__(self, protocol)

self.default_timeout = (
protocol.node_handle.get_parameter("default_call_service_timeout")
.get_parameter_value()
.double_value
)

# Register the operations that this capability provides
call_services_in_new_thread = (
protocol.node_handle.get_parameter("call_services_in_new_thread")
Expand Down Expand Up @@ -81,7 +87,7 @@ def call_service(self, message):
fragment_size = message.get("fragment_size", None)
compression = message.get("compression", "none")
args = message.get("args", [])
timeout = message.get("timeout", 5.0)
timeout = message.get("timeout", self.default_timeout)

if CallService.services_glob is not None and CallService.services_glob:
self.protocol.log(
Expand Down
1 change: 1 addition & 0 deletions rosbridge_library/test/capabilities/test_call_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def setUp(self):
self.executor.add_node(self.node)

self.node.declare_parameter("call_services_in_new_thread", False)
self.node.declare_parameter("default_call_service_timeout", 5.0)
self.node.declare_parameter("send_action_goals_in_new_thread", False)

# Create service servers with a separate callback group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def setUp(self):
self.node = Node("test_service_capabilities")

self.node.declare_parameter("call_services_in_new_thread", False)
self.node.declare_parameter("default_call_service_timeout", 5.0)
self.node.declare_parameter("send_action_goals_in_new_thread", False)

self.proto = Protocol(self._testMethodName, self.node)
Expand Down
2 changes: 2 additions & 0 deletions rosbridge_server/launch/rosbridge_websocket_launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<arg name="use_compression" default="false" />
<arg name="call_services_in_new_thread" default="false" />
<arg name="default_call_service_timeout" default="5.0" />
<arg name="send_action_goals_in_new_thread" default="false" />

<arg name="topics_glob" default="" />
Expand All @@ -42,6 +43,7 @@
<param name="unregister_timeout" value="$(var unregister_timeout)"/>
<param name="use_compression" value="$(var use_compression)"/>
<param name="call_services_in_new_thread" value="$(var call_services_in_new_thread)"/>
<param name="default_call_service_timeout" value="$(var default_call_service_timeout)"/>
<param name="send_action_goals_in_new_thread" value="$(var send_action_goals_in_new_thread)"/>

<param name="topics_glob" value="$(var topics_glob)"/>
Expand Down
4 changes: 4 additions & 0 deletions rosbridge_server/scripts/rosbridge_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ def protocol_parameter_handling(self):
"call_services_in_new_thread", False
).value

RosbridgeWebSocket.default_call_service_timeout = self.declare_parameter(
"default_call_service_timeout", 5.0
).value

RosbridgeWebSocket.send_action_goals_in_new_thread = self.declare_parameter(
"send_action_goals_in_new_thread", False
).value
Expand Down

0 comments on commit a045876

Please sign in to comment.