SMACC2
Loading...
Searching...
No Matches
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
40void PlannerSwitcher::setDesiredGlobalPlanner(std::string plannerName)
41{
42 desired_planner_ = plannerName;
43}
44
45void PlannerSwitcher::setDesiredController(std::string controllerName)
46{
47 desired_controller_ = controllerName;
48}
49
51{
52 RCLCPP_INFO(getLogger(), "[PlannerSwitcher] Planner Switcher: Trying to set BackwardPlanner");
53
54 desired_planner_ = "UndoPathGlobalPlanner";
55 desired_controller_ = "BackwardLocalPlanner";
56
57 if (commit) commitPublish();
58}
59
61{
62 RCLCPP_INFO(getLogger(), "[PlannerSwitcher] Planner Switcher: Trying to set BackwardPlanner");
63
64 desired_planner_ = "BackwardGlobalPlanner";
65 desired_controller_ = "BackwardLocalPlanner";
66
67 if (commit) commitPublish();
68}
69
71{
72 RCLCPP_INFO(getLogger(), "[PlannerSwitcher] Planner Switcher: Trying to set ForwardPlanner");
73
74 desired_planner_ = "ForwardGlobalPlanner";
75 desired_controller_ = "ForwardLocalPlanner";
76
77 if (commit) commitPublish();
78}
79
81{
82 RCLCPP_INFO(getLogger(), "[PlannerSwitcher] Planner Switcher: Trying to set PureSpinningPlanner");
83
84 desired_planner_ = "ForwardGlobalPlanner";
85 desired_controller_ = "PureSpinningLocalPlanner";
86
87 if (commit) commitPublish();
88}
89
91{
92 desired_planner_ = "GridBased";
93 desired_controller_ = "FollowPath";
94
95 if (commit) commitPublish();
96}
97
99{
100 std_msgs::msg::String planner_msg;
101 planner_msg.data = desired_planner_;
102 this->planner_selector_pub_->publish(planner_msg);
103
104 std_msgs::msg::String controller_msg;
105 controller_msg.data = desired_controller_;
106 this->controller_selector_pub_->publish(controller_msg);
107}
108} // namespace cl_nav2z
void setDesiredGlobalPlanner(std::string)
void setBackwardPlanner(bool commit=true)
rclcpp::Publisher< std_msgs::msg::String >::SharedPtr controller_selector_pub_
void setForwardPlanner(bool commit=true)
void setDefaultPlanners(bool commit=true)
void setPureSpinningPlanner(bool commit=true)
void setDesiredController(std::string)
rclcpp::Publisher< std_msgs::msg::String >::SharedPtr planner_selector_pub_
void setUndoPathBackwardPlanner(bool commit=true)
rclcpp::Logger getLogger() const
rclcpp::Node::SharedPtr getNode()