I am specifying this collision avoidance behavior for when my ego vehicle
behavior CollisionAvoidance():
while withinDistanceToAnyObjs(self, SAFETY_DISTANCE):
take SetBrakeAction(MAX_BREAK_THRESHOLD)
How can I allow this behavior only when the blocking object is in the same lane as that of the ego. The ego vehicle should start moving again once the obstacle is clear of the current lane while this object is still in the double lane
I am trying to make two cars drive in the opposite direction for sometime. Here is my full code for context:
param map = localPath(‘../assets/maps/CARLA/Town01.xodr’)
roadA = network.roads[0] # pick first road for illustration
if roadA.backwardLanes != None:
fwd_group = roadA.forwardLanes
bwd_group = roadA.backwardLanes
else:
print(‘No backward lanes on this road!’)
laneFwd = fwd_group.lanes[0]
laneBwd = bwd_group.lanes[0]
(Place two cars on these lanes, facing each other)
ego = new Car on laneFwd.centerline, with behavior EgoBehavior(EGO_SPEED)
car2 = new Car on laneBwd.centerline, facing directly toward ego, with behavior EgoBehavior(EGO_SPEED)
Additionally, how can I ensure that the other car is always in front of the ego car (in addition to facing the opposite directions)?