| 98 | } |
| 99 | |
| 100 | inline std::tuple<aimrt::rpc::Status, pybind11::object> Ros2RpcHandleRefInvoke( |
| 101 | aimrt::rpc::RpcHandleRef& rpc_handle_ref, |
| 102 | std::string_view func_name, |
| 103 | aimrt::rpc::ContextRef ctx_ref, |
| 104 | pybind11::object req, |
| 105 | pybind11::object rsp_type) { |
| 106 | auto req_ptr = convert_from_py(req); |
| 107 | if (!req_ptr) { |
| 108 | throw py::error_already_set(); |
| 109 | } |
| 110 | |
| 111 | auto rsp_create = get_create_ros_message_function(rsp_type); |
| 112 | auto* rsp_ptr = rsp_create(); |
| 113 | |
| 114 | pybind11::gil_scoped_release release; |
| 115 | |
| 116 | std::promise<uint32_t> status_promise; |
| 117 | aimrt::rpc::ClientCallback callback([&status_promise](uint32_t status) { |
| 118 | status_promise.set_value(status); |
| 119 | }); |
| 120 | |
| 121 | rpc_handle_ref.Invoke( |
| 122 | func_name, |
| 123 | ctx_ref, |
| 124 | static_cast<const void*>(req_ptr.get()), |
| 125 | rsp_ptr, |
| 126 | std::move(callback)); |
| 127 | |
| 128 | auto fu = status_promise.get_future(); |
| 129 | fu.wait(); |
| 130 | |
| 131 | pybind11::gil_scoped_acquire acquire; |
| 132 | |
| 133 | auto rsp_convert_to_py = get_convert_to_py_function(rsp_type); |
| 134 | |
| 135 | auto rsp_obj = pybind11::reinterpret_steal<pybind11::object>(rsp_convert_to_py(rsp_ptr)); |
| 136 | if (!rsp_obj) { |
| 137 | throw py::error_already_set(); |
| 138 | } |
| 139 | |
| 140 | return {aimrt::rpc::Status(fu.get()), rsp_obj}; |
| 141 | } |
| 142 | |
| 143 | inline void ExportRos2RpcServiceFunc(pybind11::module& m) { |
| 144 | m.def("Ros2RegisterServiceFunc", &Ros2RpcServiceBaseRegisterServiceFunc); |
nothing calls this directly
no test coverage detected