Skip to content

Commit

Permalink
Merge pull request #180 from una-auxme:175-feature-creating-the-overt…
Browse files Browse the repository at this point in the history
…aking-behavior

feat: Add new behavior overtake
  • Loading branch information
samuelkuehnel committed Jan 29, 2024
2 parents 26aab61 + fafa196 commit f76de0e
Show file tree
Hide file tree
Showing 5 changed files with 517 additions and 82 deletions.
20 changes: 18 additions & 2 deletions code/planning/src/behavior_agent/behavior_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def grow_a_tree(role_name):
Sequence("Intersection",
children=[
behaviours.road_features.IntersectionAhead
("Intersection Ahead"),
("Intersection Ahead?"),
Sequence("Intersection Actions",
children=[
behaviours.intersection.Approach
Expand All @@ -47,7 +47,7 @@ def grow_a_tree(role_name):
Sequence("Laneswitch",
children=[
behaviours.road_features.LaneChangeAhead
("Lane Change Ahead"),
("Lane Change Ahead?"),
Sequence("Lane Change Actions",
children=[
behaviours.lane_change.Approach
Expand All @@ -60,6 +60,22 @@ def grow_a_tree(role_name):
("Leave Change")
])
]),
Sequence("Overtaking",
children=[
behaviours.road_features.OvertakeAhead
("Overtake Ahead?"),
Sequence("Overtake Actions",
children=[
behaviours.overtake.Approach
("Approach Overtake"),
behaviours.overtake.Wait
("Wait Overtake"),
behaviours.overtake.Enter
("Enter Overtake"),
behaviours.overtake.Leave
("Leave Overtake")
])
]),

]),
behaviours.maneuvers.Cruise("Cruise")
Expand Down
79 changes: 0 additions & 79 deletions code/planning/src/behavior_agent/behaviours/maneuvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,85 +285,6 @@ def terminate(self, new_status):
(self.name, self.status, new_status))


class Overtake(py_trees.behaviour.Behaviour):
"""
This behavior handles the overtaking process.
"""
def __init__(self, name):
"""
Minimal one-time initialisation. A good rule of thumb is to only
include the initialisation relevant for being able to insert this
behaviour in a tree for offline rendering to dot graphs.
:param name: name of the behaviour
"""
super(Overtake, self).__init__(name)

def setup(self, timeout):
"""
Delayed one-time initialisation that would otherwise interfere with
offline rendering of this behaviour in a tree to dot graph or
validation of the behaviour's configuration.
This initializes the blackboard to be able to access data written to it
by the ROS topics.
:param timeout: an initial timeout to see if the tree generation is
successful
:return: True, as there is nothing to set up.
"""
self.Success = False
self.blackboard = py_trees.blackboard.Blackboard()
return True

def initialise(self):
"""
When is this called?
The first time your behaviour is ticked and anytime the status is not
RUNNING thereafter.
What to do here?
Any initialisation you need before putting your behaviour to work.
:return: True
"""
return True

def update(self):
"""
When is this called?
Every time your behaviour is ticked.
What to do here?
- Triggering, checking, monitoring. Anything...but do not block!
- Set a feedback message
- return a py_trees.common.Status.[RUNNING, SUCCESS, FAILURE]
This behaviour runs until the agent is on a different lane as in the
start of this behavior
:return: py_trees.common.Status.SUCCESS, if this behavior is
implemented
py_trees.common.Status.FAILURE, otherwise
"""
if self.Success:
return py_trees.common.Status.SUCCESS
else:
return py_trees.common.Status.RUNNING

def terminate(self, new_status):
"""
When is this called?
Whenever your behaviour switches to a non-running state.
- SUCCESS || FAILURE : your behaviour's work cycle has finished
- INVALID : a higher priority branch has interrupted, or shutting
down
writes a status message to the console when the behaviour terminates
"""
self.logger.debug(" %s [Foo::terminate().terminate()][%s->%s]" %
(self.name, self.status, new_status))


class Cruise(py_trees.behaviour.Behaviour):
"""
This behaviour is the lowest priority one and will be executed when no
Expand Down
Loading

0 comments on commit f76de0e

Please sign in to comment.