src/TrafficSimulator.py
def generate_car(self, p_notcomm = 0.1, probability_left_turn=0.33, probability_right_turn=0.33):
        ''' Create new autonomous vehicle.  Returns None if it will collide with car in system'''

        new_car = AV.AutonomousVehicle(-1)
        new_car.set_traffic_coordinator(self.coordinator)
        self.update_robot_map_specs(new_car)
        new_car_lane = np.random.choice(["-2","2","-1","1"])      
        all_lanes = ["2","-1","-2","1"]
        # all_lanes = ["-2","2"]
        new_car_lane = all_lanes[self.next_agent_id%len(all_lanes)]

        new_car.initialize_beginning_lane(new_car_lane)
        new_car.turn_direction = new_car.get_random_turn(probability_left_turn, probability_right_turn)
        r= np.random.random()
        if 0.0001 < r <= p_notcomm:
            new_car.notcommunicating = True
        else:
            new_car.notcommunicating = False
        # if self.next_agent_id%2 == 0:
        #     new_car.notcommunicating = True
        # else:
        #     new_car.notcommunicating = False
        
        # Check if lane is free
        new_pose = new_car.get_next_step_pose_lane(new_car.current_lane,self.deltaT*new_car._maxSpeed)
        no_collision = new_car.collision_free(new_pose,self.occupancy_map,new_car.pose)
        if no_collision:
            return new_car
        else:
            return None
 Create new autonomous vehicle.  Returns None if it will collide with car in system
Create new autonomous vehicle.  Returns None if it will collide with car in system
Create new autonomous vehicle . Returns None if it will collide with car in system
def generate_car(self, p_notcomm = 0.1, probability_left_turn=0.33, probability_right_turn=0.33):
        new_car = AV.AutonomousVehicle(-1)
        new_car.set_traffic_coordinator(self.coordinator)
        self.update_robot_map_specs(new_car)
        new_car_lane = np.random.choice(["-2","2","-1","1"])      
        all_lanes = ["2","-1","-2","1"]
        new_car_lane = all_lanes[self.next_agent_id%len(all_lanes)]
        new_car.initialize_beginning_lane(new_car_lane)
        new_car.turn_direction = new_car.get_random_turn(probability_left_turn, probability_right_turn)
        r= np.random.random()
        if 0.0001 < r <= p_notcomm:
            new_car.notcommunicating = True
        else:
            new_car.notcommunicating = False
        new_pose = new_car.get_next_step_pose_lane(new_car.current_lane,self.deltaT*new_car._maxSpeed)
        no_collision = new_car.collision_free(new_pose,self.occupancy_map,new_car.pose)
        if no_collision:
            return new_car
        else:
            return None
def generate_car ( self , p_notcomm = 0.1 , probability_left_turn = 0.33 , probability_right_turn = 0.33 ) : new_car = AV . AutonomousVehicle ( - 1 ) new_car . set_traffic_coordinator ( self . coordinator ) self . update_robot_map_specs ( new_car ) new_car_lane = np . random . choice ( [ "-2" , "2" , "-1" , "1" ] ) all_lanes = [ "2" , "-1" , "-2" , "1" ] new_car_lane = all_lanes [ self . next_agent_id % len ( all_lanes ) ] new_car . initialize_beginning_lane ( new_car_lane ) new_car . turn_direction = new_car . get_random_turn ( probability_left_turn , probability_right_turn ) r = np . random . random ( ) if 0.0001 < r <= p_notcomm : new_car . notcommunicating = True else : new_car . notcommunicating = False new_pose = new_car . get_next_step_pose_lane ( new_car . current_lane , self . deltaT * new_car . _maxSpeed ) no_collision = new_car . collision_free ( new_pose , self . occupancy_map , new_car . pose ) if no_collision : return new_car else : return None
Create new autonomous vehicle.
Create new autonomous vehicle .
''' Create new autonomous vehicle.  Returns None if it will collide with car in system''' # all_lanes = ["-2","2"] # if self.next_agent_id%2 == 0: #     new_car.notcommunicating = True # else: #     new_car.notcommunicating = False # Check if lane is free
self
p_notcomm
probability_left_turn
probability_right_turn