-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/dawan0111/yacyac into featu…
…re/servo_ctrl
- Loading branch information
Showing
7 changed files
with
106 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef SUPPLY_FEEDBACK_CLIENT_HPP_ | ||
#define SUPPLY_FEEDBACK_CLIENT_HPP_ | ||
|
||
#include <behaviortree_cpp/behavior_tree.h> | ||
#include <rclcpp/rclcpp.hpp> | ||
#include <std_msgs/msg/bool.hpp> | ||
|
||
class SupplyAcceptClient : public BT::StatefulActionNode { | ||
public: | ||
SupplyAcceptClient(const std::string& name, const BT::NodeConfig& config); | ||
~SupplyAcceptClient(); | ||
|
||
static BT::PortsList providedPorts() { return {}; } | ||
|
||
// this function is invoked once at the beginning. | ||
BT::NodeStatus onStart() override; | ||
|
||
// If onStart() returned RUNNING, we will keep calling | ||
// this method until it return something different from RUNNING | ||
BT::NodeStatus onRunning() override; | ||
|
||
void onHalted() override; | ||
|
||
private: | ||
rclcpp::Node::SharedPtr node_; | ||
rclcpp::Subscription<std_msgs::msg::Bool>::SharedPtr feedback_sub_; | ||
bool supply_accept_; | ||
bool has_supply_accept_; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "yacyac_core/supply_accept_client.hpp" | ||
|
||
SupplyAcceptClient::SupplyAcceptClient(const std::string& name, const BT::NodeConfig& config) : BT::StatefulActionNode(name, config) {} | ||
|
||
SupplyAcceptClient::~SupplyAcceptClient() | ||
{ | ||
RCLCPP_INFO(node_->get_logger(), "SHUTTING DOWN SupplyAcceptClient NODE"); | ||
} | ||
|
||
BT::NodeStatus SupplyAcceptClient::onStart() | ||
{ | ||
node_ = rclcpp::Node::make_shared("supply_accept_client"); | ||
|
||
const std::string QR_topic_name = "/user_feedback"; | ||
|
||
has_supply_accept_ = false; | ||
|
||
feedback_sub_ = node_->create_subscription<std_msgs::msg::Bool>(QR_topic_name, rclcpp::QoS(1), [this](const std_msgs::msg::Bool::SharedPtr msg) { | ||
supply_accept_ = msg->data; | ||
has_supply_accept_ = true; | ||
}); | ||
|
||
return BT::NodeStatus::RUNNING; | ||
} | ||
|
||
BT::NodeStatus SupplyAcceptClient::onRunning() | ||
{ | ||
rclcpp::spin_some(node_); | ||
if (has_supply_accept_) { | ||
if (supply_accept_) { | ||
return BT::NodeStatus::SUCCESS; | ||
} | ||
else { | ||
return BT::NodeStatus::FAILURE; | ||
} | ||
} | ||
else { | ||
return BT::NodeStatus::RUNNING; | ||
} | ||
} | ||
|
||
void SupplyAcceptClient::onHalted() | ||
{ | ||
// printf("[ SupplyAcceptClient: ABORTED ]"); | ||
} |