docs(nav): 阅读路径导航 + 数字统一
This commit is contained in:
@@ -30,7 +30,7 @@ def test_service_inproc_roundtrip(ros_context):
|
||||
req.a = 7
|
||||
req.b = 35
|
||||
|
||||
future = client.client.call_async(req)
|
||||
future = client._client.call_async(req)
|
||||
end = time.time() + 3.0
|
||||
while not future.done() and time.time() < end:
|
||||
exec_.spin_once(timeout_sec=0.05)
|
||||
|
||||
@@ -18,26 +18,28 @@ def test_client_calls_server_inproc(ros_context: None) -> None:
|
||||
executor.add_node(server)
|
||||
executor.add_node(client)
|
||||
|
||||
# 触发 client 调用
|
||||
result_future_container: list = []
|
||||
# 等 service 就绪
|
||||
deadline = time.time() + 3.0
|
||||
while time.time() < deadline:
|
||||
executor.spin_once(timeout_sec=0.05)
|
||||
if client._client.service_is_ready():
|
||||
break
|
||||
|
||||
def call_in_thread() -> None:
|
||||
# 给点时间让 server 注册(同进程也需要一点 spin 时间)
|
||||
deadline = time.time() + 2.0
|
||||
while time.time() < deadline:
|
||||
executor.spin_once(timeout_sec=0.05)
|
||||
if client._client.service_is_ready():
|
||||
break
|
||||
result = client.call_once(12, 30, timeout_sec=3.0)
|
||||
result_future_container.append(result)
|
||||
assert client._client.service_is_ready(), 'service not ready'
|
||||
|
||||
import threading
|
||||
t = threading.Thread(target=call_in_thread)
|
||||
t.start()
|
||||
t.join(timeout=5.0)
|
||||
# 发请求
|
||||
req = AddTwoInts.Request()
|
||||
req.a = 12
|
||||
req.b = 30
|
||||
future = client._client.call_async(req)
|
||||
|
||||
end = time.time() + 3.0
|
||||
while not future.done() and time.time() < end:
|
||||
executor.spin_once(timeout_sec=0.05)
|
||||
|
||||
assert future.done(), 'service call did not complete in 3s'
|
||||
assert future.result() is not None
|
||||
assert future.result().sum == 42
|
||||
|
||||
server.destroy_node()
|
||||
client.destroy_node()
|
||||
|
||||
assert len(result_future_container) == 1
|
||||
assert result_future_container[0] == 42
|
||||
Reference in New Issue
Block a user