{"id":35863,"date":"2025-05-07T05:46:01","date_gmt":"2025-05-06T21:46:01","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/35863.html"},"modified":"2025-05-07T05:46:01","modified_gmt":"2025-05-06T21:46:01","slug":"aimrt%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e7%b2%be%e9%80%9a-04rpc%e5%ae%a2%e6%88%b7%e7%ab%af%e5%92%8c%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/35863.html","title":{"rendered":"AimRT\u4ece\u5165\u95e8\u5230\u7cbe\u901a - 04RPC\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668"},"content":{"rendered":"<h2>\u4e00\u3001ROS\u4e2d\u7684service\u901a\u4fe1\u673a\u5236<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u670d\u52a1\u901a\u4fe1\u4e5f\u662fROS\u4e2d\u4e00\u79cd\u6781\u5176\u5e38\u7528\u7684\u901a\u4fe1\u6a21\u5f0f&#xff0c;\u670d\u52a1\u901a\u4fe1\u662f\u57fa\u4e8e\u8bf7\u6c42\u54cd\u5e94\u6a21\u5f0f\u7684&#xff0c;\u662f\u4e00\u79cd\u5e94\u7b54\u673a\u5236\u3002\u4e5f\u5373&#xff1a;\u4e00\u4e2a\u8282\u70b9A\u5411\u53e6\u4e00\u4e2a\u8282\u70b9B\u53d1\u9001\u8bf7\u6c42&#xff0c;B\u63a5\u6536\u5904\u7406\u8bf7\u6c42\u5e76\u4ea7\u751f\u54cd\u5e94\u7ed3\u679c\u8fd4\u56de\u7ed9A\u3002\u6bd4\u5982\u5982\u4e0b\u573a\u666f&#xff1a;<\/p>\n<p>\u673a\u5668\u4eba\u5de1\u903b\u8fc7\u7a0b\u4e2d&#xff0c;\u63a7\u5236\u7cfb\u7edf\u5206\u6790\u4f20\u611f\u5668\u6570\u636e\u53d1\u73b0\u53ef\u7591\u7269\u4f53\u6216\u4eba&#8230; \u6b64\u65f6\u9700\u8981\u62cd\u6444\u7167\u7247\u5e76\u7559\u5b58\u3002<\/p>\n<p>\u5728\u4e0a\u8ff0\u573a\u666f\u4e2d&#xff0c;\u5c31\u4f7f\u7528\u5230\u4e86\u670d\u52a1\u901a\u4fe1\u3002<\/p>\n<ul>\n<li>\u6570\u636e\u5206\u6790\u8282\u70b9A\u9700\u8981\u5411\u76f8\u673a\u76f8\u5173\u8282\u70b9B\u53d1\u9001\u56fe\u7247\u5b58\u50a8\u8bf7\u6c42&#xff0c;\u8282\u70b9B\u5904\u7406\u8bf7\u6c42&#xff0c;\u5e76\u8fd4\u56de\u5904\u7406\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<p>\u4e0e\u4e0a\u8ff0\u5e94\u7528\u7c7b\u4f3c\u7684&#xff0c;\u670d\u52a1\u901a\u4fe1\u66f4\u9002\u7528\u4e8e\u5bf9\u5b9e\u65f6\u6027\u6709\u8981\u6c42\u3001\u5177\u6709\u4e00\u5b9a\u903b\u8f91\u5904\u7406\u7684\u5e94\u7528\u573a\u666f\u3002<\/p>\n<p id=\"\u6982\u5ff5\">\u6982\u5ff5<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u670d\u52a1\u901a\u4fe1\u662f\u4ee5\u8bf7\u6c42\u54cd\u5e94\u7684\u65b9\u5f0f\u5b9e\u73b0\u4e0d\u540c\u8282\u70b9\u4e4b\u95f4\u6570\u636e\u4f20\u8f93\u7684\u901a\u4fe1\u6a21\u5f0f\u3002\u53d1\u9001\u8bf7\u6c42\u6570\u636e\u7684\u5bf9\u8c61\u79f0\u4e3a\u5ba2\u6237\u7aef&#xff0c;\u63a5\u6536\u8bf7\u6c42\u5e76\u53d1\u9001\u54cd\u5e94\u7684\u5bf9\u8c61\u79f0\u4e4b\u4e3a\u670d\u52a1\u7aef&#xff0c;\u540c\u8bdd\u9898\u901a\u4fe1\u4e00\u6837&#xff0c;\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u4e5f\u901a\u8fc7\u8bdd\u9898\u76f8\u5173\u8054&#xff0c;\u4e0d\u540c\u7684\u662f\u670d\u52a1\u901a\u4fe1\u7684\u6570\u636e\u4f20\u8f93\u662f\u53cc\u5411\u4ea4\u4e92\u5f0f\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"571\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250506214558-681a8316b07ea.png\" width=\"1188\" \/><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u670d\u52a1\u901a\u4fe1\u4e2d&#xff0c;\u670d\u52a1\u7aef\u4e0e\u5ba2\u6237\u7aef\u662f\u4e00\u5bf9\u591a\u7684\u5173\u7cfb&#xff0c;\u4e5f\u5373&#xff0c;\u540c\u4e00\u670d\u52a1\u8bdd\u9898\u4e0b&#xff0c;\u5b58\u5728\u591a\u4e2a\u5ba2\u6237\u7aef&#xff0c;\u6bcf\u4e2a\u5ba2\u6237\u7aef\u90fd\u53ef\u4ee5\u5411\u670d\u52a1\u7aef\u53d1\u9001\u8bf7\u6c42\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"582\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250506214559-681a8317097b0.png\" width=\"1171\" \/><\/p>\n<h2>\u4e8c\u3001\u00a0AimRT \u4e2d\u7684RPC\u901a\u8baf\u673a\u5236<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0RPC\u4e5f\u53eb\u8fdc\u7a0b\u8fc7\u7a0b\u8c03\u7528&#xff0c;\u57fa\u4e8e\u8bf7\u6c42-\u56de\u590d\u6a21\u578b&#xff0c;\u7531\u5ba2\u6237\u7aefClient\u548c\u670d\u52a1\u7aefServer\u7ec4\u6210&#xff0c;Module\u53ef\u4ee5\u521b\u5efa\u5ba2\u6237\u7aef\u53e5\u67c4&#xff0c;\u53d1\u8d77\u7279\u5b9a\u7684 RPC \u8bf7\u6c42&#xff0c;\u7531\u5176\u6307\u5b9a\u7684\u3001\u6216\u7531\u6846\u67b6\u6839\u636e\u4e00\u5b9a\u89c4\u5219\u6307\u5b9a\u7684\u670d\u52a1\u7aef\u6765\u63a5\u6536\u8bf7\u6c42\u5e76\u56de\u590d\u3002\u5176\u4e0eROS\u4e2d\u7684service\u901a\u4fe1\u4e2d\u7684\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u7c7b\u4f3c&#xff1b;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u4e0eChannel\u7c7b\u4f3c&#xff0c;\u5176\u5728\u63a5\u53e3\u5c42\u548c\u540e\u7aef\u5c42\u4e5f\u5b9e\u73b0\u4e86\u89e3\u8026&#xff0c;\u5206\u4e3a\u4e24\u90e8\u5206&#xff1b;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5728\u63a5\u53e3\u5c42\u4e3b\u8981\u4f7f\u7528Protocol\u652f\u6301\u7684\u534f\u8bae\u8fdb\u884c\u901a\u4fe1&#xff0c;\u4f8b\u5982protobuf \/ ROS2msg\/srv&#xff1b;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5728\u540e\u7aef\u652f\u6301\u7684\u534f\u8bae\u6709http\u3001ros2&#xff0c;\u5f00\u53d1\u8005\u53ef\u4ee5\u81ea\u5df1\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e&#xff1b;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"772\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250506214559-681a831752653.png\" width=\"1789\" \/><\/p>\n<p>\u5173\u4e8e\u63a5\u53e3\u5c42\u4f7f\u7528\u7684protocol&#xff0c;\u8be6\u7ec6\u53ef\u4ee5\u770b\u4e0a\u4e00\u7bc7\u7684\u4ecb\u7ecd&#xff1b;<\/p>\n<p>\u8fd9\u91cc\u5c31\u4e0d\u518d\u8fc7\u591a\u4ecb\u7ecd&#xff1b;\u00a0<\/p>\n<h2 id=\"h_2338165347_3\">\u4e09\u3001\u00a0\u57fa\u4e8eProtobuf\u6d88\u606f\u7684\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668<\/h2>\n<p>\u8fd9\u91cc\u5173\u4e8eprotobuf\u7684\u76f8\u5173\u7b80\u5355\u4f7f\u7528&#xff0c;\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003\u6211\u4e4b\u524d\u5199\u7684\u535a\u5ba2&#xff1a;<\/p>\n<p>Protubuf\u5165\u95e8 &#8212; 01\u57fa\u672c\u8bed\u6cd5\u4e0e\u7f16\u8bd1\u4f7f\u7528-CSDN\u535a\u5ba2<\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u6f14\u793a\u4e00\u4e2a\u7b80\u5355\u7684\u6848\u4f8b&#xff1a;<\/p>\n<h3 style=\"background-color:transparent\">\u7f16\u5199.proto\u6587\u4ef6<\/h3>\n<p><span style=\"color:#fe2c24\">common.proto<\/span><\/p>\n<p>syntax &#061; &#034;proto3&#034;;<\/p>\n<p>package aimrt.protocols.example;<\/p>\n<p>message ExampleFoo {<br \/>\n  int32 code &#061; 1;<br \/>\n  string data &#061; 2;<br \/>\n}<\/p>\n<p>message ExampleBar {<br \/>\n  int32 num &#061; 1;<br \/>\n}<\/p>\n<p><span style=\"color:#fe2c24\">rpc.proto\u00a0<\/span><\/p>\n<p>syntax &#061; &#034;proto3&#034;;<\/p>\n<p>import &#034;common.proto&#034;;<\/p>\n<p>package aimrt.protocols.example;<\/p>\n<p>message GetFooDataReq {<br \/>\n  string msg &#061; 1;<br \/>\n}<\/p>\n<p>message GetFooDataRsp {<br \/>\n  uint64 code &#061; 1;<br \/>\n  string msg &#061; 2;<br \/>\n  aimrt.protocols.example.ExampleFoo data &#061; 3;<br \/>\n}<\/p>\n<p>service ExampleService {<br \/>\n  rpc GetFooData(GetFooDataReq) returns (GetFooDataRsp);<br \/>\n}<\/p>\n<p>\u5176\u4e2d&#xff1a;<\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">rpc.proto<\/span>&#xff1a;\u5305\u542b\u4e86\u516c\u5171\u7684common.proto&#xff0c;\u6240\u4ee5\u8fd9\u91cc\u6211\u4eecimprot&#xff1b;<\/li>\n<li><span style=\"color:#fe2c24\">package<\/span>&#xff1a;\u8fd9\u91cc\u4f1a\u5728\u5bf9\u5e94\u7684C&#043;&#043;\u4ee3\u7801\u4e2d&#xff0c;\u53d8\u6210\u547d\u540d\u7a7a\u95f4&#xff0c;\u5982&#xff1a;aimrt::protocols::example&#xff1b;<\/li>\n<li><span style=\"color:#fe2c24\">GetFooDataReq<\/span>&#xff1a;\u8fd9\u91cc\u5b9a\u4e49\u4e86\u4e00\u4e2a\u6d88\u606f\u7684\u8bf7\u6c42\u7ed3\u6784&#xff08;\u5ba2\u6237\u7aef\u53d1\u9001\u7684\u6570\u636e\u7c7b\u578b&#xff09;&#xff1b;<\/li>\n<li><span style=\"color:#fe2c24\">GetFooDataRsp<\/span>&#xff1a;\u8fd9\u91cc\u5b9a\u4e49\u4e86\u4e00\u4e2a\u6d88\u606f\u7684\u56de\u590d\u7684\u7ed3\u6784&#xff08;\u670d\u52a1\u5668\u56de\u590d\u7684\u6570\u636e\u7c7b\u578b&#xff09;&#xff1b;<\/li>\n<li>\u63a5\u4e0b\u6765\u5b9a\u4e49\u4e86\u4e00\u4e2a\u670d\u52a1\u65b9\u6cd5&#xff1a;\u8fd9\u91cc\u901a\u8fc7rpc\u67b6\u6784&#xff0c;\u63a5\u6536<span style=\"color:#fe2c24\">GetFooDataReq<\/span><span style=\"color:#0d0016\">&#xff0c;\u56de\u590d<\/span><span style=\"color:#fe2c24\">GetFooDataRsp<\/span><\/li>\n<\/ul>\n<h3>.proto\u6587\u4ef6\u7684\u7f16\u8bd1&#xff08;\u901a\u4fe1\u901a\u4fe1\u7684\u6846\u67b6\u4e0b&#xff09;<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5bf9\u4e8e\u6b63\u5e38\u60c5\u51b5\u4e0b.proto\u6587\u4ef6\u7684\u7f16\u8bd1&#xff0c;\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003\u6211\u7684\u4e4b\u524d\u5199\u7684\u535a\u5ba2&#xff1b;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8fd9\u91ccAimRT\u5bf9\u4e8eprotobuf\u7684\u7f16\u8bd1\u63d0\u4f9b\u4e86\u4e0b\u9762\u7684\u7f16\u8bd1\u6307\u4ee4&#xff0c;\u5373\u6211\u4eec\u53ef\u4ee5\u5728CMakeLists.txt\u8fdb\u884c\u76f8\u5173\u6587\u4ef6\u7684\u914d\u7f6e&#xff0c;\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff0c;\u5728\u5b9e\u9645\u4f7f\u7528\u65f6&#xff0c;\u9700\u8981\u5148\u5c06\u5176\u751f\u6210\u5bf9\u5e94\u7684C&#043;&#043;\u4ee3\u7801&#xff0c;\u7136\u540e\u518d\u751f\u6210C&#043;&#043;\u5bf9\u5e94\u7684\u670d\u52a1\u4ee3\u7801&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#511b78\">\u00a0add_ros2_aimrt_rpc_gencode_target_for_one_file<\/span>&#xff1a;\u4e3a\u5355\u4e2a srv \u6587\u4ef6\u751f\u6210 RPC \u670d\u52a1 C&#043;&#043; \u4ee3\u7801&#xff0c;\u53c2\u6570\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\n<p>TARGET_NAME&#xff1a;\u751f\u6210\u7684 CMake Target \u540d\u79f0&#xff1b;<\/p>\n<\/li>\n<li>\n<p>PACKAGE_NAME&#xff1a;ROS2 \u534f\u8bae PKG \u7684\u540d\u79f0&#xff1b;<\/p>\n<\/li>\n<li>\n<p>PROTO_FILE&#xff1a;\u534f\u8bae\u6587\u4ef6\u7684\u8def\u5f84&#xff1b;<\/p>\n<\/li>\n<li>\n<p>GENCODE_PATH&#xff1a;\u751f\u6210\u7684\u6869\u4ee3\u7801\u5b58\u653e\u8def\u5f84&#xff1b;<\/p>\n<\/li>\n<li>\n<p>DEP_PROTO_TARGETS&#xff1a;\u4f9d\u8d56\u7684\u534f\u8bae CMake Target&#xff1b;<\/p>\n<\/li>\n<li>\n<p>OPTIONS&#xff1a;\u4f20\u9012\u7ed9\u5de5\u5177\u7684\u5176\u4ed6\u53c2\u6570&#xff1b;<\/p>\n<\/li>\n<\/ul>\n<p>\u4f8b\u5982\u4e0b\u9762\u6240\u793a\u7684\u4ee3\u7801\u4f8b\u5b50&#xff1a;<\/p>\n<p># \u6dfb\u52a0\u5bf9 pb \u6d88\u606f\u7684\u4ee3\u7801\u751f\u6210<br \/>\nadd_protobuf_gencode_target_for_proto_path(<br \/>\n    TARGET_NAME ${PROTO_NAME}_pb_gencode<br \/>\n    PROTO_PATH ${CMAKE_CURRENT_SOURCE_DIR}<br \/>\n    GENCODE_PATH ${CMAKE_CURRENT_BINARY_DIR})<\/p>\n<p># \u6dfb\u52a0\u5bf9 RPC pb\u7684\u4ee3\u7801\u751f\u6210<br \/>\nadd_protobuf_aimrt_rpc_gencode_target_for_proto_files(<br \/>\n    TARGET_NAME ${PROTO_NAME}_aimrt_rpc_gencode<br \/>\n    PROTO_FILES ${CMAKE_CURRENT_SOURCE_DIR}\/my_rpc.proto<br \/>\n    GENCODE_PATH ${CMAKE_CURRENT_BINARY_DIR}<br \/>\n    DEP_PROTO_TARGETS ${PROTO_NAME}_pb_gencode<br \/>\n) <\/p>\n<ul>\n<li>\u6211\u4eec\u4f7f\u7528\u524d\u9762\u7528\u5230\u7684<span style=\"color:#fe2c24\">add_protobuf_gencode_target_for_proto_path<\/span>\u5b8f&#xff0c;\u5c06\u5f53\u524d\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u666e\u901a\u7684 proto \u6d88\u606f\u8fdb\u884c\u4ee3\u7801\u751f\u6210&#xff0c;\u751f\u6210\u7684\u76ee\u6807\u540d\u4e3a:<span style=\"color:#fe2c24\">${PROTO_NAME}_pb_gencode&#xff1b;<\/span><\/li>\n<li>\u63a5\u7740\u6211\u4eec\u4f7f\u7528<span style=\"color:#fe2c24\">add_protobuf_aimrt_rpc_gencode_target_for_proto_files<\/span>\u5b8f&#xff0c;\u5c06\u6307\u5b9a\u7684 RPC proto\u6d88\u606f\u8fdb\u884c\u751f\u6210&#xff0c;\u751f\u6210\u7684<span style=\"color:#fe2c24\">target\u4e3a${PROTO_NAME}_aimrt_rpc_gencode&#xff1b;<\/span><\/li>\n<li>\u5728PROTO_FILES\u53c2\u6570\u6307\u660e<span style=\"color:#511b78\">\u5f53\u524d\u5305\u542brpc\u7684proto\u7684\u6587\u4ef6\u540d<\/span>&#xff1b;<\/li>\n<li>GENCODE_PATH<span style=\"color:#fe2c24\">\u6307\u660e\u5f53\u524d\u751f\u6210\u4ee3\u7801\u7684\u8def\u5f84<\/span>&#xff0c;\u5176\u4e2d AimRT \u4f1a\u81ea\u52a8\u5c06\u8fd9\u4e2a\u8def\u5f84\u6dfb\u52a0\u5230\u5e93\u7684\u5934\u6587\u4ef6\u641c\u7d22\u8def\u5f84&#xff1b;<\/li>\n<li>\u56e0\u4e3a\u6211\u4eec\u5728RPC PB \u4e2d\u4f7f\u7528\u5230\u4e86common.proto&#xff0c;\u6240\u4ee5\u9700\u8981\u7ed9\u5176\u6dfb\u52a0\u666e\u901apb\u6d88\u606f\u7684\u4f9dDEP_PROTO_TARGETS ${PROTO_NAME}_pb_gencode&#xff1b;<\/li>\n<\/ul>\n<h3>\u670d\u52a1\u5668\u6a21\u5757<\/h3>\n<p>\u5176\u4e2d&#xff0c;\u670d\u52a1\u5668module\u5305\u542b\u4e0b\u9762\u4e09\u4e2a\u6a21\u5757&#xff0c;\u8fd9\u91cc\u6211\u4eec\u4f9d\u6b21\u5bf9\u5176\u8fdb\u884c\u8bb2\u89e3&#xff1a;<\/p>\n<h4>logger.h\/logger.cc<\/h4>\n<p>#pragma once<\/p>\n<p>#include &#034;aimrt_module_cpp_interface\/logger\/logger.h&#034;<\/p>\n<p>namespace aimrt::examples::cpp::pb_rpc::normal_rpc_sync_server_module {<\/p>\n<p>void SetLogger(aimrt::logger::LoggerRef);<br \/>\naimrt::logger::LoggerRef GetLogger();<\/p>\n<p>} <\/p>\n<p>\u8fd9\u91cclogger.h\u4e3b\u8981\u4e3a\u670d\u52a1\u5668\u63d0\u4f9b\u65e5\u5fd7\u7684\u8bbe\u7f6e&#xff0c;\u4e00\u5171\u63d0\u4f9b\u4e86\u4e24\u4e2a\u51fd\u6570&#xff1a;<\/p>\n<ul>\n<li>\u901a\u8fc7SetLogger: \u8fd9\u91cc\u6211\u4eec\u4f20\u5165\u5bf9\u5e94\u7684\u65e5\u5fd7\u53e5\u67c4&#xff0c;\u53ef\u4ee5\u5c06\u5176\u5185\u90e8\u7684\u7ba1\u7406\u7684\u6a21\u5757\u7684\u65e5\u5fd7\u53e5\u67c4\u8fdb\u884c\u8d4b\u503c&#xff1b;<\/li>\n<li>\u901a\u8fc7GetLogger:\u8fd9\u91cc\u6211\u4eec\u53ef\u4ee5\u83b7\u53d6\u5230\u6211\u4eec\u4e4b\u524d\u8bbe\u7f6e\u7684\u65e5\u5fd7\u53e5\u67c4&#xff1b;<\/li>\n<\/ul>\n<h4>service.h<\/h4>\n<p>#pragma once<\/p>\n<p>#include &#034;rpc.aimrt_rpc.pb.h&#034;<\/p>\n<p>namespace aimrt::examples::cpp::pb_rpc::normal_rpc_sync_server_module {<\/p>\n<p>class ExampleServiceSyncServiceImpl : public aimrt::protocols::example::ExampleServiceSyncService {<br \/>\n public:<br \/>\n  ExampleServiceSyncServiceImpl() &#061; default;<br \/>\n  ~ExampleServiceSyncServiceImpl() override &#061; default;<\/p>\n<p>  aimrt::rpc::Status GetFooData(<br \/>\n      aimrt::rpc::ContextRef ctx,<br \/>\n      const ::aimrt::protocols::example::GetFooDataReq&amp; req,<br \/>\n      ::aimrt::protocols::example::GetFooDataRsp&amp; rsp) override;<\/p>\n<p>} <\/p>\n<p>\u8fd9\u91cc\u6211\u4eec\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0AimRT \u5c06\u6bcf\u4e2a <span style=\"color:#fe2c24\">Service<\/span> \u7684\u6869\u4ee3\u7801\u5c01\u88c5\u4e3a\u4e00\u4e2a\u57fa\u7c7b&#xff0c;\u5728\u7a0b\u5e8f\u4e2d&#xff0c;\u6211\u4eec\u53ea\u9700\u8981\u7ee7\u627f\u8be5\u57fa\u7c7b&#xff0c;\u5e76\u91cd\u5199\u57fa\u7c7b\u4e2d\u7684 RPC \u65b9\u6cd5\u5373\u53ef\u3002\u4f8b\u5982\u5728 pb \u4e2d&#xff0c;\u5b9a\u4e49\u7684 RPC \u670d\u52a1\u540d\u4e3aMyService&#xff0c;\u56e0\u6b64 AimRT \u4e3a\u6211\u4eec\u751f\u6210\u4ee5\u4e0b\u6869\u4ee3\u7801\u7c7b&#xff1a;<\/p>\n<ul>\n<li>\u5f02\u6b65\u670d\u52a1\u7aef\u6869\u4ee3\u7801\u7c7b\u540d\u4e3a:\u00a0[\u670d\u52a1\u540d]CoServic&#xff1b;<\/li>\n<li>\u540c\u6b65\u670d\u52a1\u7aef\u6869\u4ee3\u7801\u7c7b\u540d\u4e3a:[\u670d\u52a1\u540d]SyncService&#xff1b;<\/li>\n<\/ul>\n<p>\u4f8b\u5982\u4e0a\u9762\u7684&#xff0c;\u8fd9\u91cc\u5728\u770b\u6211\u4eec\u5b9a\u4e49\u7684.proto\u6587\u4ef6&#xff1a;<\/p>\n<p>\u8fd9\u91cc\u6211\u4eec\u58f0\u660e\u4e86\u4e0b\u9762\u7684\u547d\u540d\u7a7a\u95f4&#xff1a;<\/p>\n<p>package aimrt.protocols.example;<\/p>\n<p>\u6240\u4ee5\u751f\u6210\u7684C&#043;&#043;\u6e90\u6587\u4ef6\u4e2d\u4f1a\u751f\u6210\u5bf9\u5e94\u7684\u547d\u540d\u7a7a\u95f4&#xff1a;<span style=\"color:#fe2c24\">aimrt::protocols::example<\/span>\u8fd9\u4e2a\u547d\u540d\u7a7a\u95f4&#xff01;<\/p>\n<p>\u9664\u6b64\u4e4b\u5916&#xff0c;\u4e3b\u8981\u6709\u7684\u662f\u6211\u4eec\u5b9a\u4e49\u4e86\u4e0b\u9762\u8fd9\u4e2aservice&#xff1a;<\/p>\n<p>service ExampleService {<br \/>\n  rpc GetFooData(GetFooDataReq) returns (GetFooDataRsp); <\/p>\n<p>\u6240\u4ee5\u5bf9\u5e94\u751f\u6210\u7684\u670d\u52a1\u4f1a\u5728\u00a0<span style=\"color:#fe2c24\">aimrt::protocols::example:ExampleService&#xff1b;<\/span><\/p>\n<p>\u800cAimRT\u4f1a\u57fa\u4e8e<span style=\"color:#fe2c24\">aimrt::protocols::example:ExampleService\u5f00\u53d1\u5bf9\u5e94\u7684\u5f02\u6b65\/\u540c\u6b65\u63a5\u53e3&#xff01;<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u800c\u8fd9\u4e2a\u5f02\u6b65\/\u540c\u6b65\u63a5\u53e3\u90fd\u662f\u7ee7\u627fServiceBase\u7684&#xff01;<\/span><\/p>\n<p>\u7528\u6237\u5982\u679c\u8981\u4f7f\u7528\u5f02\u6b65\/\u540c\u6b65\u7684\u670d\u52a1&#xff0c;\u53ea\u9700\u8981\u5bf9\u5176\u8fdb\u884c\u7ee7\u627f\u91cd\u5199\u5373\u53ef&#xff01;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"642\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250506214559-681a8317d0690.png\" width=\"1155\" \/><\/p>\n<p>\u5982\u4e0a\u9762\u6240\u793a&#xff0c;\u8fd9\u91cc\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5bf9\u5176\u662f\u57fa\u4e8e\u7ee7\u627f\u57fa\u7c7b\u6a21\u5757\u7684&#xff1b;<\/p>\n<p>class ServiceBase {<br \/>\n public:<br \/>\n  std::string_view RpcType() const;<\/p>\n<p>  void SetServiceName(std::string_view service_name);<br \/>\n  std::string_view ServiceName() const;<\/p>\n<p>  \/\/ &#8230;<br \/>\n};<\/p>\n<p>class XXXService : public aimrt::rpc::ServiceBase {<br \/>\n  \/\/ &#8230;<br \/>\n} <\/p>\n<p>\u8be6\u7ec6\u7684\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003\u4e0b\u9762\u7684\u6587\u6863&#xff1a;<\/p>\n<p>Rpc \u2014 AimRT v0.10.0 documentation<\/p>\n<p>\u56e0\u6b64\u518d\u603b\u7ed3\u4e00\u4e0b\u540c\u6b65\u578b\u670d\u52a1\u63a5\u53e3\u7684\u4f7f\u7528&#xff1a;<\/p>\n<ul>\n<li>\u5f15\u7528\u6869\u4ee3\u7801\u5934\u6587\u4ef6&#xff0c;\u4f8b\u5982xxx.aimrt_rpc.pb.h\u6216\u8005xxx.aimrt_rpc.srv.h&#xff0c;\u5176\u4e2d\u6709\u540c\u6b65\u63a5\u53e3\u7684 Service \u57fa\u7c7bXXXSyncService;<\/li>\n<li>\u5f00\u53d1\u8005\u5b9e\u73b0\u4e00\u4e2a Impl \u7c7b&#xff0c;\u7ee7\u627fXXXSyncService&#xff0c;\u5e76\u5b9e\u73b0\u5176\u4e2d\u7684\u865a\u63a5\u53e3&#xff1b;<\/li>\n<li>\u89e3\u6790 Req&#xff0c;\u5e76\u586b\u5145 Rsp&#xff1b;<\/li>\n<li>\u8fd4\u56deStatus&#xff1b;<\/li>\n<li>\u5728Initialize\u9636\u6bb5\u8c03\u7528RpcHandleRef\u7684RegisterService\u65b9\u6cd5\u6ce8\u518c RPC Service&#xff1b;<\/li>\n<\/ul>\n<p>\u8fd9\u662f\u4e00\u4e2a\u56fa\u5b9a\u7684\u6a21\u677f&#xff01;\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003&#xff1b;<\/p>\n<h4>service.cc<\/h4>\n<p>#include &#034;normal_rpc_sync_server_module\/service.h&#034;<br \/>\n#include &#034;aimrt_module_protobuf_interface\/util\/protobuf_tools.h&#034;<br \/>\n#include &#034;normal_rpc_sync_server_module\/global.h&#034;<\/p>\n<p>namespace aimrt::examples::cpp::pb_rpc::normal_rpc_sync_server_module {<\/p>\n<p>aimrt::rpc::Status ExampleServiceSyncServiceImpl::GetFooData(<br \/>\n    aimrt::rpc::ContextRef ctx,<br \/>\n    const ::aimrt::protocols::example::GetFooDataReq&amp; req,<br \/>\n    ::aimrt::protocols::example::GetFooDataRsp&amp; rsp) {<br \/>\n  rsp.set_msg(&#034;echo &#034; &#043; req.msg());<\/p>\n<p>  AIMRT_INFO(&#034;Server handle new rpc call. context: {}, req: {}, return rsp: {}&#034;,<br \/>\n             ctx.ToString(), aimrt::Pb2CompactJson(req), aimrt::Pb2CompactJson(rsp));<\/p>\n<p>  return aimrt::rpc::Status();<br \/>\n}<\/p>\n<p>} <\/p>\n<p>\u5b9e\u9645\u4e0a\u8fd9\u91cc\u5b9a\u4e49\u7684\u8fd9\u4e2a\u51fd\u6570\u5c31\u662f\u670d\u52a1\u7aef\u7528\u6765\u5904\u7406\u6570\u636e\u7684\u56de\u8c03\u51fd\u6570&#xff01;<\/p>\n<p>\u8fd9\u4e2a\u51fd\u6570\u5305\u542b3\u4e2a\u53c2\u6570&#xff0c;\u5176\u4e2d&#xff1a;<\/p>\n<ul>\n<li>ctx&#xff1a;\u8868\u793a\u5411RPC\u7684\u540e\u7aef\u4f20\u9012\u4e00\u4e9b\u7279\u5b9a\u7684\u914d\u7f6e\u4fe1\u606f&#xff1b;<\/li>\n<li>req&#xff1a;\u8868\u793a\u53d1\u9001\u7684proto\u7c7b\u578b\u7684\u6570\u636e&#xff1b;<\/li>\n<li>rsp&#xff1a;\u8868\u793a\u56de\u590d\u76f8\u5e94\u7684\u6570\u636e&#xff1b;<\/li>\n<\/ul>\n<p>\u8fd9\u91cc\u51fd\u6570\u4f53\u5185\u5b9e\u9645\u4e0a\u5c31\u662f\u5bf9\u56de\u590d\u6570\u636e\u505a\u5904\u7406&#xff1a;\u524d\u9762&#043;\u4e0a\u6253\u5370&#034;echo&#034;&#xff1b;<\/p>\n<p>\u8fd4\u56de\u503c\u662frpc\u5bf9\u5e94\u7684\u72b6\u6001&#xff08;\u5982\u679c\u8fd9\u91cc\u6211\u4eec\u8bbe\u7f6e\u7684\u6709\u9519\u8bef\u7801&#xff0c;\u8fd9\u91cc\u8fd4\u56de\u53ef\u4ee5\u83b7\u53d6\u5230\u5bf9\u5e94\u7684\u9519\u8bef\u7801&#xff0c;\u4ece\u800c\u67e5\u8be2\u83b7\u53d6\u5230\u5bf9\u5e94\u7684\u9519\u8bef\u7c7b\u578b&#xff1b;&#xff09;\u00a0<\/p>\n<h4>service_module.h<\/h4>\n<p>#pragma once<\/p>\n<p>#include &lt;memory&gt;<\/p>\n<p>#include &#034;aimrt_module_cpp_interface\/module_base.h&#034;<br \/>\n#include &#034;normal_rpc_sync_server_module\/service.h&#034;<\/p>\n<p>namespace aimrt::examples::cpp::pb_rpc::normal_rpc_sync_server_module {<\/p>\n<p>class NormalRpcSyncServerModule : public aimrt::ModuleBase {<br \/>\n public:<br \/>\n  NormalRpcSyncServerModule() &#061; default;<br \/>\n  ~NormalRpcSyncServerModule() override &#061; default;<\/p>\n<p>  ModuleInfo Info() const override {<br \/>\n    return ModuleInfo{.name &#061; &#034;NormalRpcSyncServerModule&#034;};<br \/>\n  }<\/p>\n<p>  bool Initialize(aimrt::CoreRef core) override;<\/p>\n<p>  bool Start() override;<\/p>\n<p>  void Shutdown() override;<\/p>\n<p> private:<br \/>\n  aimrt::CoreRef core_;<br \/>\n  std::shared_ptr&lt;ExampleServiceSyncServiceImpl&gt; service_ptr_;<\/p>\n<p>  std::string service_name_;<br \/>\n};<\/p>\n<p>} <\/p>\n<p>\u6574\u4f53\u6846\u67b6\u548c\u4e4b\u524d\u7684\u4e00\u81f4&#xff0c;\u8fd9\u91cc\u91c7\u7528\u5171\u4eab\u6307\u9488\u7684\u65b9\u5f0f\u58f0\u660e\u4e00\u4e2a\u670d\u52a1\u7aef&#xff1b;<\/p>\n<h4>service_module.cc<\/h4>\n<p>\u8fd9\u91cc\u6211\u4eec\u53ea\u5bf9\u4e3b\u6a21\u5757\u8fdb\u884c\u8bb2\u89e3&#xff1a;<\/p>\n<p>#include &#034;normal_rpc_sync_server_module\/normal_rpc_sync_server_module.h&#034;<br \/>\n#include &#034;normal_rpc_sync_server_module\/global.h&#034;<\/p>\n<p>#include &#034;yaml-cpp\/yaml.h&#034;<\/p>\n<p>namespace aimrt::examples::cpp::pb_rpc::normal_rpc_sync_server_module {<\/p>\n<p>bool NormalRpcSyncServerModule::Initialize(aimrt::CoreRef core) {<br \/>\n  core_ &#061; core;<\/p>\n<p>  SetLogger(core_.GetLogger());<\/p>\n<p>  try {<br \/>\n    \/\/ Read cfg<br \/>\n    std::string file_path &#061; std::string(core_.GetConfigurator().GetConfigFilePath());<br \/>\n    if (!file_path.empty()) {<br \/>\n      YAML::Node cfg_node &#061; YAML::LoadFile(file_path);<br \/>\n      if (cfg_node[&#034;service_name&#034;]) {<br \/>\n        service_name_ &#061; cfg_node[&#034;service_name&#034;].as&lt;std::string&gt;();<br \/>\n      }<br \/>\n    }<\/p>\n<p>    \/\/ Create service<br \/>\n    service_ptr_ &#061; std::make_shared&lt;ExampleServiceSyncServiceImpl&gt;();<\/p>\n<p>    \/\/ Register service<br \/>\n    bool ret &#061; false;<br \/>\n    if (service_name_.empty()) {<br \/>\n      ret &#061; core_.GetRpcHandle().RegisterService(service_ptr_.get());<br \/>\n    } else {<br \/>\n      ret &#061; core_.GetRpcHandle().RegisterService(service_name_, service_ptr_.get());<br \/>\n    }<\/p>\n<p>    AIMRT_CHECK_ERROR_THROW(ret, &#034;Register service failed.&#034;);<\/p>\n<p>    AIMRT_INFO(&#034;Register service succeeded.&#034;);<\/p>\n<p>  } catch (const std::exception&amp; e) {<br \/>\n    AIMRT_ERROR(&#034;Init failed, {}&#034;, e.what());<br \/>\n    return false;<br \/>\n  }<\/p>\n<p>  AIMRT_INFO(&#034;Init succeeded.&#034;);<\/p>\n<p>  return true;<br \/>\n}<\/p>\n<p>bool NormalRpcSyncServerModule::Start() { return true; }<\/p>\n<p>void NormalRpcSyncServerModule::Shutdown() {}<\/p>\n<p>} <\/p>\n<p>\u4e0a\u9762\u7684\u4ee3\u7801\u4ee5<span style=\"color:#fe2c24\">\u540c\u6b65\u901a\u4fe1<\/span>\u4e3a\u4f8b\u5b50&#xff1a;<\/p>\n<p>\u5728\u521d\u59cb\u5316\u90e8\u5206&#xff1a;<\/p>\n<li>\u9996\u5148\u901a\u8fc7SetLogger\u8bbe\u7f6e\u5168\u5c40\u7684\u65e5\u5fd7&#xff1b;<\/li>\n<li>\u7136\u540e\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6&#xff1b;<\/li>\n<li>\u901a\u8fc7\u5171\u4eab\u6307\u9488\u7ba1\u7406\u670d\u52a1\u5668\u6a21\u5757&#xff1b;<\/li>\n<li>\u63a5\u4e0b\u6765\u6ce8\u518c\u670d\u52a1\u5668\u7684\u63a5\u53e3&#xff1b;<\/li>\n<p>    \/\/ Register service<br \/>\n    bool ret &#061; false;<br \/>\n    if (service_name_.empty()) {<br \/>\n      ret &#061; core_.GetRpcHandle().RegisterService(service_ptr_.get());<br \/>\n    } else {<br \/>\n      ret &#061; core_.GetRpcHandle().RegisterService(service_name_, service_ptr_.get());<br \/>\n    } <\/p>\n<p>\u8fd9\u91cc\u6ce8\u518c\u670d\u52a1\u5668\u7684\u903b\u8f91\u662f&#xff1a;<\/p>\n<ul>\n<li><span style=\"color:#511b78\">\u5982\u679c\u6211\u4eec\u6ca1\u6709\u670d\u52a1\u5668\u7684\u540d\u5b57&#xff0c;\u90a3\u4e48\u6b64\u65f6\u5c31\u6309\u7167\u9ed8\u8ba4\u7684\u540d\u79f0\u8fdb\u884c\u6ce8\u518c&#xff1b;<\/span><\/li>\n<li><span style=\"color:#511b78\">\u5982\u679c\u6211\u4eec\u8bbe\u7f6e\u4e86\u5bf9\u5e94\u7684\u540d\u5b57&#xff0c;\u6b64\u65f6\u5c31\u6309\u7167\u81ea\u5b9a\u4e49\u7684\u540d\u5b57\u8fdb\u884c\u6ce8\u518c&#xff1b;<\/span><\/li>\n<\/ul>\n<p>\u63a5\u4e0b\u6765\u5206\u522b\u5f00\u542f\u5f00\u59cb\u6a21\u5757\u548c\u7ed3\u675f\u6a21\u5757&#xff1b;<\/p>\n<h3>\u5ba2\u6237\u7aef\u6a21\u5757<\/h3>\n<h4>client_module.h<\/h4>\n<p>#pragma once<\/p>\n<p>#include &lt;atomic&gt;<br \/>\n#include &lt;future&gt;<br \/>\n#include &lt;memory&gt;<\/p>\n<p>#include &#034;aimrt_module_cpp_interface\/module_base.h&#034;<\/p>\n<p>#include &#034;rpc.aimrt_rpc.pb.h&#034;<\/p>\n<p>namespace aimrt::examples::cpp::pb_rpc::normal_rpc_sync_client_module {<\/p>\n<p>class NormalRpcSyncClientModule : public aimrt::ModuleBase {<br \/>\n public:<br \/>\n  NormalRpcSyncClientModule() &#061; default;<br \/>\n  ~NormalRpcSyncClientModule() override &#061; default;<\/p>\n<p>  ModuleInfo Info() const override {<br \/>\n    return ModuleInfo{.name &#061; &#034;NormalRpcSyncClientModule&#034;};<br \/>\n  }<\/p>\n<p>  bool Initialize(aimrt::CoreRef core) override;<\/p>\n<p>  bool Start() override;<\/p>\n<p>  void Shutdown() override;<\/p>\n<p> private:<br \/>\n  auto GetLogger() { return core_.GetLogger(); }<\/p>\n<p>  void MainLoop();<\/p>\n<p> private:<br \/>\n  aimrt::CoreRef core_;<br \/>\n  aimrt::executor::ExecutorRef executor_;<\/p>\n<p>  std::atomic_bool run_flag_ &#061; false;<br \/>\n  std::promise&lt;void&gt; stop_sig_;<\/p>\n<p>  double rpc_frq_ &#061; 1.0;<br \/>\n  std::string service_name_;<\/p>\n<p>  std::shared_ptr&lt;aimrt::protocols::example::ExampleServiceSyncProxy&gt; proxy_;<br \/>\n};<\/p>\n<p>} <\/p>\n<p>\u8fd9\u91cc\u7684\u5ba2\u6237\u7aef\u6a21\u5757\u7684\u6846\u67b6\u5b9e\u9645\u4e0a\u4e0e\u53d1\u5e03\u8005publisher\u7684\u6846\u67b6\u4e00\u6837&#xff1b;<\/p>\n<p>\u5176\u5b9e\u8fd9\u91cc\u7684service\u7684\u4e3b\u8981\u539f\u56e0\u662fchannel\u4e0erpc\u7684\u901a\u4fe1\u673a\u5236\u4e0d\u4e00\u6837&#xff0c;\u56e0\u4e3achannel\u6536\u5230\u6d88\u606f\u540e\u4e0d\u7528\u518d\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef&#xff0c;\u800cservice\u8fd9\u91cc\u6536\u5230\u6d88\u606f\u540e\u9700\u8981\u5bf9\u6d88\u606f\u505a\u5904\u7406&#xff0c;\u7136\u540e\u518d\u8fd4\u56de\u7ed9client&#xff0c;\u6240\u4ee5\u5c31\u4f1a\u9ebb\u70e6\u5f88\u591a&#xff0c;\u56e0\u6b64\u53d1\u9001\u6d88\u606f\u540e\u5ba2\u6237\u7aef\u662f\u5f02\u6b65\u8fd8\u662f\u540c\u6b65\u7b49&#xff1f;\u8003\u8651\u7684\u95ee\u9898\u66f4\u591a&#xff0c;\u5c31\u663e\u5f97\u66f4\u52a0\u590d\u6742&#xff1b;<\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u4f9d\u6b21\u5bf9\u4e0a\u9762\u7684\u4ee3\u7801\u6a21\u5757\u8fdb\u884c\u5206\u6790&#xff1a;<\/p>\n<ul>\n<li>\u4e3b\u8981\u7684\u6a21\u5757&#xff08;\u521d\u59cb\u5316\u3001\u5f00\u59cb\u548c\u7ed3\u675f&#xff09;\u4e0e\u6211\u4eec\u4e4b\u524d\u8fdb\u884c\u7684\u6a21\u5757\u4e00\u6837&#xff1b;<\/li>\n<li>\u00a0\u9664\u6b64\u4e4b\u5916&#xff0c;\u8fd8\u6709\u4e00\u4e2aexecutor&#xff0c;\u8fd9\u91cc\u662f\u7528\u4e8e\u53d1\u9001\u8005\u5c06\u4efb\u52a1\u6295\u9012\u5230\u6267\u884c\u5668&#xff0c;\u7136\u540e\u6267\u884c\u5668\u53ef\u4ee5\u53d1\u9001\u5bf9\u5e94\u7684\u4efb\u52a1&#xff1b;<\/li>\n<li>run_flag&#xff1a;\u7528\u6765\u6807\u8bc6\u6a21\u5757\u662f\u5426\u5728\u8fd0\u884c&#xff1b;<\/li>\n<li>stop_sig_n:\u5f53\u53d1\u9001\u4efb\u52a1\u5faa\u73af\u7ed3\u675f\u65f6&#xff0c;\u6b64\u65f6\u4f1a\u7ed9\u53d1\u9001\u5bf9\u5e94\u7684\u4fe1\u53f7\u7ed9\u5173\u95ed\u6a21\u5757&#xff0c;shutdown\u6536\u5230\u540e\u6b64\u65f6\u5c31\u5bf9\u6a21\u5757\u8fdb\u884c\u5173\u95ed&#xff1b;<\/li>\n<li>\u9664\u6b64\u4e4b\u5916&#xff0c;\u8fd9\u91cc\u8fd8\u5b9a\u4e49\u4e86\u8bdd\u9898\u540d\u3001\u53d1\u5e03\u8005\u548c\u53d1\u5e03\u7684\u9891\u7387&#xff1b;<\/li>\n<\/ul>\n<h4>client_module.cc<\/h4>\n<p>#include &#034;normal_rpc_sync_client_module\/normal_rpc_sync_client_module.h&#034;<br \/>\n#include &#034;aimrt_module_protobuf_interface\/util\/protobuf_tools.h&#034;<\/p>\n<p>#include &#034;yaml-cpp\/yaml.h&#034;<\/p>\n<p>namespace aimrt::examples::cpp::pb_rpc::normal_rpc_sync_client_module {<\/p>\n<p>bool NormalRpcSyncClientModule::Initialize(aimrt::CoreRef core) {<br \/>\n  core_ &#061; core;<\/p>\n<p>  try {<br \/>\n    \/\/ Read cfg<br \/>\n    std::string file_path &#061; std::string(core_.GetConfigurator().GetConfigFilePath());<br \/>\n    if (!file_path.empty()) {<br \/>\n      YAML::Node cfg_node &#061; YAML::LoadFile(file_path);<br \/>\n      rpc_frq_ &#061; cfg_node[&#034;rpc_frq&#034;].as&lt;double&gt;();<\/p>\n<p>      if (cfg_node[&#034;service_name&#034;]) {<br \/>\n        service_name_ &#061; cfg_node[&#034;service_name&#034;].as&lt;std::string&gt;();<br \/>\n      }<br \/>\n    }<\/p>\n<p>    \/\/ Get executor handle<br \/>\n    executor_ &#061; core_.GetExecutorManager().GetExecutor(&#034;work_thread_pool&#034;);<br \/>\n    AIMRT_CHECK_ERROR_THROW(executor_, &#034;Get executor &#039;work_thread_pool&#039; failed.&#034;);<\/p>\n<p>    \/\/ Get rpc handle<br \/>\n    auto rpc_handle &#061; core_.GetRpcHandle();<br \/>\n    AIMRT_CHECK_ERROR_THROW(rpc_handle, &#034;Get rpc handle failed.&#034;);<\/p>\n<p>    \/\/ Register rpc client<br \/>\n    bool ret &#061; false;<br \/>\n    if (service_name_.empty()) {<br \/>\n      ret &#061; aimrt::protocols::example::RegisterExampleServiceClientFunc(rpc_handle);<br \/>\n    } else {<br \/>\n      ret &#061; aimrt::protocols::example::RegisterExampleServiceClientFunc(rpc_handle, service_name_);<br \/>\n    }<br \/>\n    AIMRT_CHECK_ERROR_THROW(ret, &#034;Register client failed.&#034;);<\/p>\n<p>    \/\/ Create rpc proxy<br \/>\n    proxy_ &#061; std::make_shared&lt;aimrt::protocols::example::ExampleServiceSyncProxy&gt;(rpc_handle);<\/p>\n<p>    if (!service_name_.empty()) {<br \/>\n      proxy_-&gt;SetServiceName(service_name_);<br \/>\n    }<\/p>\n<p>  } catch (const std::exception&amp; e) {<br \/>\n    AIMRT_ERROR(&#034;Init failed, {}&#034;, e.what());<br \/>\n    return false;<br \/>\n  }<\/p>\n<p>  AIMRT_INFO(&#034;Init succeeded.&#034;);<\/p>\n<p>  return true;<br \/>\n}<\/p>\n<p>bool NormalRpcSyncClientModule::Start() {<br \/>\n  try {<br \/>\n    run_flag_ &#061; true;<br \/>\n    executor_.Execute(std::bind(&amp;NormalRpcSyncClientModule::MainLoop, this));<br \/>\n  } catch (const std::exception&amp; e) {<br \/>\n    AIMRT_ERROR(&#034;Start failed, {}&#034;, e.what());<br \/>\n    return false;<br \/>\n  }<\/p>\n<p>  AIMRT_INFO(&#034;Start succeeded.&#034;);<br \/>\n  return true;<br \/>\n}<\/p>\n<p>void NormalRpcSyncClientModule::Shutdown() {<br \/>\n  try {<br \/>\n    if (run_flag_) {<br \/>\n      run_flag_ &#061; false;<br \/>\n      stop_sig_.get_future().wait();<br \/>\n    }<br \/>\n  } catch (const std::exception&amp; e) {<br \/>\n    AIMRT_ERROR(&#034;Shutdown failed, {}&#034;, e.what());<br \/>\n    return;<br \/>\n  }<\/p>\n<p>  AIMRT_INFO(&#034;Shutdown succeeded.&#034;);<br \/>\n}<\/p>\n<p>\/\/ Main loop<br \/>\nvoid NormalRpcSyncClientModule::MainLoop() {<br \/>\n  try {<br \/>\n    AIMRT_INFO(&#034;Start MainLoop.&#034;);<\/p>\n<p>    uint32_t count &#061; 0;<br \/>\n    while (run_flag_) {<br \/>\n      \/\/ Sleep<br \/>\n      std::this_thread::sleep_for(std::chrono::milliseconds(static_cast&lt;uint32_t&gt;(1000 \/ rpc_frq_)));<\/p>\n<p>      count&#043;&#043;;<br \/>\n      AIMRT_INFO(&#034;Loop count : {} &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#034;, count);<\/p>\n<p>      \/\/ Create req and rsp<br \/>\n      aimrt::protocols::example::GetFooDataReq req;<br \/>\n      aimrt::protocols::example::GetFooDataRsp rsp;<br \/>\n      req.set_msg(&#034;hello world foo, count &#034; &#043; std::to_string(count));<\/p>\n<p>      \/\/ Create ctx<br \/>\n      auto ctx_ptr &#061; proxy_-&gt;NewContextSharedPtr();<br \/>\n      ctx_ptr-&gt;SetTimeout(std::chrono::seconds(3));<\/p>\n<p>      AIMRT_INFO(&#034;Client start new rpc call. req: {}&#034;, aimrt::Pb2CompactJson(req));<\/p>\n<p>      \/\/ Call rpc<br \/>\n      auto status &#061; proxy_-&gt;GetFooData(ctx_ptr, req, rsp);<\/p>\n<p>      \/\/ Check result<br \/>\n      if (status.OK()) {<br \/>\n        AIMRT_INFO(&#034;Client get rpc ret, status: {}, rsp: {}&#034;, status.ToString(),<br \/>\n                   aimrt::Pb2CompactJson(rsp));<br \/>\n      } else {<br \/>\n        AIMRT_WARN(&#034;Client get rpc error ret, status: {}&#034;, status.ToString());<br \/>\n      }<br \/>\n    }<\/p>\n<p>    AIMRT_INFO(&#034;Exit MainLoop.&#034;);<br \/>\n  } catch (const std::exception&amp; e) {<br \/>\n    AIMRT_ERROR(&#034;Exit MainLoop with exception, {}&#034;, e.what());<br \/>\n  }<\/p>\n<p>  stop_sig_.set_value();<br \/>\n}<\/p>\n<p>} <\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u5bf9\u4e0a\u9762\u7684\u6a21\u5757\u8fdb\u884c\u6328\u4e2a\u5206\u6790&#xff1a;<\/p>\n<p>#include &#034;normal_rpc_sync_client_module\/normal_rpc_sync_client_module.h&#034;<br \/>\n#include &#034;aimrt_module_protobuf_interface\/util\/protobuf_tools.h&#034;<\/p>\n<p>#include &#034;yaml-cpp\/yaml.h&#034; <\/p>\n<p>\u800c\u5f53\u6211\u4eec\u9700\u8981\u5c06\u4e8c\u8fdb\u5236\u7684protobuf\u6587\u4ef6\u8f6c\u5316\u4e3a\u5176\u4ed6\u53ef\u8bfb\u7c7b\u578b\u7684\u6570\u636e\u65f6&#xff0c;\u6b64\u65f6\u5c31\u9700\u8981\u5305\u542b\u4e0b\u9762\u8fd9\u4e2a\u5934\u6587\u4ef6&#xff1a;<\/p>\n<p>#include &#034;aimrt_module_protobuf_interface\/util\/protobuf_tools.h&#034; <\/p>\n<p>\u5176\u4ed6\u7684\u5934\u6587\u4ef6\u5728\u00a0<span style=\"color:#fe2c24\">#include&#034;normal_rpc_sync_client_module\/normal_rpc_sync_client_module.h&#034;<\/span>\u5305\u542b\u7684\u90fd\u6709&#xff1b;<\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u518d\u770b<span style=\"color:#fe2c24\">\u521d\u59cb\u5316\u6a21\u5757<\/span>&#xff1a;<\/p>\n<p>bool NormalRpcSyncClientModule::Initialize(aimrt::CoreRef core) {<br \/>\n  core_ &#061; core;<\/p>\n<p>  try {<br \/>\n    \/\/ Read cfg<br \/>\n    std::string file_path &#061; std::string(core_.GetConfigurator().GetConfigFilePath());<br \/>\n    if (!file_path.empty()) {<br \/>\n      YAML::Node cfg_node &#061; YAML::LoadFile(file_path);<br \/>\n      rpc_frq_ &#061; cfg_node[&#034;rpc_frq&#034;].as&lt;double&gt;();<\/p>\n<p>      if (cfg_node[&#034;service_name&#034;]) {<br \/>\n        service_name_ &#061; cfg_node[&#034;service_name&#034;].as&lt;std::string&gt;();<br \/>\n      }<br \/>\n    }<\/p>\n<p>    \/\/ Get executor handle<br \/>\n    executor_ &#061; core_.GetExecutorManager().GetExecutor(&#034;work_thread_pool&#034;);<br \/>\n    AIMRT_CHECK_ERROR_THROW(executor_, &#034;Get executor &#039;work_thread_pool&#039; failed.&#034;);<\/p>\n<p>    \/\/ Get rpc handle<br \/>\n    auto rpc_handle &#061; core_.GetRpcHandle();<br \/>\n    AIMRT_CHECK_ERROR_THROW(rpc_handle, &#034;Get rpc handle failed.&#034;);<\/p>\n<p>    \/\/ Register rpc client<br \/>\n    bool ret &#061; false;<br \/>\n    if (service_name_.empty()) {<br \/>\n      ret &#061; aimrt::protocols::example::RegisterExampleServiceClientFunc(rpc_handle);<br \/>\n    } else {<br \/>\n      ret &#061; aimrt::protocols::example::RegisterExampleServiceClientFunc(rpc_handle, service_name_);<br \/>\n    }<br \/>\n    AIMRT_CHECK_ERROR_THROW(ret, &#034;Register client failed.&#034;);<\/p>\n<p>    \/\/ Create rpc proxy<br \/>\n    proxy_ &#061; std::make_shared&lt;aimrt::protocols::example::ExampleServiceSyncProxy&gt;(rpc_handle);<\/p>\n<p>    if (!service_name_.empty()) {<br \/>\n      proxy_-&gt;SetServiceName(service_name_);<br \/>\n    }<\/p>\n<p>  } catch (const std::exception&amp; e) {<br \/>\n    AIMRT_ERROR(&#034;Init failed, {}&#034;, e.what());<br \/>\n    return false;<br \/>\n  }<\/p>\n<p>  AIMRT_INFO(&#034;Init succeeded.&#034;);<\/p>\n<p>  return true;<br \/>\n} <\/p>\n<p><span style=\"color:#fe2c24\">\u5728\u521d\u59cb\u5316\u6a21\u5757\u4e2d&#xff0c;\u4f9d\u6b21\u8fdb\u884c&#xff1a;<\/span><\/p>\n<ul>\n<li>\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9&#xff0c;\u4e14\u5982\u679c\u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u4e86\u8bdd\u9898\u540d&#xff0c;\u6211\u4eec\u5c31\u63d0\u53d6\u91cc\u9762\u7684\u8bdd\u9898\u540d&#xff1b;<\/li>\n<li>\u83b7\u53d6\u6211\u4eec\u5bf9\u5e94\u7684\u6267\u884c\u5668\u7684\u53e5\u67c4&#xff1b;<\/li>\n<li>\u83b7\u5f97rpc\u901a\u4fe1\u7684\u53e5\u67c4&#xff1b;<\/li>\n<li>\u6ce8\u518crcp\u5ba2\u6237\u7aef&#xff1b;<\/li>\n<\/ul>\n<p>    \/\/ Register rpc client<br \/>\n    bool ret &#061; false;<br \/>\n    if (service_name_.empty()) {<br \/>\n      ret &#061; aimrt::protocols::example::RegisterExampleServiceClientFunc(rpc_handle);<br \/>\n    } else {<br \/>\n      ret &#061; aimrt::protocols::example::RegisterExampleServiceClientFunc(rpc_handle, service_name_);<br \/>\n    } <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8fd9\u91cc\u6ce8\u518c\u7684\u903b\u8f91\u4f9d\u7136\u662f&#xff1a;\u5982\u679c\u6211\u4eec\u6ca1\u6709\u8bbe\u7f6e\u670d\u52a1\u8bdd\u9898\u540d&#xff0c;\u5c31\u6309\u7167\u9ed8\u8ba4\u7684\u540d\u5b57\u8fdb\u884c\u6ce8\u518c&#xff1b;\u5426\u5219\u6309\u7167\u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u540d\u5b57\u8fdb\u884c\u6ce8\u518c&#xff1b;\u00a0<\/p>\n<p>\u9664\u6b64\u4e4b\u5916&#xff0c;\u8fd9\u91cc\u6700\u4e3b\u8981\u7684\u662f\u521b\u5efa\u4e86\u4e00\u4e2arpc\u7684proxy&#xff1b;<\/p>\n<p><span style=\"color:#fe2c24\">\u95ee\u9898&#xff1a;\u5ba2\u6237\u7aef\u5f53\u4e2d\u6211\u4eec\u5982\u4f55\u4f20\u9012\u4fe1\u606f\u7ed9\u670d\u52a1\u7aef&#xff1f;<\/span><\/p>\n<p>\u5728AimRT\u4e2d&#xff0c;\u63d0\u4f9b\u4e86\u56db\u79cd\u7c7b\u578b\u7684\u63a5\u53e3&#xff1a;<\/p>\n<ul>\n<li>\u540c\u6b65\u578b\u63a5\u53e3&#xff1a;\u540d\u79f0\u4e00\u822c\u4e3aXXXSyncProxy&#xff1b;<\/li>\n<li>\u5f02\u6b65\u56de\u8c03\u578b\u63a5\u53e3&#xff1a;\u540d\u79f0\u4e00\u822c\u4e3aXXXAsyncProxy&#xff1b;<\/li>\n<li>\u5f02\u6b65 Future \u578b\u63a5\u53e3&#xff1a;\u540d\u79f0\u4e00\u822c\u4e3aXXXFutureProxy&#xff1b;<\/li>\n<li>\u65e0\u6808\u534f\u7a0b\u578b\u63a5\u53e3&#xff1a;\u540d\u79f0\u4e00\u822c\u4e3aXXXCoProxy&#xff1b;<\/li>\n<\/ul>\n<p>\u5176\u4e2d&#xff0c;\u5728\u5934\u6587\u4ef6\u4e2d&#xff0c;\u6211\u4eec\u5df2\u7ecf\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5171\u4eab\u6307\u9488\u6765\u7ba1\u7406\u540c\u6b65\u578b\u7684proxy\u63a5\u53e3&#xff1a;<\/p>\n<p>std::shared_ptr&lt;aimrt::protocols::example::ExampleServiceSyncProxy&gt; proxy_; <\/p>\n<p>\u8fd9\u4e2a\u63a5\u53e3\u4f1a\u7ee7\u627f\u57fa\u7c7b\u7684\u4e00\u4e9b\u5171\u4eab\u63a5\u53e3&#xff1a;<\/p>\n<p>class ProxyBase {<br \/>\n public:<br \/>\n  std::string_view RpcType() const;<\/p>\n<p>  void SetServiceName(std::string_view service_name);<br \/>\n  std::string_view ServiceName() const;<\/p>\n<p>  std::shared_ptr&lt;Context&gt; NewContextSharedPtr(ContextRef ctx_ref &#061; ContextRef()) const;<\/p>\n<p>  void SetDefaultContextSharedPtr(const std::shared_ptr&lt;Context&gt;&amp; ctx_ptr);<br \/>\n  std::shared_ptr&lt;Context&gt; GetDefaultContextSharedPtr() const;<br \/>\n};<\/p>\n<p>class XXXProxy : public aimrt::rpc::CoProxyBase {<br \/>\n public:<br \/>\n  explicit XXXProxy(aimrt::rpc::RpcHandleRef rpc_handle_ref);<\/p>\n<p>  static bool RegisterClientFunc(aimrt::rpc::RpcHandleRef rpc_handle_ref);<br \/>\n  static bool RegisterClientFunc(aimrt::rpc::RpcHandleRef rpc_handle_ref, std::string_view service_name);<\/p>\n<p>  \/\/ &#8230;<br \/>\n} <\/p>\n<p>\u8be6\u7ec6\u7684\u8bb2\u89e3\u5927\u59d0\u53ef\u4ee5\u53c2\u8003\u4e0b\u9762\u7684\u94fe\u63a5&#xff1a;<\/p>\n<p>Rpc \u2014 AimRT v0.10.0 documentation<\/p>\n<p>\u63a5\u4e0b\u6765\u518d\u56de\u5230\u6211\u4eec\u7684\u521d\u59cb\u5316\u6a21\u5757\u5173\u4e8eproxy\u7684\u90e8\u5206&#xff1a;<\/p>\n<ul>\n<li>\u8fd9\u91cc\u662f\u76f8\u5f53\u4e8e\u901a\u8fc7\u4f20\u5165\u6211\u4eec\u7684rpc\u53e5\u67c4&#xff0c;\u5c06proxy\u8fdb\u884c\u5b9e\u4f8b\u5316&#xff1b;<\/li>\n<li>\u7136\u540e\u5982\u679c\u6211\u4eec\u8fd9\u91cc\u5b9a\u4e49\u4e86\u8bdd\u9898\u540d\u5c31\u8bbe\u7f6e\u8bdd\u9898\u540d&#xff0c;\u76f8\u5f53\u4e8e\u8fdb\u884c\u4e86\u4e00\u4e9b\u9884\u5907\u64cd\u4f5c&#xff1b;<\/li>\n<\/ul>\n<p><span style=\"color:#fe2c24\">\u5f00\u59cbstart\u6a21\u5757&#xff1a;<\/span><\/p>\n<p>bool NormalRpcSyncClientModule::Start() {<br \/>\n  try {<br \/>\n    run_flag_ &#061; true;<br \/>\n    executor_.Execute(std::bind(&amp;NormalRpcSyncClientModule::MainLoop, this));<br \/>\n  } catch (const std::exception&amp; e) {<br \/>\n    AIMRT_ERROR(&#034;Start failed, {}&#034;, e.what());<br \/>\n    return false;<br \/>\n  }<\/p>\n<p>  AIMRT_INFO(&#034;Start succeeded.&#034;);<br \/>\n  return true;<br \/>\n} <\/p>\n<p>\u5f00\u59cb\u6a21\u5757\u7684\u903b\u8f91\u5f88\u7b80\u5355&#xff1a;<\/p>\n<ul>\n<li>\u8fd9\u91cc\u8fd8\u662f\u5c06\u6211\u4eec\u5bf9\u5e94\u7684\u8fd0\u884c\u72b6\u6001\u6539\u4e3atrue&#xff1b;<\/li>\n<li>\u7136\u540e\u8ba9\u6267\u884c\u5668\u6267\u884c\u5bf9\u5e94\u7684MainLoop\u64cd\u4f5c&#xff1b;&#xff08;\u5728MainLoop\u91cc\u9762\u4f1a\u8fdb\u884c\u4e00\u4e9b\u6570\u636e\u7684\u5904\u7406&#xff09;&#xff1b;<\/li>\n<\/ul>\n<p><span style=\"color:#fe2c24\">\u53d1\u9001\u6d88\u606fMainLoop\u6a21\u5757&#xff1a;<\/span><\/p>\n<p>\/\/ Main loop<br \/>\nvoid NormalRpcSyncClientModule::MainLoop() {<br \/>\n  try {<br \/>\n    AIMRT_INFO(&#034;Start MainLoop.&#034;);<\/p>\n<p>    uint32_t count &#061; 0;<br \/>\n    while (run_flag_) {<br \/>\n      \/\/ Sleep<br \/>\n      std::this_thread::sleep_for(std::chrono::milliseconds(static_cast&lt;uint32_t&gt;(1000 \/ rpc_frq_)));<\/p>\n<p>      count&#043;&#043;;<br \/>\n      AIMRT_INFO(&#034;Loop count : {} &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#034;, count);<\/p>\n<p>      \/\/ Create req and rsp<br \/>\n      aimrt::protocols::example::GetFooDataReq req;<br \/>\n      aimrt::protocols::example::GetFooDataRsp rsp;<br \/>\n      req.set_msg(&#034;hello world foo, count &#034; &#043; std::to_string(count));<\/p>\n<p>      \/\/ Create ctx<br \/>\n      auto ctx_ptr &#061; proxy_-&gt;NewContextSharedPtr();<br \/>\n      ctx_ptr-&gt;SetTimeout(std::chrono::seconds(3));<\/p>\n<p>      AIMRT_INFO(&#034;Client start new rpc call. req: {}&#034;, aimrt::Pb2CompactJson(req));<\/p>\n<p>      \/\/ Call rpc<br \/>\n      auto status &#061; proxy_-&gt;GetFooData(ctx_ptr, req, rsp);<\/p>\n<p>      \/\/ Check result<br \/>\n      if (status.OK()) {<br \/>\n        AIMRT_INFO(&#034;Client get rpc ret, status: {}, rsp: {}&#034;, status.ToString(),<br \/>\n                   aimrt::Pb2CompactJson(rsp));<br \/>\n      } else {<br \/>\n        AIMRT_WARN(&#034;Client get rpc error ret, status: {}&#034;, status.ToString());<br \/>\n      }<br \/>\n    }<\/p>\n<p>    AIMRT_INFO(&#034;Exit MainLoop.&#034;);<br \/>\n  } catch (const std::exception&amp; e) {<br \/>\n    AIMRT_ERROR(&#034;Exit MainLoop with exception, {}&#034;, e.what());<br \/>\n  }<\/p>\n<p>  stop_sig_.set_value();<br \/>\n} <\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u6328\u4e2a\u5206\u6790\u4e0a\u9762\u7684\u4ee3\u7801\u903b\u8f91\u7ed3\u6784&#xff1a;<\/p>\n<ul>\n<li>\u9996\u5148&#xff0c;\u5982\u679crun_flag\u4e3atrue&#xff0c;\u8bf4\u660e\u4ee3\u7801module\u6b64\u65f6\u6846\u67b6\u662fstart&#xff0c;\u6240\u4ee5\u6211\u4eec\u9700\u8981\u53d1\u9001\u4efb\u52a1&#xff1b;<\/li>\n<li>\u63a5\u4e0b\u6765&#xff0c;\u8bbe\u7f6e\u4efb\u52a1\u7684\u6267\u884c\u9891\u7387&#xff1b;<\/li>\n<li>\u5206\u522b\u521b\u5efarep\u548crsp\u7528\u6765\u50a8\u5b58&#xff1a;\u53d1\u9001\u7684\u6d88\u606f\u548c\u63a5\u53d7\u7684\u6d88\u606f&#xff1b;<\/li>\n<li>\u63a5\u4e0b\u6765\u6211\u4eec\u8bbe\u7f6e\u6d88\u606f\u5185\u5bb9&#xff1a;<\/li>\n<\/ul>\n<p>req.set_msg(&#034;hello world foo, count &#034; &#043; std::to_string(count)); <\/p>\n<ul>\n<li>\u00a0\u63a5\u4e0b\u6765\u6211\u4eec\u521b\u5efa\u5bf9\u5e94\u7684\u540e\u7aef\u914d\u7f6e&#xff1a;<\/li>\n<\/ul>\n<p>      auto ctx_ptr &#061; proxy_-&gt;NewContextSharedPtr();<br \/>\n      ctx_ptr-&gt;SetTimeout(std::chrono::seconds(3));<\/p>\n<p>      AIMRT_INFO(&#034;Client start new rpc call. req: {}&#034;, aimrt::Pb2CompactJson(req)); <\/p>\n<ul>\n<li>\u5728proxy\u7684\u57fa\u7c7b\u4e2d&#xff0c;\u63d0\u4f9b\u4e86\u7ba1\u7406context\u540e\u7aef\u914d\u7f6e\u7684\u5171\u4eab\u6307\u9488&#xff1b;<\/li>\n<li>\u8bbe\u7f6e RPC \u8c03\u7528\u7684\u8d85\u65f6\u65f6\u95f4&#xff0c;\u5982\u679c\u8d85\u5e02\u8d85\u8fc73s&#xff0c;\u6b64\u65f6\u6846\u67b6\u4f1a\u5728\u8d85\u65f6\u540e\u81ea\u52a8\u53d6\u6d88\u7b49\u5f85\u54cd\u5e94&#xff1b;<\/li>\n<\/ul>\n<p>\u63a5\u4e0b\u6765\u8fd9\u91cc\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7proxy\u8c03\u7528\u5bf9\u5e94\u7684\u56de\u8c03\u51fd\u6570\u8fdb\u884c\u4fe1\u606f\u7684\u53d1\u9001&#xff1a;<\/p>\n<p>      \/\/ Call rpc<br \/>\n      auto status &#061; proxy_-&gt;GetFooData(ctx_ptr, req, rsp); <\/p>\n<ul>\n<li>\u5982\u679c\u8fd4\u56de\u7684start.OK()\u4e3atrue&#xff0c;\u8bf4\u660e\u6b64\u65f6\u83b7\u53d6rpc\u7684\u8fc7\u7a0b\u4e2d\u6ca1\u6709\u51fa\u73b0\u9519\u8bef&#xff01;\u6240\u4ee5\u63a5\u4e0b\u6765\u6253\u5370\u6b63\u5e38info\u4fe1\u606f&#xff1b;<\/li>\n<li>\u5426\u5219\u5c31\u6253\u5370warm\u8b66\u544a\u4fe1\u606f&#xff1b;\u00a0<\/li>\n<li>\u670d\u52a1\u5668\u56de\u590d\u5ba2\u6237\u7aef\u7684\u6d88\u606f\u4f1a\u4fdd\u5b58\u5230req\u5f53\u4e2d&#xff1b;<\/li>\n<\/ul>\n<p>stop_sig_.set_value(); <\/p>\n<p>\u6700\u540e&#xff0c;\u5f53\u5faa\u73af\u7ed3\u675f\u540e&#xff0c;\u6b64\u65f6\u8bf4\u660e\u4e0d\u4f1a\u518d\u8fdb\u884c\u6d88\u606f\u7684\u53d1\u9001&#xff0c;\u56e0\u6b64\u5411shutdown\u53d1\u9001\u5bf9\u5e94\u7684\u4fe1\u53f7&#xff1b;\u00a0<\/p>\n<p><span style=\"color:#fe2c24\">\u7ed3\u675fshutdown\u6a21\u5757&#xff1a;<\/span><\/p>\n<p>void NormalRpcSyncClientModule::Shutdown() {<br \/>\n  try {<br \/>\n    if (run_flag_) {<br \/>\n      run_flag_ &#061; false;<br \/>\n      stop_sig_.get_future().wait();<br \/>\n    }<br \/>\n  } catch (const std::exception&amp; e) {<br \/>\n    AIMRT_ERROR(&#034;Shutdown failed, {}&#034;, e.what());<br \/>\n    return;<br \/>\n  }<\/p>\n<p>  AIMRT_INFO(&#034;Shutdown succeeded.&#034;);<br \/>\n} <\/p>\n<p>\u5f53\u4fe1\u53f7\u53d1\u9001\u540e&#xff0c;\u6b64\u65f6shutdown\u4f1a\u6536\u5230\u5bf9\u5e94\u7684\u4fe1\u53f7&#xff0c;\u7136\u540e\u6210\u529f\u5173\u95ed&#xff01;<\/p>\n<h3>CMake\u94fe\u63a5\u76f8\u5173\u5e93\u00a0<\/h3>\n<p>\u5728\u4e0a\u9762\u6211\u4eec\u5df2\u7ecf\u8fdb\u884c\u4e86.proto\u6587\u4ef6\u7684\u76f8\u5173\u7f16\u8bd1&#xff0c;\u56e0\u6b64&#xff0c;\u6b64\u65f6\u5982\u679c\u6211\u4eec\u60f3\u8981\u5728\u81ea\u5df1\u7684\u6e90\u6587\u4ef6\u4e2d\u8fdb\u884c\u94fe\u63a5&#xff0c;\u5f88\u7b80\u5355&#xff0c;\u4f8b\u5982\u4e0b\u9762\u7684\u4f8b\u5b50&#xff08;\u5bf9\u5e94\u4e0a\u9762\u6211\u4eec\u7f16\u8bd1\u7684.proto\u6587\u4ef6&#xff09;&#xff1a;<\/p>\n<p>target_link_libraries(my_lib PUBLIC example_rpc_aimrt_rpc_gencode) <\/p>\n<p>\u6b64\u65f6\u5373\u53ef\u6210\u529f\u94fe\u63a5\u5bf9\u5e94\u7684\u5e93&#xff1b;<\/p>\n<h2>\u56db\u3001 \u57fa\u4e8eROS2 srv\u6d88\u606f\u7684\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668<\/h2>\n<h3>\u7f16\u5199.msg\u6587\u4ef6<\/h3>\n<p>byte[]  data<br \/>\n&#8212;<br \/>\nint64   code <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5176\u4e2d&#xff0c;\u4ee5&#8212;\u6765\u5206\u5272 Req \u548c Rsp \u7684\u5b9a\u4e49\u3002\u7136\u540e\u76f4\u63a5\u901a\u8fc7 ROS2 \u63d0\u4f9b\u7684 CMake \u65b9\u6cd5<span style=\"color:#fe2c24\">rosidl_generate_interfaces<\/span>&#xff0c;\u4e3a Req \u548c Rsp \u6d88\u606f\u751f\u6210 C&#043;&#043; \u4ee3\u7801\u548c CMake Target&#xff0c;\u4f8b\u5982&#xff1a;<\/p>\n<p>rosidl_generate_interfaces(<br \/>\n  example_srv_gencode<br \/>\n  &#034;srv\/example.srv&#034;<br \/>\n) <\/p>\n<p>\u4e4b\u540e\u5c31\u53ef\u4ee5\u5f15\u7528\u76f8\u5173\u7684 CMake Target \u6765\u4f7f\u7528\u751f\u6210\u7684 Req \u548c Rsp \u7684\u6d88\u606f\u7ed3\u6784 C&#043;&#043; \u4ee3\u7801&#xff1b;<\/p>\n<p>\u4f46\u662f\u5b9e\u9645\u4e0a&#xff0c;\u7ecf\u8fc7\u4e0a\u9762\u7684\u64cd\u4f5c&#xff0c;\u6211\u4eec\u5bf9\u4e8e\u751f\u6210\u7684\u6d88\u606f\u8fd8\u662f\u4e0d\u80fd\u76f4\u63a5\u8fdb\u884c\u8c03\u7528&#xff1b;<\/p>\n<p>\u5728\u751f\u6210\u4e86 Req \u548c Rsp \u6d88\u606f\u7ed3\u6784\u7684 C&#043;&#043; \u4ee3\u7801\u540e&#xff0c;\u6211\u4eec\u8fd8\u9700\u8981\u4f7f\u7528 AimRT \u63d0\u4f9b\u7684 Python \u811a\u672c\u5de5\u5177&#xff0c;\u751f\u6210\u670d\u52a1\u5b9a\u4e49\u90e8\u5206\u7684 C&#043;&#043; \u6869\u4ee3\u7801&#xff0c;\u4f8b\u5982&#xff1a;<\/p>\n<p>python3 ARGS .\/ros2_py_gen_aimrt_cpp_rpc.py &#8211;pkg_name&#061;example_pkg &#8211;srv_file&#061;.\/example.srv &#8211;output_path&#061;.\/ <\/p>\n<p>\u6b64\u65f6\u5373\u4f1a\u751f\u6210\u5bf9\u5e94\u7684<span style=\"color:#fe2c24\">example.aimrt_rpc.srv.h<\/span>\u548c<span style=\"color:#fe2c24\">example.aimrt_rpc.srv.cc<\/span>\u6587\u4ef6&#xff1b;<\/p>\n<p>\u4f46\u662f\u5b9e\u9645\u4e0a&#xff0c;\u4e0d\u9700\u8981\u8fd9\u4e48\u9ebb\u70e6\u7684\u81ea\u5df1\u8fdb\u884c\u7f16\u8bd1&#xff0c;AimRT\u5185\u90e8\u4e5f\u7ed9\u6211\u4eec\u63d0\u4f9b\u4e86\u5185\u7f6e\u7684CMake\u7f16\u8bd1\u6307\u4ee4&#xff1a;<\/p>\n<ul>\n<li>\n<p><span style=\"color:#fe2c24\">add_ros2_aimrt_rpc_gencode_target_for_one_file<\/span>&#xff1a;\u4e3a\u5355\u4e2a srv \u6587\u4ef6\u751f\u6210 RPC \u670d\u52a1 C&#043;&#043; \u4ee3\u7801&#xff0c;\u53c2\u6570\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\n<p>TARGET_NAME&#xff1a;\u751f\u6210\u7684 CMake Target \u540d\u79f0&#xff1b;<\/p>\n<\/li>\n<li>\n<p>PACKAGE_NAME&#xff1a;ROS2 \u534f\u8bae PKG \u7684\u540d\u79f0&#xff1b;<\/p>\n<\/li>\n<li>\n<p>PROTO_FILE&#xff1a;\u534f\u8bae\u6587\u4ef6\u7684\u8def\u5f84&#xff1b;<\/p>\n<\/li>\n<li>\n<p>GENCODE_PATH&#xff1a;\u751f\u6210\u7684\u6869\u4ee3\u7801\u5b58\u653e\u8def\u5f84&#xff1b;<\/p>\n<\/li>\n<li>\n<p>DEP_PROTO_TARGETS&#xff1a;\u4f9d\u8d56\u7684\u534f\u8bae CMake Target&#xff1b;<\/p>\n<\/li>\n<li>\n<p>OPTIONS&#xff1a;\u4f20\u9012\u7ed9\u5de5\u5177\u7684\u5176\u4ed6\u53c2\u6570&#xff1b;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u4f8b\u5982\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50&#xff1a;<\/p>\n<p># Generate C&#043;&#043; code for Req and Rsp message in &#096;.srv&#096; file<br \/>\nrosidl_generate_interfaces(<br \/>\n  example_srv_gencode<br \/>\n  &#034;srv\/example.srv&#034;<br \/>\n)<\/p>\n<p># Generate RPC service C&#043;&#043; code for the example &#039;.srv&#039; file. It is necessary to rely on the CMake Target related to ROS2 messages, which is defined in &#039;${ROS2_EXAMPLE_CMAKE_TARGETS}&#039;<br \/>\nadd_ros2_aimrt_rpc_gencode_target_for_one_file(<br \/>\n  TARGET_NAME example_ros2_rpc_aimrt_rpc_gencode<br \/>\n  PACKAGE_NAME example_pkg<br \/>\n  PROTO_FILE ${CMAKE_CURRENT_SOURCE_DIR}\/srv\/example.srv<br \/>\n  GENCODE_PATH ${CMAKE_CURRENT_BINARY_DIR}<br \/>\n  DEP_PROTO_TARGETS<br \/>\n    rclcpp::rclcpp<br \/>\n    ${ROS2_EXAMPLE_CMAKE_TARGETS}) <\/p>\n<ul>\n<li>rosidl_generate_interfaces&#xff1a;\u8d1f\u8d23\u5c06\u6d88\u606f\u7ed3\u6784\u4f53\u90e8\u5206\u751f\u6210\u5bf9\u5e94\u7684C&#043;&#043;\u4ee3\u7801&#xff1b;<\/li>\n<li>add_ros2_aimrt_rpc_gencode_target_for_one_file&#xff1a;\u518d\u5c06\u5bf9\u5e94\u7684C&#043;&#043;\u4ee3\u7801\u751f\u6210C&#043;&#043;\u7684\u670d\u52a1\u4ee3\u7801&#xff1b;<\/li>\n<li>\u4e8c\u8005\u7f3a\u4e00\u4e0d\u53ef&#xff1b;<\/li>\n<\/ul>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5176\u4ed6\u7684\u5173\u4e8e\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u7684\u65f6\u5019&#xff0c;\u4e0eprotobuf\u5b8c\u5168\u76f8\u540c&#xff0c;\u4e0d\u540c\u7684\u662f\u5c06\u5bf9\u5e94\u7684\u6d88\u606f\u7c7b\u578b\u6539\u4e3aROS\u5373\u53ef&#xff0c;\u56e0\u6b64\u8fd9\u91cc\u6211\u4eec\u4e0d\u518d\u8fdb\u884c\u8fc7\u591a\u7684\u89e3\u91ca&#xff1b;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u622a\u6b62\u5230\u8fd9\u91cc\u6211\u4eec\u5bf9AimRT\u7684\u6846\u67b6\u5df2\u7ecf\u660e\u767d\u4e86\u4e0d\u5c11&#xff0c;\u63a5\u4e0b\u6765\u6709\u673a\u4f1a\u4f1a\u53d1\u5e03\u5173\u4e8eAImRT\u4e2d\u7684rpc\u540e\u7aef\u7684\u76f8\u5173\u4ecb\u7ecd&#xff1b;<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb870\u6b21\uff0c\u70b9\u8d5e14\u6b21\uff0c\u6536\u85cf16\u6b21\u3002\u670d\u52a1\u901a\u4fe1\u4e5f\u662fROS\u4e2d\u4e00\u79cd\u6781\u5176\u5e38\u7528\u7684\u901a\u4fe1\u6a21\u5f0f\uff0c\u670d\u52a1\u901a\u4fe1\u662f\u57fa\u4e8e\u8bf7\u6c42\u54cd\u5e94\u6a21\u5f0f\u7684\uff0c\u662f\u4e00\u79cd\u5e94\u7b54\u673a\u5236\u3002\u4e5f\u5373\uff1a\u4e00\u4e2a\u8282\u70b9A\u5411\u53e6\u4e00\u4e2a\u8282\u70b9B\u53d1\u9001\u8bf7\u6c42\uff0cB\u63a5\u6536\u5904\u7406\u8bf7\u6c42\u5e76\u4ea7\u751f\u54cd\u5e94\u7ed3\u679c\u8fd4\u56de\u7ed9A\u3002\u6bd4\u5982\u5982\u4e0b\u573a\u666f\uff1a\u5728\u4e0a\u8ff0\u573a\u666f\u4e2d\uff0c\u5c31\u4f7f\u7528\u5230\u4e86\u670d\u52a1\u901a\u4fe1\u3002\u4e0e\u4e0a\u8ff0\u5e94\u7528\u7c7b\u4f3c\u7684\uff0c\u670d\u52a1\u901a\u4fe1\u66f4\u9002\u7528\u4e8e\u5bf9\u5b9e\u65f6\u6027\u6709\u8981\u6c42\u3001\u5177\u6709\u4e00\u5b9a\u903b\u8f91\u5904\u7406\u7684\u5e94\u7528\u573a\u666f\u3002\u6982\u5ff5        \u670d\u52a1\u901a\u4fe1\u662f\u4ee5\u8bf7\u6c42\u54cd\u5e94\u7684\u65b9\u5f0f\u5b9e\u73b0\u4e0d\u540c\u8282\u70b9\u4e4b\u95f4\u6570\u636e\u4f20\u8f93\u7684\u901a\u4fe1\u6a21\u5f0f\u3002\u53d1\u9001\u8bf7\u6c42\u6570\u636e\u7684\u5bf9\u8c61\u79f0\u4e3a\u5ba2\u6237\u7aef\uff0c\u63a5\u6536\u8bf7\u6c42\u5e76\u53d1\u9001\u54cd\u5e94\u7684\u5bf9\u8c61\u79f0\u4e4b\u4e3a\u670d\u52a1\u7aef\uff0c\u540c\u8bdd\u9898\u901a\u4fe1\u4e00\u6837\uff0c\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u4e5f\u901a\u8fc7\u8bdd\u9898\u76f8\u5173\u8054\uff0c\u4e0d\u540c\u7684\u662f\u670d\u52a1\u901a\u4fe1\u7684\u6570<\/p>\n","protected":false},"author":2,"featured_media":35859,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3062,55,58,43,44],"topic":[],"class_list":["post-35863","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-aimrt","tag-c","tag-linux","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>AimRT\u4ece\u5165\u95e8\u5230\u7cbe\u901a - 04RPC\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/35863.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AimRT\u4ece\u5165\u95e8\u5230\u7cbe\u901a - 04RPC\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb870\u6b21\uff0c\u70b9\u8d5e14\u6b21\uff0c\u6536\u85cf16\u6b21\u3002\u670d\u52a1\u901a\u4fe1\u4e5f\u662fROS\u4e2d\u4e00\u79cd\u6781\u5176\u5e38\u7528\u7684\u901a\u4fe1\u6a21\u5f0f\uff0c\u670d\u52a1\u901a\u4fe1\u662f\u57fa\u4e8e\u8bf7\u6c42\u54cd\u5e94\u6a21\u5f0f\u7684\uff0c\u662f\u4e00\u79cd\u5e94\u7b54\u673a\u5236\u3002\u4e5f\u5373\uff1a\u4e00\u4e2a\u8282\u70b9A\u5411\u53e6\u4e00\u4e2a\u8282\u70b9B\u53d1\u9001\u8bf7\u6c42\uff0cB\u63a5\u6536\u5904\u7406\u8bf7\u6c42\u5e76\u4ea7\u751f\u54cd\u5e94\u7ed3\u679c\u8fd4\u56de\u7ed9A\u3002\u6bd4\u5982\u5982\u4e0b\u573a\u666f\uff1a\u5728\u4e0a\u8ff0\u573a\u666f\u4e2d\uff0c\u5c31\u4f7f\u7528\u5230\u4e86\u670d\u52a1\u901a\u4fe1\u3002\u4e0e\u4e0a\u8ff0\u5e94\u7528\u7c7b\u4f3c\u7684\uff0c\u670d\u52a1\u901a\u4fe1\u66f4\u9002\u7528\u4e8e\u5bf9\u5b9e\u65f6\u6027\u6709\u8981\u6c42\u3001\u5177\u6709\u4e00\u5b9a\u903b\u8f91\u5904\u7406\u7684\u5e94\u7528\u573a\u666f\u3002\u6982\u5ff5    \u670d\u52a1\u901a\u4fe1\u662f\u4ee5\u8bf7\u6c42\u54cd\u5e94\u7684\u65b9\u5f0f\u5b9e\u73b0\u4e0d\u540c\u8282\u70b9\u4e4b\u95f4\u6570\u636e\u4f20\u8f93\u7684\u901a\u4fe1\u6a21\u5f0f\u3002\u53d1\u9001\u8bf7\u6c42\u6570\u636e\u7684\u5bf9\u8c61\u79f0\u4e3a\u5ba2\u6237\u7aef\uff0c\u63a5\u6536\u8bf7\u6c42\u5e76\u53d1\u9001\u54cd\u5e94\u7684\u5bf9\u8c61\u79f0\u4e4b\u4e3a\u670d\u52a1\u7aef\uff0c\u540c\u8bdd\u9898\u901a\u4fe1\u4e00\u6837\uff0c\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u4e5f\u901a\u8fc7\u8bdd\u9898\u76f8\u5173\u8054\uff0c\u4e0d\u540c\u7684\u662f\u670d\u52a1\u901a\u4fe1\u7684\u6570\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/35863.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-06T21:46:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250506214558-681a8316b07ea.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/35863.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/35863.html\",\"name\":\"AimRT\u4ece\u5165\u95e8\u5230\u7cbe\u901a - 04RPC\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-06T21:46:01+00:00\",\"dateModified\":\"2025-05-06T21:46:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/35863.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/35863.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/35863.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AimRT\u4ece\u5165\u95e8\u5230\u7cbe\u901a - 04RPC\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"AimRT\u4ece\u5165\u95e8\u5230\u7cbe\u901a - 04RPC\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/35863.html","og_locale":"zh_CN","og_type":"article","og_title":"AimRT\u4ece\u5165\u95e8\u5230\u7cbe\u901a - 04RPC\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb870\u6b21\uff0c\u70b9\u8d5e14\u6b21\uff0c\u6536\u85cf16\u6b21\u3002\u670d\u52a1\u901a\u4fe1\u4e5f\u662fROS\u4e2d\u4e00\u79cd\u6781\u5176\u5e38\u7528\u7684\u901a\u4fe1\u6a21\u5f0f\uff0c\u670d\u52a1\u901a\u4fe1\u662f\u57fa\u4e8e\u8bf7\u6c42\u54cd\u5e94\u6a21\u5f0f\u7684\uff0c\u662f\u4e00\u79cd\u5e94\u7b54\u673a\u5236\u3002\u4e5f\u5373\uff1a\u4e00\u4e2a\u8282\u70b9A\u5411\u53e6\u4e00\u4e2a\u8282\u70b9B\u53d1\u9001\u8bf7\u6c42\uff0cB\u63a5\u6536\u5904\u7406\u8bf7\u6c42\u5e76\u4ea7\u751f\u54cd\u5e94\u7ed3\u679c\u8fd4\u56de\u7ed9A\u3002\u6bd4\u5982\u5982\u4e0b\u573a\u666f\uff1a\u5728\u4e0a\u8ff0\u573a\u666f\u4e2d\uff0c\u5c31\u4f7f\u7528\u5230\u4e86\u670d\u52a1\u901a\u4fe1\u3002\u4e0e\u4e0a\u8ff0\u5e94\u7528\u7c7b\u4f3c\u7684\uff0c\u670d\u52a1\u901a\u4fe1\u66f4\u9002\u7528\u4e8e\u5bf9\u5b9e\u65f6\u6027\u6709\u8981\u6c42\u3001\u5177\u6709\u4e00\u5b9a\u903b\u8f91\u5904\u7406\u7684\u5e94\u7528\u573a\u666f\u3002\u6982\u5ff5    \u670d\u52a1\u901a\u4fe1\u662f\u4ee5\u8bf7\u6c42\u54cd\u5e94\u7684\u65b9\u5f0f\u5b9e\u73b0\u4e0d\u540c\u8282\u70b9\u4e4b\u95f4\u6570\u636e\u4f20\u8f93\u7684\u901a\u4fe1\u6a21\u5f0f\u3002\u53d1\u9001\u8bf7\u6c42\u6570\u636e\u7684\u5bf9\u8c61\u79f0\u4e3a\u5ba2\u6237\u7aef\uff0c\u63a5\u6536\u8bf7\u6c42\u5e76\u53d1\u9001\u54cd\u5e94\u7684\u5bf9\u8c61\u79f0\u4e4b\u4e3a\u670d\u52a1\u7aef\uff0c\u540c\u8bdd\u9898\u901a\u4fe1\u4e00\u6837\uff0c\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u4e5f\u901a\u8fc7\u8bdd\u9898\u76f8\u5173\u8054\uff0c\u4e0d\u540c\u7684\u662f\u670d\u52a1\u901a\u4fe1\u7684\u6570","og_url":"https:\/\/www.wsisp.com\/helps\/35863.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-06T21:46:01+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250506214558-681a8316b07ea.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"15 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/35863.html","url":"https:\/\/www.wsisp.com\/helps\/35863.html","name":"AimRT\u4ece\u5165\u95e8\u5230\u7cbe\u901a - 04RPC\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-06T21:46:01+00:00","dateModified":"2025-05-06T21:46:01+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/35863.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/35863.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/35863.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"AimRT\u4ece\u5165\u95e8\u5230\u7cbe\u901a - 04RPC\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/35863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=35863"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/35863\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/35859"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=35863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=35863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=35863"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=35863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}