diff --git a/rclpy/src/rclpy/client.hpp b/rclpy/src/rclpy/client.hpp index 4b8ebb794..26f6b92a6 100644 --- a/rclpy/src/rclpy/client.hpp +++ b/rclpy/src/rclpy/client.hpp @@ -49,11 +49,12 @@ class Client : public Destroyable, public std::enable_shared_from_this * \param[in] pyqos QoSProfile python object for this client * \param[in] clock Clock to use for service event timestamps */ - Client(Node & node, py::object pysrv_type, const char * service_name, py::object pyqos, - Clock & clock) - : Client( - node, std::move(pysrv_type), service_name, std::move(pyqos), - rcl_publisher_get_default_options().qos, clock){} + Client( + Node & node, py::object pysrv_type, const char * service_name, py::object pyqos, + Clock & clock) + : Client( + node, std::move(pysrv_type), service_name, std::move(pyqos), + rcl_publisher_get_default_options().qos, clock) {} /// Create a client /** @@ -71,12 +72,13 @@ class Client : public Destroyable, public std::enable_shared_from_this * \param[in] pyqos_service_event_pub QoSProfile python object for the service event publisher * \param[in] clock Clock to use for service event timestamps */ - Client(Node & node, py::object pysrv_type, const char * service_name, py::object pyqos, - py::object pyqos_service_event_pub, Clock & clock) - : Client( - node, std::move(pysrv_type), service_name, std::move(pyqos), - pyqos_service_event_pub.is_none() ? rcl_publisher_get_default_options().qos : pyqos_service_event_pub.cast(), - clock){} + Client( + Node & node, py::object pysrv_type, const char * service_name, py::object pyqos, + py::object pyqos_service_event_pub, Clock & clock) + : Client( + node, std::move(pysrv_type), service_name, std::move(pyqos), + pyqos_service_event_pub.is_none() ? rcl_publisher_get_default_options().qos : pyqos_service_event_pub.cast(), + clock) {} ~Client() = default; @@ -122,8 +124,9 @@ class Client : public Destroyable, public std::enable_shared_from_this destroy() override; private: - Client(Node & node, py::object pysrv_type, const char * service_name, py::object pyqos, - rmw_qos_profile_t pyqos_service_event_pub, Clock & clock); + Client( + Node & node, py::object pysrv_type, const char * service_name, py::object pyqos, + rmw_qos_profile_t pyqos_service_event_pub, Clock & clock); Node node_; std::shared_ptr rcl_client_; }; diff --git a/rclpy/src/rclpy/service.cpp b/rclpy/src/rclpy/service.cpp index 301d1a362..f361b8d4f 100644 --- a/rclpy/src/rclpy/service.cpp +++ b/rclpy/src/rclpy/service.cpp @@ -39,11 +39,11 @@ Service::destroy() } Service::Service( - Node & node, py::object pysrv_type, std::string service_name, py::object pyqos_srv_profile, - rmw_qos_profile_t service_event_publisher_qos, Clock & clock) + Node & node, py::object pysrv_type, std::string service_name, py::object pyqos_srv_profile, + rmw_qos_profile_t service_event_publisher_qos, Clock & clock) : node_(node) { - auto *srv_type = static_cast( + auto * srv_type = static_cast( common_get_type_support(pysrv_type)); if (nullptr == srv_type) { throw py::error_already_set(); diff --git a/rclpy/src/rclpy/service.hpp b/rclpy/src/rclpy/service.hpp index 945a0f2e6..d5b262241 100644 --- a/rclpy/src/rclpy/service.hpp +++ b/rclpy/src/rclpy/service.hpp @@ -58,9 +58,9 @@ class Service : public Destroyable, public std::enable_shared_from_this std::string service_name, py::object pyqos_profile, Clock & clock) - : Service( - node, std::move(pysrv_type), std::move(service_name), std::move(pyqos_profile), - rcl_service_get_default_options().qos, clock){} + : Service( + node, std::move(pysrv_type), std::move(service_name), std::move(pyqos_profile), + rcl_service_get_default_options().qos, clock) {} /// Create a service server /** @@ -85,10 +85,10 @@ class Service : public Destroyable, public std::enable_shared_from_this py::object pyqos_srv_profile, py::object pyqos_service_event_pub, Clock & clock) - : Service( - node, std::move(pysrv_type), std::move(service_name), std::move(pyqos_srv_profile), - pyqos_service_event_pub.is_none() ? rcl_publisher_get_default_options().qos : pyqos_service_event_pub.cast(), - clock){} + : Service( + node, std::move(pysrv_type), std::move(service_name), std::move(pyqos_srv_profile), + pyqos_service_event_pub.is_none() ? rcl_publisher_get_default_options().qos : pyqos_service_event_pub.cast(), + clock) {} Service( Node & node, std::shared_ptr rcl_service); diff --git a/rclpy/src/rclpy/service_introspection.cpp b/rclpy/src/rclpy/service_introspection.cpp index 7cf698b97..f0057577f 100644 --- a/rclpy/src/rclpy/service_introspection.cpp +++ b/rclpy/src/rclpy/service_introspection.cpp @@ -19,28 +19,40 @@ #include "rcl/client.h" #include "rcl/service.h" -namespace rclpy { +namespace rclpy +{ #include void define_service_introspection(py::module_ module) { - py::module_ m2 = module.def_submodule("service_introspection", - "utilities for introspecting services"); - m2.def("configure_service_events", - [](size_t srv, size_t node, bool opt) { - return rcl_service_introspection_configure_server_service_events(reinterpret_cast(srv), reinterpret_cast(node), opt); - }); - m2.def("configure_client_events", - [](size_t clt, size_t node, bool opt) { - return rcl_service_introspection_configure_client_service_events(reinterpret_cast(clt), reinterpret_cast(node), opt); - }); - m2.def("configure_service_message_payload", [](size_t srv, bool opt){ - return rcl_service_introspection_configure_server_service_event_message_payload(reinterpret_cast(srv), opt); - }); - m2.def("configure_client_message_payload", [](size_t clt, bool opt) { - return rcl_service_introspection_configure_client_service_event_message_payload(reinterpret_cast(clt), opt); - }); + py::module_ m2 = module.def_submodule( + "service_introspection", + "utilities for introspecting services"); + m2.def( + "configure_service_events", + [](size_t srv, size_t node, bool opt) { + return rcl_service_introspection_configure_server_service_events( + reinterpret_cast< + rcl_service_t *>(srv), reinterpret_cast(node), opt); + }); + m2.def( + "configure_client_events", + [](size_t clt, size_t node, bool opt) { + return rcl_service_introspection_configure_client_service_events( + reinterpret_cast(clt), reinterpret_cast(node), opt); + }); + m2.def( + "configure_service_message_payload", [](size_t srv, bool opt){ + return rcl_service_introspection_configure_server_service_event_message_payload( + reinterpret_cast(srv), opt); + }); + m2.def( + "configure_client_message_payload", [](size_t clt, bool opt) { + return rcl_service_introspection_configure_client_service_event_message_payload( + reinterpret_cast(clt), opt); + }); m2.attr("RCL_SERVICE_INTROSPECTION_PUBLISH_CLIENT_PARAMETER") = RCL_SERVICE_INTROSPECTION_PUBLISH_CLIENT_PARAMETER; m2.attr("RCL_SERVICE_INTROSPECTION_PUBLISH_SERVICE_PARAMETER") = @@ -50,5 +62,5 @@ define_service_introspection(py::module_ module) m2.attr("RCL_SERVICE_INTROSPECTION_PUBLISH_SERVICE_EVENT_CONTENT_PARAMETER") = RCL_SERVICE_INTROSPECTION_PUBLISH_SERVICE_EVENT_CONTENT_PARAMETER; m2.attr("RCL_SERVICE_INTROSPECTION_TOPIC_POSTFIX") = RCL_SERVICE_INTROSPECTION_TOPIC_POSTFIX; -} +} } // namespace rclpy diff --git a/rclpy/src/rclpy/service_introspection.hpp b/rclpy/src/rclpy/service_introspection.hpp index 922f3857f..d06f7a156 100644 --- a/rclpy/src/rclpy/service_introspection.hpp +++ b/rclpy/src/rclpy/service_introspection.hpp @@ -19,7 +19,8 @@ namespace py = pybind11; -namespace rclpy { +namespace rclpy +{ void define_service_introspection(py::module_ module);