20 #include "server_handler.hpp"
22 using namespace std::chrono_literals;
23 using namespace std::chrono;
25 ServerHandler::ServerHandler()
28 node_ = rclcpp::Node::make_shared(
"behavior_tree_tester");
30 clear_local_costmap_server = std::make_unique<DummyService<nav2_msgs::srv::ClearEntireCostmap>>(
31 node_,
"local_costmap/clear_entirely_local_costmap");
32 clear_global_costmap_server = std::make_unique<DummyService<nav2_msgs::srv::ClearEntireCostmap>>(
33 node_,
"global_costmap/clear_entirely_global_costmap");
34 compute_path_to_pose_server = std::make_unique<ComputePathToPoseActionServer>(node_);
35 follow_path_server = std::make_unique<DummyActionServer<nav2_msgs::action::FollowPath>>(
36 node_,
"follow_path");
37 spin_server = std::make_unique<DummyActionServer<nav2_msgs::action::Spin>>(
39 wait_server = std::make_unique<DummyActionServer<nav2_msgs::action::Wait>>(
41 backup_server = std::make_unique<DummyActionServer<nav2_msgs::action::BackUp>>(
43 drive_on_heading_server = std::make_unique<DummyActionServer<nav2_msgs::action::DriveOnHeading>>(
44 node_,
"drive_on_heading");
45 ntp_server = std::make_unique<DummyActionServer<nav2_msgs::action::ComputePathThroughPoses>>(
46 node_,
"compute_path_through_poses");
49 ServerHandler::~ServerHandler()
56 void ServerHandler::activate()
59 throw std::runtime_error(
"Trying to activate while already activated");
64 std::make_shared<std::thread>(std::bind(&ServerHandler::spinThread,
this));
66 std::cout <<
"Server handler is active!" << std::endl;
69 void ServerHandler::deactivate()
72 throw std::runtime_error(
"Trying to deactivate while already inactive");
76 server_thread_->join();
78 std::cout <<
"Server handler has been deactivated!" << std::endl;
81 void ServerHandler::reset()
const
83 clear_global_costmap_server->reset();
84 clear_local_costmap_server->reset();
85 compute_path_to_pose_server->reset();
86 follow_path_server->reset();
89 backup_server->reset();
90 drive_on_heading_server->reset();
93 void ServerHandler::spinThread()