This commit is contained in:
2026-08-05 18:17:25 +08:00
parent 61796dfa9f
commit b52cee9e39
34 changed files with 866 additions and 309 deletions
+3 -2
View File
@@ -109,7 +109,8 @@ from example_interfaces.srv import AddTwoInts
class AddTwoIntsServer(Node):
def __init__(self):
super().__init__('add_two_ints_server_py')
# 节点名(实际本仓库无 _py 后缀,launch 也不重命名)
super().__init__('add_two_ints_server')
# create_service(srv_type, srv_name, callback)
# callback 签名: callback(request, response) -> response
self.srv = self.create_service(
@@ -167,7 +168,7 @@ private:
```python
class Client(Node):
def __init__(self):
super().__init__('add_two_ints_client_py')
super().__init__('add_two_ints_client')
self.client = self.create_client(AddTwoInts, 'add_two_ints')
# 阻塞等服务端上线(1s 超时,循环等)