-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathsleep_action.cpp
More file actions
38 lines (31 loc) · 1.11 KB
/
sleep_action.cpp
File metadata and controls
38 lines (31 loc) · 1.11 KB
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
#include "sleep_action.hpp"
#include "behaviortree_ros2/plugins.hpp"
bool SleepAction::setGoal(RosActionNode::Goal& goal)
{
auto timeout = getInput<unsigned>("msec");
goal.msec_timeout = timeout.value();
return true;
}
NodeStatus SleepAction::onResultReceived(const RosActionNode::WrappedResult& wr)
{
RCLCPP_INFO(logger(), "%s: onResultReceived. Done = %s", name().c_str(),
wr.result->done ? "true" : "false");
return wr.result->done ? NodeStatus::SUCCESS : NodeStatus::FAILURE;
}
NodeStatus SleepAction::onFailure(ActionNodeErrorCode error)
{
RCLCPP_ERROR(logger(), "%s: onFailure with error: %s", name().c_str(), toStr(error));
return NodeStatus::FAILURE;
}
BT::NodeStatus SleepAction::onFeedback(const std::shared_ptr<const Feedback> feedback)
{
RCLCPP_INFO_THROTTLE(logger(), *clock(), 1000, "Feedback cycle %d", feedback->cycle);
return NodeStatus::RUNNING;
}
void SleepAction::onHalt()
{
RCLCPP_INFO(logger(), "%s: onHalt", name().c_str());
}
// Plugin registration.
// The class SleepAction will self register with name "SleepAction".
CreateRosNodePlugin(SleepAction, "SleepAction");