1 #ifndef B2BCONFIGURATOR_H
2 #define B2BCONFIGURATOR_H
11 FrontierCrashed(TransitionSystem & ts, Direction d) : transitionSystem(ts), direction(d) {}
13 bool operator()(
const Frontier & f)
const {
14 if (f.connecting.empty())
return false;
15 return transitionSystem[f.connecting[0]].direction==direction && transitionSystem[f.frontier].outcome==simResult::crashed;
18 TransitionSystem & transitionSystem;
19 Direction direction=UNDEFINED;
43 bool closeVertex(std::set<vertexDescriptor> & closed, vertexDescriptor v)
override;
56 std::vector <vertexDescriptor>
splitTask(vertexDescriptor v, Direction d, vertexDescriptor src=TransitionSystem::null_vertex())
override;
68 virtual 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)
override;
87 int minimumEdgesForClearvoyance(Direction direction);
100 virtual Disturbance getDisturbance(TransitionSystem&g, vertexDescriptor v, b2World & world,
const Direction & dir,
const b2Transform& start)
override;
112 template <
typename P>
114 std::vector <Direction> result;
116 std::vector <Frontier> frontiers=
frontierVertices(v, transitionSystem, info);
117 if (frontiers.size()<2){
121 result= predicate(v);
123 else if (frontiers.size()<4){
124 auto fLeft= std::find_if(frontiers.begin(), frontiers.end(),
FrontierCrashed(transitionSystem, LEFT));
125 auto fRight= std::find_if(frontiers.begin(), frontiers.end(),
FrontierCrashed(transitionSystem, RIGHT));
126 if (fLeft!=frontiers.end()){
127 result.push_back(DEFAULT);
129 if (fRight!=frontiers.end()){
130 result.push_back(DEFAULT);
155 virtual std::vector<vertexDescriptor>
explorer(vertexDescriptor v, TransitionSystem&g, b2World &w)
override;
157 virtual simResult simulate(
Task t, b2World & world, vertexDescriptor v0);
175 std::vector<Disturbance> disturbances;
176 vertexDescriptor source;
181 disturbances.push_back(d);
186 virtual bool add(vertexDescriptor v,
const Disturbance& d);
199 void pop(vertexDescriptor v);
201 void reset() {lookaheads.clear();}
203 std::vector <DisturbanceLookahead> getLookaheads()
const {
208 std::vector<DisturbanceLookahead> lookaheads;
219 void addOptionsInHindsight(vertexDescriptor v, vertexDescriptor v0, vertexDescriptor v1, ClearVoyance & clearvoyance);
Configurator with long-range planning. It explores transitions out of a state until a DEFAULT Task is...
Definition: attentive.h:10
ExecutionInfo package_info(vertexDescriptor gv=TransitionSystem::null_vertex(), bool been=false)
Package task/goal execution details into an Execution Info instance.
Definition: attentive.h:20
Stores disturbance lookaheads for alternative DEFAULT tasks (where the disturbance is backpropagated)
Definition: b2bconfigurator.h:172
void pop(vertexDescriptor v)
Pops the first disturbance off of the vector associated with the queried vertex.
Definition: b2bconfigurator.cpp:367
virtual Disturbance query(vertexDescriptor v)
Gets first disturbance predicted with a vertex.
Definition: b2bconfigurator.cpp:357
B2BConfigurator is a class that extends the AttentiveConfigurator to eliminate the Task splitting in ...
Definition: b2bconfigurator.h:27
virtual Robot makeRobot(b2World &world, const b2Transform &start, const Disturbance &focus)
Overload of makeRobot, uses a disturbance which may be the goal of the hindsight disturbance to make ...
Definition: b2bconfigurator.cpp:322
virtual 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) override
Same as AttentiveConfigurator::backtrack, but also adds vertex to priority queue if the vertex is in ...
Definition: b2bconfigurator.cpp:55
virtual std::vector< vertexDescriptor > explorer(vertexDescriptor v, TransitionSystem &g, b2World &w) override
Constructs transition system using a Box2D simulation combined with an A* graph expansion algorithm.
Definition: b2bconfigurator.cpp:218
void addOptionsInHindsight(vertexDescriptor v, vertexDescriptor v0, vertexDescriptor v1, ClearVoyance &clearvoyance)
If the frontier is a default state and its source is a turning task, it adds an additional default op...
Definition: b2bconfigurator.cpp:330
int visitedEdgeCount(const std::vector< edgeDescriptor > &es)
Counts the number of visited edges.
Definition: b2bconfigurator.cpp:112
virtual Disturbance getDisturbance(TransitionSystem &g, vertexDescriptor v, b2World &world, const Direction &dir, const b2Transform &start) override
Uses clearvoyance to get the disturbance for a vertex if needed.
Definition: b2bconfigurator.cpp:138
bool closeVertex(std::set< vertexDescriptor > &closed, vertexDescriptor v) override
Closes a vertex but the maximum out edges number for a default state to have is 5 instead of 3.
Definition: b2bconfigurator.cpp:3
std::vector< Direction > transitionInHindsight(vertexDescriptor v, P predicate)
Looks at the frontier to unlock transitions from a vertex.
Definition: b2bconfigurator.h:113
std::vector< vertexDescriptor > splitTask(vertexDescriptor v, Direction d, vertexDescriptor src=TransitionSystem::null_vertex()) override
Doesn't split the task, just returns the vertex of the task at hand; if Task fails or it's currently ...
Definition: b2bconfigurator.cpp:34
bool attentionWindowOverlaps(const Disturbance &Di, const State &q, b2World &world, const Disturbance &focus)
Returns true if attention window overlap with Di.
Definition: b2bconfigurator.cpp:100
virtual void init(Task _task=Task())
Initialises configurator.
Definition: configurator.cpp:22
Information about what the configurator is doing (current Task, current vertex), what it wants to do ...
Definition: planner.h:48
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:45
std::vector< Frontier > frontierVertices(vertexDescriptor v, TransitionSystem &g, ExecutionInfo &info)
Performs iterative deepening search to find the frontier.
Definition: planner.cpp:100
Definition: b2bconfigurator.h:174
Definition: disturbance.h:114
Predicate assessing whether a frontier is a crashed state.
Definition: b2bconfigurator.h:8
Contains the frontier (first) and the connecting vertices.
Definition: planner.h:16
Hybrid states in the transition system.
Definition: graphTools.h:69
Definition: disturbance.h:270