SMACC2
planner_switcher.cpp
Go to the documentation of this file.
1// Copyright 2021 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Pablo Inigo Blasco, Brett Aldrich
18 *
19 ******************************************************************************************************************/
22
23namespace cl_nav2z
24{
25using namespace std::chrono_literals;
26
28
30{
31 rclcpp::QoS qos(rclcpp::KeepLast(1));
32 qos.transient_local().reliable();
33
35 getNode()->create_publisher<std_msgs::msg::String>("planner_selector", qos);
37 getNode()->create_publisher<std_msgs::msg::String>("controller_selector", qos);
38}
39
41{
42 RCLCPP_INFO(getLogger(), "[PlannerSwitcher] Planner Switcher: Trying to set BackwardPlanner");
43
44 desired_global_planner_ = "UndoPathGlobalPlanner";
45 desired_local_planner_ = "BackwardLocalPlanner";
46
48}
49
51{
52 RCLCPP_INFO(getLogger(), "[PlannerSwitcher] Planner Switcher: Trying to set BackwardPlanner");
53
54 desired_global_planner_ = "BackwardGlobalPlanner";
55 desired_local_planner_ = "BackwardLocalPlanner";
57}
58
60{
61 RCLCPP_INFO(getLogger(), "[PlannerSwitcher] Planner Switcher: Trying to set ForwardPlanner");
62
63 desired_global_planner_ = "ForwardGlobalPlanner";
64 desired_local_planner_ = "ForwardLocalPlanner";
66}
67
69{
70 RCLCPP_INFO(getLogger(), "[PlannerSwitcher] Planner Switcher: Trying to set PureSpinningPlanner");
71
72 desired_global_planner_ = "ForwardGlobalPlanner";
73 desired_local_planner_ = "PureSpinningLocalPlanner";
75}
76
78{
79 desired_global_planner_ = "GridBased";
80 desired_local_planner_ = "FollowPath";
81
83}
84
86{
87 std_msgs::msg::String planner_msg;
88 planner_msg.data = desired_global_planner_;
89 this->planner_selector_pub_->publish(planner_msg);
90
91 std_msgs::msg::String controller_msg;
92 controller_msg.data = desired_local_planner_;
93 this->controller_selector_pub_->publish(controller_msg);
94}
95} // namespace cl_nav2z
rclcpp::Publisher< std_msgs::msg::String >::SharedPtr controller_selector_pub_
rclcpp::Publisher< std_msgs::msg::String >::SharedPtr planner_selector_pub_
rclcpp::Logger getLogger()
rclcpp::Node::SharedPtr getNode()