16 #ifndef NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__IS_BATTERY_LOW_CONDITION_HPP_
17 #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__IS_BATTERY_LOW_CONDITION_HPP_
24 #include "nav2_ros_common/lifecycle_node.hpp"
25 #include "sensor_msgs/msg/battery_state.hpp"
26 #include "behaviortree_cpp/condition_node.h"
28 namespace nav2_behavior_tree
50 const std::string & condition_name,
51 const BT::NodeConfiguration & conf);
59 BT::NodeStatus
tick()
override;
78 BT::InputPort<double>(
"min_battery",
"Minimum battery percentage/voltage"),
79 BT::InputPort<std::string>(
80 "battery_topic",
"/battery_status",
"Battery topic"),
82 "is_voltage",
false,
"If true voltage will be used to check for low battery"),
91 void batteryCallback(
const sensor_msgs::msg::BatteryState::ConstSharedPtr & msg);
93 nav2::LifecycleNode::SharedPtr node_;
94 rclcpp::CallbackGroup::SharedPtr callback_group_;
95 rclcpp::executors::SingleThreadedExecutor callback_group_executor_;
96 nav2::Subscription<sensor_msgs::msg::BatteryState>::SharedPtr battery_sub_;
97 std::string battery_topic_;
100 bool is_battery_low_;
101 std::chrono::milliseconds bt_loop_duration_;
A BT::ConditionNode that listens to a battery topic and returns SUCCESS when battery is low and FAILU...
void createROSInterfaces()
Function to create ROS interfaces.
static BT::PortsList providedPorts()
Creates list of BT ports.
BT::NodeStatus tick() override
The main override required by a BT action.
void initialize()
Function to read parameters and initialize class variables.