18#include "auto_apms_behavior_tree_core/node.hpp"
19#include "auto_apms_util/container.hpp"
20#include "rcl_interfaces/srv/list_parameters.hpp"
22#define INPUT_KEY_PARAM_NAME "parameter"
23#define INPUT_KEY_NODE_NAME "node"
31 HasParameter(
const std::string & instance_name,
const Config & config,
const Context & context)
35 std::string node_name = context_.getFullyQualifiedRosNodeName();
37 config.input_ports.find(INPUT_KEY_NODE_NAME) != config.input_ports.end() &&
38 !config.input_ports.at(INPUT_KEY_NODE_NAME).empty()) {
39 node_name = config.input_ports.at(INPUT_KEY_NODE_NAME);
44 static BT::PortsList providedPorts()
48 BT::InputPort<std::string>(
49 INPUT_KEY_NODE_NAME,
"Name of the targeted ROS 2 node. Leave empty to target this executor's node."),
50 BT::InputPort<std::string>(INPUT_KEY_PARAM_NAME,
"Name of the parameter.")};
53 bool setRequest(Request::SharedPtr & request)
override final
55 const BT::Expected<std::string> expected_name = getInput<std::string>(INPUT_KEY_PARAM_NAME);
56 if (!expected_name || expected_name.value().empty()) {
58 logger_,
"%s - Parameter name must not be empty.", context_.getFullyQualifiedTreeNodeName(
this).c_str());
59 RCLCPP_DEBUG_EXPRESSION(
60 logger_, !expected_name,
"%s - Error message: %s", context_.getFullyQualifiedTreeNodeName(
this).c_str(),
61 expected_name.error().c_str());
64 has_parameter_name_ = expected_name.value();
65 request->depth = Request::DEPTH_RECURSIVE;
66 request->prefixes = {};
70 BT::NodeStatus onResponseReceived(
const Response::SharedPtr & response)
override final
73 return BT::NodeStatus::FAILURE;
77 std::string has_parameter_name_;
Generic behavior tree node wrapper for a ROS 2 service client.
bool createClient(const std::string &service_name)
RosServiceNode(const std::string &instance_name, const Config &config, Context context)
#define AUTO_APMS_BEHAVIOR_TREE_REGISTER_NODE(type)
Macro for registering a behavior tree node plugin.
bool contains(const ContainerT< ValueT, AllocatorT > &c, const ValueT &val)
Check whether a particular container structure contains a value.
Powerful tooling for incorporating behavior trees for task development.