Bratmobile
attentive.h
1 #ifndef ATTENTIVE_H
2 #define ATTENTIVE_H
3 #include "focused.h"
4 
11  protected:
12 
16  virtual bool preventTransition(vertexDescriptor v)override{
17  return false;
18  }
19 
23  bool recycle_plan(vertexDescriptor v, vertexDescriptor &v0, vertexDescriptor & task_start, StateMatcher::MATCH_TYPE &matchType,
24  b2Transform & shift_start, b2Transform& sk_first_start, std::pair<edgeDescriptor, bool>&edge,
25  std::vector<vertexDescriptor> &plan_prov, Direction t_get_direction)override;
26 
27  virtual VertexMatch findMatch(State s, Direction dir=Direction::UNDEFINED, StateMatcher::MATCH_TYPE match_type=StateMatcher::_TRUE, StateDifference * _sd=NULL, vertexDescriptor src=TransitionSystem::null_vertex())override;
28 
29  std::pair<bool, vertexDescriptor> isPlannedTaskOK(vertexDescriptor src, State s);
30 
31 
32 };
33 
39 public:
43 Disturbance getDisturbance(TransitionSystem&g, vertexDescriptor v, b2World & world, const Direction & dir, const b2Transform& start)override;
44 
45 Robot makeRobot(b2World & w, const Task & task)override;
46 
51 float remainingSimulationTime(const Task *const t=NULL)override;
52 
63 VertexMatch findMatch(State s, Direction dir=Direction::UNDEFINED, StateMatcher::MATCH_TYPE match_type=StateMatcher::_TRUE, StateDifference * _sd=NULL, vertexDescriptor src=TransitionSystem::null_vertex())override;
64 
65 StateMatcher::MATCH_TYPE desiredMatch() override {
66  return StateMatcher::MATCH_TYPE::_TRUE;
67 }
75 void transitionMatrix(vertexDescriptor v, Direction d, vertexDescriptor src) override;
76 
80 bool closeVertex(std::set<vertexDescriptor> & closed, vertexDescriptor v)override;
81 
82 
83 void backtrack(std::vector <vertexDescriptor>& evaluation_q, std::vector <vertexDescriptor>&priority_q, std::set<vertexDescriptor>& closed, std::vector <vertexDescriptor>& plan_prov, vertexDescriptor module_src, vertexDescriptor startRecycle)override;
84 
85 std::vector<Direction> partiallyExplorativeOptions(std::pair<bool, edgeDescriptor> ve)override;
86 
87 bool shouldPartiallyExplore(const std::vector<edgeDescriptor>& oe, std::pair<bool, edgeDescriptor> ve)override;
88 
89 bool canPropagate(vertexDescriptor v) override;
90 
91 bool canReassignOutcome(vertexDescriptor v) override;
92 
93 bool propagateD(vertexDescriptor v1, vertexDescriptor v0, std::set<vertexDescriptor>*closed=NULL, StateMatcher::MATCH_TYPE match=StateMatcher::_FALSE)override;
94 
95 float customSimulationStep(vertexDescriptor v=TransitionSystem::null_vertex())override{
96  return simulationStep;
97 }
98 
99 };
100 
101 // /**
102 // * @brief Plans by simply looking ahead at the possible Tasks and choosing the best sequence.
103 // * Does not process states, e.g. with split
104 // */
105 // class SimplestConfigurator: public FocusedConfigurator{
106 // int simulationStep=BOX2DRANGE;
107 
108 // Robot makeRobot(b2World & world, const b2Transform & start){
109 // return Configurator::makeRobot(world, start);
110 // }
111 
112 // Disturbance getDisturbance(TransitionSystem&g, vertexDescriptor v, b2World & world, const Direction & dir, const b2Transform& start){
113 // return g[v].Dn;
114 // }
115 
116 // void backtrack(std::vector <vertexDescriptor>& evaluation_q, std::vector <vertexDescriptor>&priority_q, std::set<vertexDescriptor>& closed, std::vector <vertexDescriptor>& plan_prov, vertexDescriptor module_src=MOVING_VERTEX, vertexDescriptor startRecycle=MOVING_VERTEX);
117 
118 
119 
120 // };
121 #endif
Configurator with long-range planning. It explores transitions out of a state until a DEFAULT Task is...
Definition: attentive.h:10
virtual VertexMatch findMatch(State s, Direction dir=Direction::UNDEFINED, StateMatcher::MATCH_TYPE match_type=StateMatcher::_TRUE, StateDifference *_sd=NULL, vertexDescriptor src=TransitionSystem::null_vertex()) override
Searches transition System for a match to a state provided. Continuous states are matched,...
Definition: attentive.cpp:41
bool recycle_plan(vertexDescriptor v, vertexDescriptor &v0, vertexDescriptor &task_start, StateMatcher::MATCH_TYPE &matchType, b2Transform &shift_start, b2Transform &sk_first_start, std::pair< edgeDescriptor, bool > &edge, std::vector< vertexDescriptor > &plan_prov, Direction t_get_direction) override
Find a suitable sequence for execution as a plan in the transition system, if present.
Definition: attentive.cpp:3
virtual bool preventTransition(vertexDescriptor v) override
Definition: attentive.h:16
Configurator that discretises DEFAULT tasks into fixed-length segments. Basically,...
Definition: attentive.h:38
Robot makeRobot(b2World &w, const Task &task) override
Makes the robot object in the world with the given start position and task.
Definition: attentive.cpp:84
bool propagateD(vertexDescriptor v1, vertexDescriptor v0, std::set< vertexDescriptor > *closed=NULL, StateMatcher::MATCH_TYPE match=StateMatcher::_FALSE) override
Propagate a disturbance backwards to all states representing the same task (max 1)
Definition: attentive.cpp:181
VertexMatch findMatch(State s, Direction dir=Direction::UNDEFINED, StateMatcher::MATCH_TYPE match_type=StateMatcher::_TRUE, StateDifference *_sd=NULL, vertexDescriptor src=TransitionSystem::null_vertex()) override
In discrete configurator, matches must be exact and no signal to replan if Task is successful.
Definition: attentive.cpp:100
void transitionMatrix(vertexDescriptor v, Direction d, vertexDescriptor src) override
In discrete configurator, successful DEFAULT tasks can transition to DEFAULT, LEFT,...
Definition: attentive.cpp:108
bool closeVertex(std::set< vertexDescriptor > &closed, vertexDescriptor v) override
Just adds to closed set.
Definition: attentive.cpp:135
float remainingSimulationTime(const Task *const t=NULL) override
Sets a time limit to DEFAULT tasks corresponding to the amount of time estimated to complete a forwar...
Definition: attentive.cpp:89
bool canPropagate(vertexDescriptor v) override
propagates only if the previous vertex
Definition: attentive.cpp:204
Disturbance getDisturbance(TransitionSystem &g, vertexDescriptor v, b2World &world, const Direction &dir, const b2Transform &start) override
In discrete configurator, Di is previous state's Dn, or the goal, if null.
Definition: attentive.cpp:80
bool shouldPartiallyExplore(const std::vector< edgeDescriptor > &oe, std::pair< bool, edgeDescriptor > ve) override
Psi guard: should only current task be simulated?
Definition: attentive.cpp:175
void backtrack(std::vector< vertexDescriptor > &evaluation_q, std::vector< vertexDescriptor > &priority_q, std::set< vertexDescriptor > &closed, std::vector< vertexDescriptor > &plan_prov, vertexDescriptor module_src, vertexDescriptor startRecycle) override
Iterates through vertices, if they result in crash, it splits the tasks and recalculates evaluation f...
Definition: attentive.cpp:140
std::vector< Direction > partiallyExplorativeOptions(std::pair< bool, edgeDescriptor > ve) override
Assigns options to vertex which has in previous iteration been expanded. Assigns direction of success...
Definition: attentive.cpp:160
Configurator that only replans if the current task fails.
Definition: focused.h:8
Robot class for Box2D simulation.
Definition: robot.h:18
A closed hybrid control loop. It has an initial disturbance representing the continuous state and a d...
Definition: task.h:47
Definition: disturbance.h:113
Contains the differences between the contiuous components of two hybrid states.
Definition: graphTools.h:143
Hybrid states in the transition system.
Definition: graphTools.h:69