.. _program_listing_file_include_hri_hri.hpp: Program Listing for File hri.hpp ================================ |exhale_lsh| :ref:`Return to documentation for file ` (``include/hri/hri.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright (c) 2023 PAL Robotics S.L. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef HRI__HRI_HPP_ #define HRI__HRI_HPP_ #include #include #include #include #include #include "hri_msgs/msg/ids_list.hpp" #include "rclcpp/rclcpp.hpp" #include "tf2_ros/buffer.h" #include "tf2_ros/transform_listener.h" #include "hri/body.hpp" #include "hri/face.hpp" #include "hri/feature_tracker.hpp" #include "hri/person.hpp" #include "hri/types.hpp" #include "hri/voice.hpp" namespace hri { class HRIListener : public std::enable_shared_from_this { public: [[nodiscard]] static std::shared_ptr create(NodeLikeSharedPtr node_like) { return std::shared_ptr(new HRIListener(node_like)); } virtual ~HRIListener(); std::map getFaces() const; void onFace(std::function callback) { face_callbacks_.push_back(callback); } void onFaceLost(std::function callback) { face_lost_callbacks_.push_back(callback); } std::map getBodies() const; void onBody(std::function callback) { body_callbacks_.push_back(callback); } void onBodyLost(std::function callback) { body_lost_callbacks_.push_back(callback); } std::map getVoices() const; void onVoice(std::function callback) { voice_callbacks_.push_back(callback); } void onVoiceLost(std::function callback) { voice_lost_callbacks_.push_back(callback); } std::map getPersons() const; void onPerson(std::function callback) { person_callbacks_.push_back(callback); } void onPersonLost(std::function callback) { person_lost_callbacks_.push_back(callback); } std::map getTrackedPersons() const; void onTrackedPerson(std::function callback) { person_tracked_callbacks_.push_back(callback); } void onTrackedPersonLost(std::function callback) { person_tracked_lost_callbacks_.push_back(callback); } void setReferenceFrame(const std::string & frame) { reference_frame_ = frame; } rclcpp::CallbackGroup::SharedPtr getCallbackGroup() {return callback_group_;} void clearData() { faces_.clear(); bodies_.clear(); voices_.clear(); persons_.clear(); tracked_persons_.clear(); tf_buffer_.clear(); } void clearCallbacks() { face_callbacks_.clear(); face_lost_callbacks_.clear(); body_callbacks_.clear(); body_lost_callbacks_.clear(); voice_callbacks_.clear(); voice_lost_callbacks_.clear(); person_callbacks_.clear(); person_lost_callbacks_.clear(); person_tracked_callbacks_.clear(); person_tracked_lost_callbacks_.clear(); } protected: explicit HRIListener(NodeLikeSharedPtr node_like); private: void onTrackedFeature(FeatureType & feature, hri_msgs::msg::IdsList::ConstSharedPtr tracked); NodeInterfaces node_interfaces_; rclcpp::CallbackGroup::SharedPtr callback_group_; std::map::SharedPtr> feature_subscribers_; std::map faces_; std::vector> face_callbacks_; std::vector> face_lost_callbacks_; std::map bodies_; std::vector> body_callbacks_; std::vector> body_lost_callbacks_; std::map voices_; std::vector> voice_callbacks_; std::vector> voice_lost_callbacks_; std::map persons_; std::vector> person_callbacks_; std::vector> person_lost_callbacks_; std::map tracked_persons_; std::vector> person_tracked_callbacks_; std::vector> person_tracked_lost_callbacks_; std::string reference_frame_; tf2::BufferCore tf_buffer_; std::unique_ptr tf_listener_; }; } // namespace hri #endif // HRI__HRI_HPP_