Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
controller_error_plugins.hpp
1 // Copyright (c) 2022 Joshua Wallace
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 #ifndef ERROR_CODES__CONTROLLER__CONTROLLER_ERROR_PLUGINS_HPP_
16 #define ERROR_CODES__CONTROLLER__CONTROLLER_ERROR_PLUGINS_HPP_
17 
18 #include <memory>
19 #include <string>
20 
21 #include "nav2_core/controller.hpp"
22 #include "nav2_core/controller_exceptions.hpp"
23 #include "nav2_ros_common/tf2_factories.hpp"
24 
25 namespace nav2_system_tests
26 {
27 
29 {
30 public:
31  UnknownErrorController() = default;
32  ~UnknownErrorController() = default;
33 
34  void configure(
35  const nav2::LifecycleNode::WeakPtr &,
36  std::string, nav2::TransformBuffer::SharedPtr,
37  std::shared_ptr<nav2_costmap_2d::Costmap2DROS>) override {}
38 
39  void cleanup() {}
40 
41  void activate() {}
42 
43  void deactivate() {}
44 
45  void newPathReceived(const nav_msgs::msg::Path &) {}
46 
47  virtual geometry_msgs::msg::TwistStamped computeVelocityCommands(
48  const geometry_msgs::msg::PoseStamped &,
49  const geometry_msgs::msg::Twist &,
51  const nav_msgs::msg::Path &,
52  const geometry_msgs::msg::PoseStamped &)
53  {
54  throw nav2_core::ControllerException("Unknown Error");
55  }
56 
57  void setSpeedLimit(const double &, const bool &) {}
58 };
59 
61 {
62  virtual geometry_msgs::msg::TwistStamped computeVelocityCommands(
63  const geometry_msgs::msg::PoseStamped &,
64  const geometry_msgs::msg::Twist &,
66  const nav_msgs::msg::Path &,
67  const geometry_msgs::msg::PoseStamped &)
68  {
69  throw nav2_core::ControllerTFError("TF error");
70  }
71 };
72 
74 {
75  virtual geometry_msgs::msg::TwistStamped computeVelocityCommands(
76  const geometry_msgs::msg::PoseStamped &,
77  const geometry_msgs::msg::Twist &,
79  const nav_msgs::msg::Path &,
80  const geometry_msgs::msg::PoseStamped &)
81  {
82  throw nav2_core::FailedToMakeProgress("Failed to make progress");
83  }
84 };
85 
87 {
88  virtual geometry_msgs::msg::TwistStamped computeVelocityCommands(
89  const geometry_msgs::msg::PoseStamped &,
90  const geometry_msgs::msg::Twist &,
92  const nav_msgs::msg::Path &,
93  const geometry_msgs::msg::PoseStamped &)
94  {
95  throw nav2_core::PatienceExceeded("Patience exceeded");
96  }
97 };
98 
100 {
101  virtual geometry_msgs::msg::TwistStamped computeVelocityCommands(
102  const geometry_msgs::msg::PoseStamped &,
103  const geometry_msgs::msg::Twist &,
105  const nav_msgs::msg::Path &,
106  const geometry_msgs::msg::PoseStamped &)
107  {
108  throw nav2_core::InvalidPath("Invalid path");
109  }
110 };
111 
113 {
114  virtual geometry_msgs::msg::TwistStamped computeVelocityCommands(
115  const geometry_msgs::msg::PoseStamped &,
116  const geometry_msgs::msg::Twist &,
118  const nav_msgs::msg::Path &,
119  const geometry_msgs::msg::PoseStamped &)
120  {
121  throw nav2_core::NoValidControl("No valid control");
122  }
123 };
124 
125 } // namespace nav2_system_tests
126 
127 #endif // ERROR_CODES__CONTROLLER__CONTROLLER_ERROR_PLUGINS_HPP_
controller interface that acts as a virtual base class for all controller plugins
Definition: controller.hpp:60
Function-object for checking whether a goal has been reached.
void deactivate()
Method to deactivate planner and any threads involved in execution.
void newPathReceived(const nav_msgs::msg::Path &)
local setPlan - Notifies the Controller that a new plan is received from the Planner Server
void setSpeedLimit(const double &, const bool &)
Limits the maximum linear speed of the robot.
virtual geometry_msgs::msg::TwistStamped computeVelocityCommands(const geometry_msgs::msg::PoseStamped &, const geometry_msgs::msg::Twist &, nav2_core::GoalChecker *, const nav_msgs::msg::Path &, const geometry_msgs::msg::PoseStamped &)
Controller computeVelocityCommands - calculates the best command given the current pose and velocity.
void activate()
Method to active planner and any threads involved in execution.
void configure(const nav2::LifecycleNode::WeakPtr &, std::string, nav2::TransformBuffer::SharedPtr, std::shared_ptr< nav2_costmap_2d::Costmap2DROS >) override
void cleanup()
Method to cleanup resources.