|
| 1 | +// Copyright 2024 Intelligent Robotics Lab - Gentlebots |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#include "hri/dialog/remove_guest_attended.hpp" |
| 16 | +#include <regex> |
| 17 | + |
| 18 | +using std::placeholders::_1; |
| 19 | +using namespace std::chrono_literals; |
| 20 | + |
| 21 | + |
| 22 | +namespace dialog |
| 23 | +{ |
| 24 | + |
| 25 | +RemoveGuestAttended::RemoveGuestAttended( |
| 26 | + const std::string & xml_tag_name, const BT::NodeConfiguration & conf) |
| 27 | +: BT::ActionNodeBase(xml_tag_name, conf) |
| 28 | +{ |
| 29 | + config().blackboard->get("node", node_); |
| 30 | + this->kb_publisher_= node_->create_publisher<std_msgs::msg::String>("/kb/remove_fact", 10); |
| 31 | +} |
| 32 | + |
| 33 | +BT::NodeStatus RemoveGuestAttended::tick() |
| 34 | +{ |
| 35 | + RCLCPP_DEBUG(node_->get_logger(), "[RemoveGuestAttended] ticked"); |
| 36 | + |
| 37 | + getInput("guest_attended", guest_attending_id_); |
| 38 | + |
| 39 | + std_msgs::msg::String fact_msg; |
| 40 | + |
| 41 | + if (!guest_attending_id_.empty()) { |
| 42 | + fact_msg.data = "robot1 oro:attends " + guest_attending_id_; |
| 43 | + kb_publisher_->publish(fact_msg); |
| 44 | + RCLCPP_INFO(node_->get_logger(), "[RemoveGuestAttended] Removing fact: robot1 oro:attends %s", guest_attending_id_.c_str()); |
| 45 | + }else{ |
| 46 | + return BT::NodeStatus::FAILURE; |
| 47 | + } |
| 48 | + |
| 49 | + return BT::NodeStatus::SUCCESS; |
| 50 | + |
| 51 | +} |
| 52 | + |
| 53 | +void RemoveGuestAttended::halt() {} |
| 54 | + |
| 55 | + |
| 56 | +} // namespace hri |
| 57 | + |
| 58 | +#include "behaviortree_cpp_v3/bt_factory.h" |
| 59 | +BT_REGISTER_NODES(factory) |
| 60 | +{ |
| 61 | + |
| 62 | + factory.registerNodeType<dialog::RemoveGuestAttended>("RemoveGuestAttended"); |
| 63 | +} |
0 commit comments