Esempio n. 1
0
 def check_obstacles(self, vehicles):
     minimumDistance = 1000
     for vehicle in vehicles:
         if self.vehicle_type == "Pedrestian":  # and vehicle.vehicle_type == "Pedrestian":
             continue
         elif vehicle.RightOfPassage == 0 and self.RightOfPassage == 1 and self.vehicle_type != "Pedrestian":
             # The vehicle doesn't have right of passage (not in roundabout)
             continue
         elif self.position == vehicle.position:
             # It's our vehicle
             continue
         else:
             distance = utils.calc_distance(self.position, vehicle.position)
             angle = abs(utils.calc_angle(self.position, vehicle.position) - self.direction)
             current_vision = self.vision_angle
             if (
                 self.RightOfPassage == 0
                 and self.velocity < 0.75 * self.max_velocity
                 and vehicle.RightOfPassage == 1
             ):
                 current_vision = self.vision_angle_entrance
             if distance <= self.range_of_sight and angle < current_vision:
                 stopDistance = (
                     utils.calc_stopDistance(distance, angle) - self.length * 2 - vehicle.length
                 )  # 3 times radius
                 if stopDistance < minimumDistance:
                     minimumDistance = stopDistance
     return minimumDistance
Esempio n. 2
0
 def GetDistanceToBusStop(self,position,direction):
     deltaX=self.roads[2][0]-self.roads[1][0]
     deltaY=self.roads[2][1]-self.roads[1][1]
     busStopX=self.roads[1][0]+deltaX*0.5
     busStopY=self.roads[1][1]+deltaY*0.5
     dist=utils.calc_distance((busStopX,busStopY),position)
     if (abs(utils.calc_angle(position, (busStopX,busStopY)) - direction)>math.pi/2):
         dist=-dist
     return dist
Esempio n. 3
0
 def get_direction(self):
     next_pos = self.road.GetNodePosition(self.nextNode)
     return utils.calc_angle(self.position, next_pos)