# Layered-Cost-Map-Based Traffic Management for Multiple AMRs via a DDS
## 3 Methods
### Layered Cost Map
#### 3.2.1 Filters  
Let us consider an area where high-risk locations exist without obstacles for AMRs. Such an area can be designated as a prohibited area by a user-defined image to prevent AMRs from passing through it. As AMRs are prevented from trespassing on this area, the cost map layer is named the prohibition filter. The cost exhibits a maximum level of 254. If necessary, it can be reduced to a non-maximum level so that the AMR can flexibly trespass on the area when it needs to avoid dynamic obstacles. We designate a prohibition filter by adding the filter part as a suffix because a separate map is required. In contrast to a static map, we call the map the prohibition filter mask map. Similar to the static map, the mask map is transmitted from a separate map server and delivered to the topic--/prohibition_mask. The prohibition filter is then created from the mask map and is overlapped with the existing lower-cost map layers using the OR operation. As shown in Figure 2, the mask map is created with the static map by adding the prohibited area marked in black. AMRs can effectively pass through a long and narrow passageway with pedestrians or other AMRs simultaneously if AMRs are regulated according to right-hand traffic. The lane filter is in charge of enforcing such a traffic rule. The lane filter uses a map server that requires a separate mask map file to send maps as topics--/lane_mask. However, one difference is that it receives a 16-bit map file to set directions. The lane filter map server is  
Figure 2: Layered cost map: the prohibition filter, lane filter, fleet layer, and region filter. designed to receive the 16-bit map file to set the 16-bit direction cost map. Similar to the mask map of the prohibition filter, the 16-bit mask map is converted to a cost map. The cost can be dynamically adjusted according to the yaw angle of the AMR, as described in Algorithm 1. ```
Input :\(\angle\) robot; the yaw angle of the robot \(\angle\) lane; pixel color value in range 0 to 35999 Output : Cost functionGetCost(\(\angle\) robot, \(\angle\) lane)  Wait for the response of the action server if0.4 \(\leq\cos(\angle_{\text{robot}}-\angle_{\text{lane}})\leq 1.0\)then  Cost = 0 elseif\(-1.0\leq\cos(\angle_{\text{robot}}-\angle_{\text{lane}})\leq-0.4\)then  Cost = 254 else  Cost = 128 endif return Cost endfunction
```  
**Algorithm 1** Lane filter  
In a multi-AMR system, there could be limits on the number of AMRs in a particular area. For example, if two AMRs enter a narrow road, which is challenging to pass simultaneously, they may enter a deadlock situation. To cope with this situation, the region filter can be designed to prevent deadlock when multiple AMRs enter the same area simultaneously. The region is represented by the convex hull. The convex hull region is configured with a set of vertices, which defines an array type in the YAML file. The configuration of the region filter is obtained using the text-based parameter file. The region list includes x and y coordinate vectors with [double, double] type. When an AMR enters a pre-designated area by setting an exclusive area in the cost map, it changes the free space to an occupied space, prohibiting other AMRs; thus, we define the layer as the region filter. In the region filter, when one AMR enters the exclusive area, the information must be reflected in the cost map of other AMRs; thus, location sharing among AMRs is required. The region filter communicates with the region filter server to reserve or release the region. The region filter in an AMR requests a ticket with a topic--/ticket--from the region filter server to enter the region. The region filter returns the ticket with the topic--/ticket--to the region filter server to leave the region. The region filter server responds to the region filter of each AMR based on robot ID and region ID to identify the AMRs and regions. The region filter is implemented by Algorithm 2.