Common
common packages for kyubic
 
Loading...
Searching...
No Matches
battery_check.hpp
Go to the documentation of this file.
1
10#ifndef _BATTERY_CHECK_HPP
11#define _BATTERY_CHECK_HPP
12
13#include <behaviortree_cpp/action_node.h>
14
15#include <atomic>
16#include <driver_msgs/msg/power_state.hpp>
17#include <rclcpp/rclcpp.hpp>
18#include <std_msgs/msg/string.hpp>
19
23class BatteryCheck : public BT::StatefulActionNode
24{
25public:
33 const std::string & name, const BT::NodeConfig & config,
34 rclcpp::Publisher<std_msgs::msg::String>::SharedPtr logger_pub,
35 rclcpp::Node::SharedPtr ros_node);
36
41 static BT::PortsList providedPorts();
42
46 BT::NodeStatus onStart() override;
47
51 BT::NodeStatus onRunning() override;
52
56 void onHalted() override;
57
58private:
59 rclcpp::Node::SharedPtr ros_node_;
60 rclcpp::Publisher<std_msgs::msg::String>::SharedPtr logger_pub_;
61 rclcpp::Subscription<driver_msgs::msg::PowerState>::SharedPtr power_sub_;
62
63 std::atomic<float> logic_voltage_, act_voltage_;
64 std::atomic<bool> topic_received_;
65
66 bool is_battery_good(float voltage);
67 void logger(bool logic_check, bool act_check);
68};
69#endif // _CHECK_BATTERY_STATE_HPP
Condition node to check the health status of battery voltage.
Definition: battery_check.hpp:24
BT::NodeStatus onRunning() override
Performs the battery check logic.
Definition: battery_check.cpp:33
void onHalted() override
Called when the node is halted.
Definition: battery_check.cpp:50
BT::NodeStatus onStart() override
Start logic.
Definition: battery_check.cpp:31
static BT::PortsList providedPorts()
Defines the input and output ports for this node.
Definition: battery_check.cpp:29