Skip to content

Commit

Permalink
Add task list sorting in goap.Runner and two TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Kolbe committed Jan 9, 2014
1 parent c68a1d5 commit a4d511e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions goap/src/goap/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def get_child_nodes_for_valid_actions(self, actions_generator, start_worldstate)


class Planner(object):
# TODO: make ordering of actions possible (e.g. move before lookaround)

def __init__(self, actionbag, worldstate, goal):
self._actionbag = actionbag
Expand Down
9 changes: 7 additions & 2 deletions goap/src/goap/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def __init__(self, runner, **kwargs):
self.runner = runner

def execute(self, userdata):
# TODO: propagate preemption request into goap submachine
goal = self.build_goal(userdata)
# avoid duplicate introspection:
outcome = self.runner.update_and_plan_and_execute(goal, introspection=False)
Expand Down Expand Up @@ -282,8 +283,8 @@ def test_tasker():
with sm_tasker:
## add all tasks to be available
# states using goap
StateMachine.add('MOVE_TO_NEW_GOAL', sq_move_to_new_goal)
StateMachine.add('INCREASE_AWARENESS', IncreaseAwarenessGOAPState(runner))
StateMachine.add('MOVE_TO_NEW_GOAL_GOAP', sq_move_to_new_goal)
StateMachine.add('INCREASE_AWARENESS_GOAP', IncreaseAwarenessGOAPState(runner))

# states from uashh_smach
StateMachine.add('LOOK_AROUND', get_lookaround_smach())
Expand All @@ -301,6 +302,10 @@ def test_tasker():
## now the task receiver is created and automatically links to
## all task states added above
task_states_labels = sm_tasker.get_children().keys()
task_states_labels = sorted(task_states_labels) # sort alphabetically
task_states_labels = sorted(task_states_labels, # sort by _GOAP
key=lambda label: '_GOAP' in label,
reverse=True)
task_receiver_transitions = {'undefined_outcome':'undefined_task'}
task_receiver_transitions.update({l:l for l in task_states_labels})

Expand Down

0 comments on commit a4d511e

Please sign in to comment.