Bratmobile
task_controller.h
1 #ifndef TASK_CONTROLLER_H
2 #define TASK_CONTROLLER_H
3 
4 #include "task.h"
5 #include "graphTools.h"
6 
11 class Controller{
12  protected:
13  Disturbance disturbance_q; //disturbance being counteracted as in the cognitive map
14  b2Transform _D_to_goal=b2Transform_zero;
20  vertexDescriptor get_current_vertex(const std::vector<vertexDescriptor>& cv){
21  if (cv.size()>0){
22  return cv[0];
23  }
24  return 0;
25  }
26  Task stopTask(const Task& controlGoal);
27 
28  public:
29 
30 
31  Controller()=default;
32 
42  virtual Task next_task(Task currentTask, const Task & controlGoal, const TransitionSystem & g, std::vector <vertexDescriptor> & current_vertices, std::vector <vertexDescriptor> & plan)=0;
43 
51  static int motor_step(Task::Action a, float distance=0.27);
52 
57  return disturbance_q;
58  }
59 
60  void set_disturbance(const Disturbance & d){
61  disturbance_q=d;
62  }
63 
70  b2Transform disturbance_to_goal(){
71  return _D_to_goal;
72  }
73 
74 };
75 
81  public:
82 
83  Wise_Controller()=default;
84 
85  Task next_task(Task currentTask, const Task & controlGoal, const TransitionSystem & g, std::vector <vertexDescriptor> & current_vertices, std::vector<vertexDescriptor> & plan);
86 
94  int to_task_end(const TransitionSystem& g, std::vector<vertexDescriptor>& plan);
95 
96 
109 Task task_to_execute(const std::vector<vertexDescriptor>&p, const TransitionSystem& g, int end_it, const Task & controlGoal, Task & currentTask, const std::vector<vertexDescriptor> & current_vertices);
110 
111 };
112 
118  public:
119 
120  Reactive_Controller()=default;
121 
122  virtual Task next_task(Task currentTask, const Task & controlGoal, const TransitionSystem & g, std::vector <vertexDescriptor> & current_vertices, std::vector<vertexDescriptor> & plan);
123 
124 
125 };
126 
128  Task next_task(Task currentTask, const Task & controlGoal, const TransitionSystem & g, std::vector <vertexDescriptor> & current_vertices, std::vector<vertexDescriptor> & plan);
129 };
130 #endif
Callback interface class for implementing custom strategies to switch between tasks to be executed.
Definition: task_controller.h:11
vertexDescriptor get_current_vertex(const std::vector< vertexDescriptor > &cv)
Get the current vertex.
Definition: task_controller.h:20
b2Transform disturbance_to_goal()
returns the distance between the disturbance_q and the goal this is used to maintain constant ratios ...
Definition: task_controller.h:70
virtual Task next_task(Task currentTask, const Task &controlGoal, const TransitionSystem &g, std::vector< vertexDescriptor > &current_vertices, std::vector< vertexDescriptor > &plan)=0
Virtual function used to choose the next task.
static int motor_step(Task::Action a, float distance=0.27)
Assigns fixed duration (in amount of motor callbacks)
Definition: task_controller.cpp:3
Disturbance get_disturbance()
Returns the disturbance being counteracted as in the cognitive map.
Definition: task_controller.h:56
Definition: task_controller.h:127
Chooses the next task reactively (Braitenberg controller)
Definition: task_controller.h:117
virtual Task next_task(Task currentTask, const Task &controlGoal, const TransitionSystem &g, std::vector< vertexDescriptor > &current_vertices, std::vector< vertexDescriptor > &plan)
Virtual function used to choose the next task.
Definition: task_controller.cpp:99
A closed hybrid control loop. It has an initial disturbance representing the continuous state and a d...
Definition: task.h:45
Chooses tasks based on a plan.
Definition: task_controller.h:80
Task next_task(Task currentTask, const Task &controlGoal, const TransitionSystem &g, std::vector< vertexDescriptor > &current_vertices, std::vector< vertexDescriptor > &plan)
Virtual function used to choose the next task.
Definition: task_controller.cpp:26
Task task_to_execute(const std::vector< vertexDescriptor > &p, const TransitionSystem &g, int end_it, const Task &controlGoal, Task &currentTask, const std::vector< vertexDescriptor > &current_vertices)
Creates a new task by interpreting the states in a plan. Tasks split in several states are treated li...
Definition: task_controller.cpp:47
int to_task_end(const TransitionSystem &g, std::vector< vertexDescriptor > &plan)
returns last vertex of the task starting at plan[0]
Definition: task_controller.cpp:38
Definition: disturbance.h:114
The motor instructions generated by the control strategy used in this tasks.
Definition: task.h:63