3 #include "configurator.h"
21 return ExecutionInfo(currentVertex, gv, currentTask, controlGoal, been, m_plan);
37 virtual Disturbance getDisturbance(TransitionSystem&g, vertexDescriptor v, b2World & world,
const Direction & dir,
const b2Transform& start);
50 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);
60 virtual std::vector <vertexDescriptor>
splitTask(vertexDescriptor v, Direction d, vertexDescriptor src=TransitionSystem::null_vertex());
72 virtual bool propagateD(vertexDescriptor v1, vertexDescriptor v0, std::set<vertexDescriptor>*closed=NULL, StateMatcher::MATCH_TYPE match=StateMatcher::_FALSE);
75 void planPriority(TransitionSystem&, vertexDescriptor);
79 void adjust_rw_task(
const vertexDescriptor&, TransitionSystem &,
Task*,
const b2Transform &);
92 virtual VertexMatch
findMatch(
State s, Direction dir=Direction::UNDEFINED, StateMatcher::MATCH_TYPE match_type=StateMatcher::_TRUE,
StateDifference * _sd=NULL, std::vector <VertexMatch>*other_matches=NULL);
103 virtual std::vector<vertexDescriptor>
explorer(vertexDescriptor v, TransitionSystem&g, b2World &w);
129 std::pair <edgeDescriptor, bool>
add_vertex_retro(vertexDescriptor &src, vertexDescriptor &v1,
Edge edge=
Edge(),
bool topDown=0);
132 std::vector <Direction>
getExploredDirections(vertexDescriptor v,
const std::vector<Direction>& directions);
143 virtual void transitionMatrix(vertexDescriptor v, Direction d, vertexDescriptor src);
154 void applyTransitionMatrix(vertexDescriptor v0, Direction d,
bool ended, vertexDescriptor src, std::vector<vertexDescriptor>& plan_prov);
164 void addToPriorityQueue(vertexDescriptor v, std::vector<vertexDescriptor>& queue,
const std::set <vertexDescriptor>& closed);
171 void shift_states(TransitionSystem &,
const std::vector<vertexDescriptor>&,
const b2Transform &);
174 vertexDescriptor get_explore_start(TransitionSystem &);
198 std::vector<Direction>::iterator
get_next_option(vertexDescriptor v, vertexDescriptor src, std::vector<vertexDescriptor> full_plan);
215 virtual bool recycle_plan(vertexDescriptor v, vertexDescriptor &v0, vertexDescriptor & task_start, StateMatcher::MATCH_TYPE &matchType,
216 b2Transform & shift_start, b2Transform& sk_first_start, std::pair<edgeDescriptor, bool>&edge,
217 std::vector<vertexDescriptor> &plan_prov, Direction t_get_direction);
231 std::pair<State, Edge>
simulation_setup(b2World& w,
Task & t, vertexDescriptor v0, b2Transform shift, b2Transform &start, std::vector<Direction>v0_options);
248 bool matchToSafe(VertexMatch &match,
const std::vector<VertexMatch> &other_matches=std::vector<VertexMatch>());
262 std::pair<edgeDescriptor, bool>
setup_match_edge(VertexMatch &match, vertexDescriptor &v0, vertexDescriptor & v1,
const Edge& k, Direction direction,
bool changedMatch);
270 virtual std::vector <vertexDescriptor>
task_vertices(vertexDescriptor v, std::pair<bool, edgeDescriptor>* ep=NULL);
290 vertexDescriptor
getRecyclingStart(vertexDescriptor v, vertexDescriptor v1, vertexDescriptor taskStart);
297 std::vector <edgeDescriptor>
inEdges(vertexDescriptor v, Direction d = UNDEFINED);
299 virtual bool closeVertex(std::set<vertexDescriptor> & closed, vertexDescriptor v);
311 std::pair<edgeDescriptor, bool>
addEdgeRetrospectively(vertexDescriptor v, vertexDescriptor &v1,
const State & s_tmp,std::pair<edgeDescriptor, bool> first_edge, Direction d,
float linearSpeed);
323 void correctQueue(std::vector<vertexDescriptor>& queue, vertexDescriptor v, vertexDescriptor startRecycle,
int planProvSize);
337 void abandonPlan(std::vector<vertexDescriptor>& planProv, vertexDescriptor v0, vertexDescriptor v1);
354 vertexDescriptor lastAdded=TransitionSystem::null_vertex();
366 void addToEvaluationQueue(std::vector <vertexDescriptor>& evaluationQueue, vertexDescriptor v1, TransitionSystem & g, vertexDescriptor v);
368 void reset(vertexDescriptor v=TransitionSystem::null_vertex()){
381 virtual StateMatcher::MATCH_TYPE desiredMatch() {
382 return StateMatcher::MATCH_TYPE::ABSTRACT;
394 virtual bool shouldPartiallyExplore(
const std::vector<edgeDescriptor>& oe, std::pair<bool, edgeDescriptor> ve);
402 virtual bool canReassignOutcome(vertexDescriptor v);
404 virtual float customSimulationStep(vertexDescriptor v=TransitionSystem::null_vertex()){
405 return simulationStep;
428 StateMatcher::MATCH_TYPE desiredMatch()
override {
429 return StateMatcher::MATCH_TYPE::ABSTRACT;
441 bool recycle_plan(vertexDescriptor v, vertexDescriptor &v0, vertexDescriptor & task_start, StateMatcher::MATCH_TYPE &matchType,
442 b2Transform & shift_start, b2Transform& sk_first_start, std::pair<edgeDescriptor, bool>&edge,
443 std::vector<vertexDescriptor> &plan_prov, Direction t_get_direction)
override{
447 virtual VertexMatch
findMatch(
State s, Direction dir=Direction::UNDEFINED, StateMatcher::MATCH_TYPE match_type=StateMatcher::_TRUE,
StateDifference * _sd=NULL, std::vector <VertexMatch>*other_matches=NULL)
override;
451 virtual float customSimulationStep(vertexDescriptor v=TransitionSystem::null_vertex())
override;
453 bool hasPlanFinished(){
454 return m_plan.empty() && currentTask.
is_over();
468 Disturbance getDisturbance(TransitionSystem&g, vertexDescriptor v, b2World & world,
const Direction & dir,
const b2Transform& start)
override;
489 VertexMatch
findMatch(
State s, Direction dir=Direction::UNDEFINED, StateMatcher::MATCH_TYPE match_type=StateMatcher::_TRUE,
StateDifference * _sd=NULL, std::vector <VertexMatch>*other_matches=NULL)
override;
491 StateMatcher::MATCH_TYPE desiredMatch()
override {
492 return StateMatcher::MATCH_TYPE::_TRUE;
501 void transitionMatrix(vertexDescriptor v, Direction d, vertexDescriptor src)
override;
506 bool closeVertex(std::set<vertexDescriptor> & closed, vertexDescriptor v)
override;
511 bool recycle_plan(vertexDescriptor v, vertexDescriptor &v0, vertexDescriptor & task_start, StateMatcher::MATCH_TYPE &matchType,
512 b2Transform & shift_start, b2Transform& sk_first_start, std::pair<edgeDescriptor, bool>&edge,
513 std::vector<vertexDescriptor> &plan_prov, Direction t_get_direction)
override{
517 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;
521 bool shouldPartiallyExplore(
const std::vector<edgeDescriptor>& oe, std::pair<bool, edgeDescriptor> ve)
override;
527 bool canReassignOutcome(vertexDescriptor v)
override;
529 bool propagateD(vertexDescriptor v1, vertexDescriptor v0, std::set<vertexDescriptor>*closed=NULL, StateMatcher::MATCH_TYPE match=StateMatcher::_FALSE)
override;
531 float customSimulationStep(vertexDescriptor v=TransitionSystem::null_vertex()){
532 return AttentiveConfigurator::customSimulationStep();
Adds and removes vertices from the evaluation queue.
Definition: attentive.h:352
void addToEvaluationQueue(std::vector< vertexDescriptor > &evaluationQueue, vertexDescriptor v1, TransitionSystem &g, vertexDescriptor v)
Adds to evaluation queue: if the vertex represents a successful task, it is added to the end of the q...
Definition: attentive.cpp:831
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, std::vector< VertexMatch > *other_matches=NULL)
Searches transition System for a match to a state provided. Continuous states are matched,...
Definition: attentive.cpp:422
void reassign_direction(vertexDescriptor bestNext, Direction &direction)
Reassigns direction as the direction of the bext task to expand next in explorer.
Definition: attentive.cpp:624
std::pair< edgeDescriptor, bool > setup_match_edge(VertexMatch &match, vertexDescriptor &v0, vertexDescriptor &v1, const Edge &k, Direction direction, bool changedMatch)
Given a valid match, sets up the edge with the previous vertex Creates new edge if it doesn't exist,...
Definition: attentive.cpp:653
void pre_explore()
Prepares transitionsystem for exploration: clears all edges of q0 with states that aren't the current...
Definition: attentive.cpp:533
virtual bool shouldPartiallyExplore(const std::vector< edgeDescriptor > &oe, std::pair< bool, edgeDescriptor > ve)
Psi guard: should only current task be simulated?
Definition: attentive.cpp:850
void explore_plan(b2World &) override
Explores and plan.
Definition: attentive.cpp:547
std::pair< edgeDescriptor, bool > add_vertex_now(const vertexDescriptor &src, vertexDescriptor &v1, Disturbance obs, Edge edge=Edge(), bool topDown=0)
Adds state after discovering it in exploration.
Definition: attentive.cpp:3
virtual 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)
Assesses whether a previous plan can be recycled.
Definition: attentive.cpp:576
std::pair< edgeDescriptor, bool > addEdgeRetrospectively(vertexDescriptor v, vertexDescriptor &v1, const State &s_tmp, std::pair< edgeDescriptor, bool > first_edge, Direction d, float linearSpeed)
Adds edge retrospectively (used in split task)
Definition: attentive.cpp:756
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)
Iterates through vertices, if they result in crash, it splits the tasks and recalculates evaluation f...
Definition: attentive.cpp:212
std::pair< State, Edge > simulation_setup(b2World &w, Task &t, vertexDescriptor v0, b2Transform shift, b2Transform &start, std::vector< Direction >v0_options)
Sets up for simulation.
Definition: attentive.cpp:614
void enforce_edge()
Used to make sure that there is always a connection between DUMMY/MOVING to the next in plan - useful...
Definition: attentive.cpp:845
virtual Disturbance getDisturbance(TransitionSystem &g, vertexDescriptor v, b2World &world, const Direction &dir, const b2Transform &start)
Use attention window to find if any previously avoided obstacle is in the way of the goal,...
Definition: attentive.cpp:29
std::vector< edgeDescriptor > inEdges(vertexDescriptor v, Direction d=UNDEFINED)
Returns a vector of all the in-edges of vertex.
Definition: attentive.cpp:709
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
virtual bool propagateD(vertexDescriptor v1, vertexDescriptor v0, std::set< vertexDescriptor > *closed=NULL, StateMatcher::MATCH_TYPE match=StateMatcher::_FALSE)
Propagate a disturbance backwards to all states representing the same task (max 1)
Definition: attentive.cpp:254
void correctQueue(std::vector< vertexDescriptor > &queue, vertexDescriptor v, vertexDescriptor startRecycle, int planProvSize)
Edits.
Definition: attentive.cpp:770
virtual bool canPropagate(vertexDescriptor v)
propagates only if the previous vertex
Definition: attentive.cpp:245
virtual std::vector< vertexDescriptor > splitTask(vertexDescriptor v, Direction d, vertexDescriptor src=TransitionSystem::null_vertex())
Split tasks into sub-states of fixed length.
Definition: attentive.cpp:155
virtual void transitionMatrix(vertexDescriptor v, Direction d, vertexDescriptor src)
Definition: attentive.cpp:298
virtual Robot makeRobot(b2World &w, const b2Transform &start)
Makes the robot object in the world with the given start position and task.
Definition: attentive.cpp:825
std::pair< edgeDescriptor, bool > add_vertex_retro(vertexDescriptor &src, vertexDescriptor &v1, Edge edge=Edge(), bool topDown=0)
Adds vertices retroactively (e.g. after a state is split)
Definition: attentive.cpp:11
void visitedDirectionsPushBack(vertexDescriptor v, std::vector< Direction > &visitedDirections, Direction direction)
Pushes directions visited at this iteration (not using phi) to input vector.
Definition: attentive.cpp:272
virtual void removeExploredTransitions(vertexDescriptor v)
Definition: attentive.cpp:291
std::vector< Direction > getExploredDirections(vertexDescriptor v, const std::vector< Direction > &directions)
Definition: attentive.cpp:281
std::vector< Direction >::iterator get_next_option(vertexDescriptor v, vertexDescriptor src, std::vector< vertexDescriptor > full_plan)
Returns an iterator to the next option representing a discrete Task transition. If v is in the plan,...
virtual std::vector< Direction > partiallyExplorativeOptions(std::pair< bool, edgeDescriptor > ve)
Assigns options to vertex which has in previous iteration been expanded. Assigns direction of success...
Definition: attentive.cpp:806
bool matchToSafe(VertexMatch &match, const std::vector< VertexMatch > &other_matches=std::vector< VertexMatch >())
if the match is a crashed task
Definition: attentive.cpp:636
void addToPriorityQueue(vertexDescriptor v, std::vector< vertexDescriptor > &queue, const std::set< vertexDescriptor > &closed)
Adds vertexDescriptor to priority queue according to a custom heuristic.
Definition: attentive.cpp:401
virtual std::vector< vertexDescriptor > task_vertices(vertexDescriptor v, std::pair< bool, edgeDescriptor > *ep=NULL)
Rerturns all the vertices making up a task.
Definition: attentive.cpp:662
void adjustProbability(const edgeDescriptor &e)
Adjusts the probability that a continuous state (edge target) will occur after taking a discrete stat...
Definition: attentive.cpp:779
vertexDescriptor getRecyclingStart(vertexDescriptor v, vertexDescriptor v1, vertexDescriptor taskStart)
Returns the vertex from which to start recycling plan.
Definition: attentive.cpp:728
void abandonPlan(std::vector< vertexDescriptor > &planProv, vertexDescriptor v0, vertexDescriptor v1)
Clears plan vector, sets current task to change and clears current vertices.
Definition: attentive.cpp:796
void resetPhi()
Resets all vertices evaluation function phi to a default unitialised value of 10.
Definition: attentive.cpp:19
void applyTransitionMatrix(vertexDescriptor v0, Direction d, bool ended, vertexDescriptor src, std::vector< vertexDescriptor > &plan_prov)
Sets permitted transitions out of a state, formally combines jump guard J and guard Psi.
Definition: attentive.cpp:349
virtual std::vector< vertexDescriptor > explorer(vertexDescriptor v, TransitionSystem &g, b2World &w)
Constructs transition system using a Box2D simulation combined with an A* graph expansion algorithm.
Definition: attentive.cpp:70
Definition: configurator.h:17
virtual void init(Task _task=Task())
Initialises configurator.
Definition: configurator.cpp:22
Configurator that discretises DEFAULT tasks into fixed-length segments. Basically,...
Definition: attentive.h:463
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:993
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
Does not recycle.
Definition: attentive.h:511
VertexMatch findMatch(State s, Direction dir=Direction::UNDEFINED, StateMatcher::MATCH_TYPE match_type=StateMatcher::_TRUE, StateDifference *_sd=NULL, std::vector< VertexMatch > *other_matches=NULL) override
In discrete configurator, matches must be exact and no signal to replan if Task is successful.
Definition: attentive.cpp:906
void transitionMatrix(vertexDescriptor v, Direction d, vertexDescriptor src) override
In discrete configurator, successful DEFAULT tasks can transition to DEFAULT, LEFT,...
Definition: attentive.cpp:914
bool closeVertex(std::set< vertexDescriptor > &closed, vertexDescriptor v) override
Just adds to closed set.
Definition: attentive.cpp:941
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:895
bool canPropagate(vertexDescriptor v) override
propagates only if the previous vertex
Definition: attentive.cpp:1016
void removeExploredTransitions(vertexDescriptor v) override
If the current vertex is matched, don't allow to check plan further.
Definition: attentive.cpp:985
Robot makeRobot(b2World &w, const b2Transform &start) override
Makes the robot object in the world with the given start position and task.
Definition: attentive.cpp:890
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:886
bool shouldPartiallyExplore(const std::vector< edgeDescriptor > &oe, std::pair< bool, edgeDescriptor > ve) override
Psi guard: should only current task be simulated?
Definition: attentive.cpp:981
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:946
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:966
Information about what the configurator is doing (current Task, current vertex), what it wants to do ...
Definition: planner.h:48
Configurator that only replans if the current task fails.
Definition: attentive.h:425
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
Does not recycle.
Definition: attentive.h:441
void adjust_goal_expectation() override
Uses tracking information to adjust the position of the goal relative to the robot.
Definition: attentive.h:449
void removeExploredTransitions(vertexDescriptor v) override
If the current vertex is matched, don't allow to check plan further.
Definition: attentive.cpp:854
virtual VertexMatch findMatch(State s, Direction dir=Direction::UNDEFINED, StateMatcher::MATCH_TYPE match_type=StateMatcher::_TRUE, StateDifference *_sd=NULL, std::vector< VertexMatch > *other_matches=NULL) override
Searches transition System for a match to a state provided. Continuous states are matched,...
Definition: attentive.cpp:861
Robot class for Box2D simulation.
Definition: robot.h:18
Definition: graphTools.h:453
A closed hybrid control loop. It has an initial disturbance representing the continuous state and a d...
Definition: task.h:45
bool is_over()
If task has finished executing.
Definition: task.h:366
Definition: disturbance.h:114
Edges connecting states in the transition system.
Definition: graphTools.h:40
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