ASCO Aerial Autonomy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
base_controller.h
Go to the documentation of this file.
1 #pragma once
2 
5 
17 template <class SensorDataType, class GoalType, class ControlType>
18 class Controller {
19 public:
27  virtual bool run(SensorDataType sensor_data, ControlType &control) {
28  return runImplementation(sensor_data, goal_, control);
29  }
30 
39  ControllerStatus isConverged(SensorDataType sensor_data) {
40  return isConvergedImplementation(sensor_data, goal_);
41  }
47  virtual void setGoal(GoalType goal) { goal_ = goal; }
52  virtual GoalType getGoal() const { return goal_; }
56  virtual ~Controller() {}
57 
58 protected:
67  virtual bool runImplementation(SensorDataType sensor_data, GoalType goal,
68  ControlType &control) = 0;
80  virtual ControllerStatus isConvergedImplementation(SensorDataType sensor_data,
81  GoalType goal) = 0;
82 
83 private:
87  Atomic<GoalType> goal_;
88 };
Base Controller class.
Definition: base_controller.h:18
virtual void setGoal(GoalType goal)
set the goal condition for the controller. Should use internal locking as the run function can be cal...
Definition: base_controller.h:47
ControllerStatus isConverged(SensorDataType sensor_data)
Check if controller is converged.
Definition: base_controller.h:39
virtual ControllerStatus isConvergedImplementation(SensorDataType sensor_data, GoalType goal)=0
Implementation for checking convergence to be implemented by subclasses. This function is called afte...
Status of the controller.
Definition: controller_status.h:10
virtual bool runImplementation(SensorDataType sensor_data, GoalType goal, ControlType &control)=0
Run the control loop and return control arguments.
virtual ~Controller()
Destructor.
Definition: base_controller.h:56
virtual GoalType getGoal() const
get the goal condition for the controller. Should use internal locking as the run function can be cal...
Definition: base_controller.h:52
virtual bool run(SensorDataType sensor_data, ControlType &control)
Run the control loop and return control arguments.
Definition: base_controller.h:27