From 688c83a44c01b328d9cda765e30bf270627f0a49 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Wed, 23 Aug 2017 14:29:37 -0700 Subject: [PATCH] expose rcl handles --- rclcpp/include/rclcpp/client.hpp | 8 ++++++++ rclcpp/include/rclcpp/publisher.hpp | 12 ++++++++++++ rclcpp/include/rclcpp/service.hpp | 10 +++++++++- rclcpp/include/rclcpp/subscription.hpp | 4 ++++ rclcpp/src/rclcpp/client.cpp | 12 ++++++++++++ rclcpp/src/rclcpp/publisher.cpp | 12 ++++++++++++ rclcpp/src/rclcpp/service.cpp | 14 +++++++++++++- rclcpp/src/rclcpp/subscription.cpp | 6 ++++++ 8 files changed, 76 insertions(+), 2 deletions(-) diff --git a/rclcpp/include/rclcpp/client.hpp b/rclcpp/include/rclcpp/client.hpp index e8f1e35..482d29b 100644 --- a/rclcpp/include/rclcpp/client.hpp +++ b/rclcpp/include/rclcpp/client.hpp @@ -68,6 +68,10 @@ public: const std::string & get_service_name() const; + RCLCPP_PUBLIC + rcl_client_t * + get_client_handle(); + RCLCPP_PUBLIC const rcl_client_t * get_client_handle() const; @@ -100,6 +104,10 @@ protected: RCLCPP_PUBLIC rcl_node_t * + get_rcl_node_handle(); + + RCLCPP_PUBLIC + const rcl_node_t * get_rcl_node_handle() const; rclcpp::node_interfaces::NodeGraphInterface::WeakPtr node_graph_; diff --git a/rclcpp/include/rclcpp/publisher.hpp b/rclcpp/include/rclcpp/publisher.hpp index 62d76bf..ce6a91e 100644 --- a/rclcpp/include/rclcpp/publisher.hpp +++ b/rclcpp/include/rclcpp/publisher.hpp @@ -98,6 +98,18 @@ public: const rmw_gid_t & get_intra_process_gid() const; + /// Get the rcl publisher handle. + /** \return The rcl publisher handle. */ + RCLCPP_PUBLIC + rcl_publisher_t * + get_publisher_handle(); + + /// Get the rcl publisher handle. + /** \return The rcl publisher handle. */ + RCLCPP_PUBLIC + const rcl_publisher_t * + get_publisher_handle() const; + /// Compare this publisher to a gid. /** * Note that this function calls the next function. diff --git a/rclcpp/include/rclcpp/service.hpp b/rclcpp/include/rclcpp/service.hpp index 7279dc3..f05b58f 100644 --- a/rclcpp/include/rclcpp/service.hpp +++ b/rclcpp/include/rclcpp/service.hpp @@ -60,9 +60,13 @@ public: get_service_name(); RCLCPP_PUBLIC - const rcl_service_t * + rcl_service_t * get_service_handle(); + RCLCPP_PUBLIC + const rcl_service_t * + get_service_handle() const; + virtual std::shared_ptr create_request() = 0; virtual std::shared_ptr create_request_header() = 0; virtual void handle_request( @@ -74,6 +78,10 @@ protected: RCLCPP_PUBLIC rcl_node_t * + get_rcl_node_handle(); + + RCLCPP_PUBLIC + const rcl_node_t * get_rcl_node_handle() const; std::shared_ptr node_handle_; diff --git a/rclcpp/include/rclcpp/subscription.hpp b/rclcpp/include/rclcpp/subscription.hpp index 38d53bf..6f081af 100644 --- a/rclcpp/include/rclcpp/subscription.hpp +++ b/rclcpp/include/rclcpp/subscription.hpp @@ -78,6 +78,10 @@ public: const char * get_topic_name() const; + RCLCPP_PUBLIC + rcl_subscription_t * + get_subscription_handle(); + RCLCPP_PUBLIC const rcl_subscription_t * get_subscription_handle() const; diff --git a/rclcpp/src/rclcpp/client.cpp b/rclcpp/src/rclcpp/client.cpp index 0d29715..a1db27f 100644 --- a/rclcpp/src/rclcpp/client.cpp +++ b/rclcpp/src/rclcpp/client.cpp @@ -48,6 +48,12 @@ ClientBase::get_service_name() const return this->service_name_; } +rcl_client_t * +ClientBase::get_client_handle() +{ + return &client_handle_; +} + const rcl_client_t * ClientBase::get_client_handle() const { @@ -115,6 +121,12 @@ ClientBase::wait_for_service_nanoseconds(std::chrono::nanoseconds timeout) } rcl_node_t * +ClientBase::get_rcl_node_handle() +{ + return node_handle_.get(); +} + +const rcl_node_t * ClientBase::get_rcl_node_handle() const { return node_handle_.get(); diff --git a/rclcpp/src/rclcpp/publisher.cpp b/rclcpp/src/rclcpp/publisher.cpp index 5ebfd2a..7302f6c 100644 --- a/rclcpp/src/rclcpp/publisher.cpp +++ b/rclcpp/src/rclcpp/publisher.cpp @@ -125,6 +125,18 @@ PublisherBase::get_intra_process_gid() const return intra_process_rmw_gid_; } +rcl_publisher_t * +PublisherBase::get_publisher_handle() +{ + return &publisher_handle_; +} + +const rcl_publisher_t * +PublisherBase::get_publisher_handle() const +{ + return &publisher_handle_; +} + bool PublisherBase::operator==(const rmw_gid_t & gid) const { diff --git a/rclcpp/src/rclcpp/service.cpp b/rclcpp/src/rclcpp/service.cpp index 4adcc73..4a421e2 100644 --- a/rclcpp/src/rclcpp/service.cpp +++ b/rclcpp/src/rclcpp/service.cpp @@ -46,13 +46,25 @@ ServiceBase::get_service_name() return this->service_name_; } -const rcl_service_t * +rcl_service_t * ServiceBase::get_service_handle() { return service_handle_; } +const rcl_service_t * +ServiceBase::get_service_handle() const +{ + return service_handle_; +} + rcl_node_t * +ServiceBase::get_rcl_node_handle() +{ + return node_handle_.get(); +} + +const rcl_node_t * ServiceBase::get_rcl_node_handle() const { return node_handle_.get(); diff --git a/rclcpp/src/rclcpp/subscription.cpp b/rclcpp/src/rclcpp/subscription.cpp index 81f08d8..1b84088 100644 --- a/rclcpp/src/rclcpp/subscription.cpp +++ b/rclcpp/src/rclcpp/subscription.cpp @@ -79,6 +79,12 @@ SubscriptionBase::get_topic_name() const return rcl_subscription_get_topic_name(&subscription_handle_); } +rcl_subscription_t * +SubscriptionBase::get_subscription_handle() +{ + return &subscription_handle_; +} + const rcl_subscription_t * SubscriptionBase::get_subscription_handle() const {