forked from BehaviorTree/BehaviorTree.ROS2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_bool_node.cpp
More file actions
41 lines (36 loc) · 1023 Bytes
/
set_bool_node.cpp
File metadata and controls
41 lines (36 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "set_bool_node.hpp"
bool SetBoolService::setRequest(Request::SharedPtr& request)
{
getInput("value", request->data);
std::cout << "setRequest " << std::endl;
return true;
}
BT::NodeStatus SetBoolService::onResponseReceived(const Response::SharedPtr& response)
{
std::cout << "onResponseReceived " << std::endl;
if(response->success)
{
RCLCPP_INFO(logger(), "SetBool service succeeded.");
return BT::NodeStatus::SUCCESS;
}
else
{
RCLCPP_INFO(logger(), "SetBool service failed: %s", response->message.c_str());
return BT::NodeStatus::FAILURE;
}
}
BT::NodeStatus SetBoolService::onFailure(BT::ServiceNodeErrorCode error)
{
RCLCPP_ERROR(logger(), "Error: %d", error);
return BT::NodeStatus::FAILURE;
}
//-----------------------------------------------------------
BT::NodeStatus SetRobotBoolService::tick()
{
std::string robot;
if(getInput("robot", robot) && !robot.empty())
{
setServiceName(robot + "/" + service_suffix_);
}
return SetBoolService::tick();
}