SMACC2
Loading...
Searching...
No Matches
cp_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 CpPlannerSwitcher::setDesiredGlobalPlanner(std::string plannerName)
41{
42 desired_planner_ = plannerName;
43}
44
45void CpPlannerSwitcher::setDesiredController(std::string controllerName)
46{
47 desired_controller_ = controllerName;
48}
49
51{
52 RCLCPP_INFO(getLogger(), "[CpPlannerSwitcher] 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(), "[CpPlannerSwitcher] 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(), "[CpPlannerSwitcher] 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(
83 getLogger(), "[CpPlannerSwitcher] Planner Switcher: Trying to set PureSpinningPlanner");
84
85 desired_planner_ = "ForwardGlobalPlanner";
86 desired_controller_ = "PureSpinningLocalPlanner";
87
88 if (commit) commitPublish();
89}
90
92{
93 desired_planner_ = "GridBased";
94 desired_controller_ = "FollowPath";
95
96 if (commit) commitPublish();
97}
98
100{
101 std_msgs::msg::String planner_msg;
102 planner_msg.data = desired_planner_;
103 this->planner_selector_pub_->publish(planner_msg);
104
105 std_msgs::msg::String controller_msg;
106 controller_msg.data = desired_controller_;
107 this->controller_selector_pub_->publish(controller_msg);
108}
109} // namespace cl_nav2z
void setPureSpinningPlanner(bool commit=true)
void setUndoPathBackwardPlanner(bool commit=true)
void setBackwardPlanner(bool commit=true)
void setForwardPlanner(bool commit=true)
void setDefaultPlanners(bool commit=true)
rclcpp::Publisher< std_msgs::msg::String >::SharedPtr planner_selector_pub_
void setDesiredGlobalPlanner(std::string)
rclcpp::Publisher< std_msgs::msg::String >::SharedPtr controller_selector_pub_
rclcpp::Logger getLogger() const
rclcpp::Node::SharedPtr getNode()