Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drive and turn twice behavior, VehicleTurningRight changes have been added #5

Open
wants to merge 2 commits into
base: kathy_branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion srunner/scenarios/behavior_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def create_tree(self):
elif self.turn=='right': self.turn_value = 1
plan = generate_target_waypoint(self.map.get_waypoint(self.start_location), self.turn_value)
self.behavior = WaypointFollower(self.vehicle, self.vehicle_speed, plan=plan)
return self.behavior
return self.behavior, plan

class DriveAndSharpStopAtNextIntersection():
def __init__(self, vehicle, vehicle_speed, distance_from_intersection):
Expand All @@ -65,7 +65,28 @@ def create_tree(self):
self.behavior.add_child(drive_until_intersection_subtree)
self.behavior.add_child(StopVehicle(self.vehicle, 2.0))
return self.behavior


class DriveAndTurnAtNextIntersectionTwice():
def __init__(self, vehicle, vehicle_speed, start_location, turn_1='left', turn_2='left'):
self.vehicle = vehicle
self.vehicle_speed = vehicle_speed
self.start_location = start_location
self.turn_1 = turn_1
self.turn_2 = turn_2
self.map = CarlaDataProvider.get_map()
self.turn_value_1 = -1 #Default to left turn
self.turn_value_2 = -1
self.behavior = None

def create_tree(self):
seq = py_trees.composites.Sequence("Sequence Behavior")
behavior_tree_first_turn, plan = DriveAndTurnAtNextIntersection(self.vehicle, self.vehicle_speed, self.start_location, self.turn_1).create_tree()
behavior_tree_second_turn, plan = DriveAndTurnAtNextIntersection(self.vehicle, self.vehicle_speed, plan[-1][0].transform.location, self.turn_2).create_tree()
seq.add_child(behavior_tree_first_turn)
seq.add_child(behavior_tree_second_turn)
return seq

class DriveAndSlowDownAtNextIntersection():
def __init__(self, vehicle, vehicle_speed, slow_down_speed):
self.vehicle = vehicle
Expand Down
4 changes: 2 additions & 2 deletions srunner/scenarios/object_crash_intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _initialize_actors(self, config):

# Move a certain distance to the front
start_distance = 8
waypoint = waypoint.next(start_distance)[0]
waypoint = waypoint[-1][0].next(start_distance)[0]

# Get the last driving lane to the right
waypoint, self._num_lane_changes = get_right_driving_lane(waypoint)
Expand Down Expand Up @@ -320,7 +320,7 @@ def _initialize_actors(self, config):

# Move a certain distance to the front
start_distance = 8
waypoint = waypoint.next(start_distance)[0]
waypoint = waypoint[-1][0].next(start_distance)[0]

# Get the last driving lane to the right
waypoint, self._num_lane_changes = get_right_driving_lane(waypoint)
Expand Down