View Javadoc
1   package org.opentrafficsim.road.gtu.lane.perception;
2   
3   import org.djunits.value.vdouble.scalar.Length;
4   
5   /**
6    * This data structure can clearly indicate the lane structure ahead of us, e.g. in the following situation:
7    * 
8    * <pre>
9    *     (---- a ----)(---- b ----)(---- c ----)(---- d ----)(---- e ----)(---- f ----)(---- g ----)  
10   *                                             __________                             __________
11   *                                            / _________ 1                          / _________ 2
12   *                                           / /                                    / /
13   *                                __________/ /             _______________________/ /
14   *  1  ____________ ____________ /_ _ _ _ _ _/____________ /_ _ _ _ _ _ _ _ _ _ _ _ /      
15   *  0 |_ _X_ _ _ _ |_ _ _ _ _ _ |_ _ _ _ _ _ |_ _ _ _ _ _ |_ _ _ _ _ _ |_ _ _ _ _ _ \____________
16   * -1 |____________|_ _ _ _ _ _ |____________|____________|  __________|____________|____________| 3
17   * -2              / __________/                           \ \  
18   *        ________/ /                                       \ \___________  
19   *      5 _________/                                         \____________  4
20   * </pre>
21   * 
22   * When the GTU is looking ahead, it needs to know that when it continues to destination 3, it needs to shift one lane to the
23   * right at some point, but <b>not</b> two lanes to the right in link b, and not later than at the end of link f. When it needs
24   * to go to destination 1, it needs to shift to the left in link c. When it has to go to destination 2, it has to shift to the
25   * left, but not earlier than at link e. At node [de], it is possible to leave the rightmost lane of link e, and go to
26   * destination 4. The rightmost lane just splits into two lanes at the end of link d, and the GTU can either continue driving to
27   * destination 3, turn right to destination 4. This means that the right lane of link d has <b>two</b> successor lanes.
28   * <p>
29   * In the data structures, lanes are numbered laterally. Suppose that the lane where vehicle X resides would be number 0.
30   * Consistent with "left is positive" for angles, the lane right of X would have number -1, and entry 5 would have number -2.
31   * <p>
32   * In the data structure, this can be indicated as follows (N = next, P = previous, L = left, R = right, D = lane drop, . =
33   * continued but not in this structure). The merge lane in b is considered "off limits" for the GTUs on the "main" lane -1; the
34   * "main" lane 0 is considered off limits from the exit lanes on c, e, and f. Still, we need to maintain pointers to these
35   * lanes, as we are interested in the GTUs potentially driving next to us, feeding into our lane, etc.
36   * 
37   * <pre>
38   *       1                0               -1               -2
39   *       
40   *                       ROOT 
41   *                   _____|_____      ___________      ___________            
42   *                  |_-_|_._|_R_|----|_L_|_._|_-_|    |_-_|_._|_-_|  a           
43   *                        |                |                |
44   *                   _____V_____      _____V_____      _____V_____            
45   *                  |_-_|_N_|_R_|----|_L_|_N_|_R_|&lt;---|_L_|_D_|_-_|  b           
46   *                        |                |                 
47   *  ___________      _____V_____      _____V_____                 
48   * |_-_|_N_|_R_|&lt;---|_L_|_N_|_R_|----|_L_|_N_|_-_|                   c
49   *       |                |                |                 
50   *  _____V_____      _____V_____      _____V_____                 
51   * |_-_|_._|_-_|    |_-_|_N_|_R_|----|_L_|_NN|_-_|                   d          
52   *                        |                ||_______________ 
53   *  ___________      _____V_____      _____V_____      _____V_____            
54   * |_-_|_N_|_R_|&lt;---|_L_|_N_|_R_|----|_L_|_N_|_-_|    |_-_|_N_|_-_|  e          
55   *       |                |                |                |
56   *  _____V_____      _____V_____      _____V_____      _____V_____            
57   * |_-_|_N_|_R_|&lt;---|_L_|_D_|_R_|----|_L_|_N_|_-_|    |_-_|_._|_-_|  f          
58   *       |                                 |                 
59   *  _____V_____                       _____V_____                             
60   * |_-_|_._|_-_|                     |_-_|_._|_-_|                   g          
61   * 
62   * 
63   * </pre>
64   * <p>
65   * Copyright (c) 2013-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
66   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
67   * </p>
68   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
69   * initial version Feb 20, 2016 <br>
70   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
71   */
72  public class LaneStructure
73  {
74      /** The length of this structure, to see if it needs updating. */
75      private Length.Rel length;
76  
77      /** The lanes from which we observe the situation. */
78      private LaneStructureRecord rootLSR;
79  
80      /**
81       * @param initialRootLSR the initial rot record. 
82       * 
83       */
84      public LaneStructure(final LaneStructureRecord initialRootLSR)
85      {
86          setRootLSR(initialRootLSR);
87      }
88  
89      /**
90       * @return rootLSR
91       */
92      public final LaneStructureRecord getRootLSR()
93      {
94          return this.rootLSR;
95      }
96  
97      /**
98       * @param rootLSR set rootLSR
99       */
100     public final void setRootLSR(final LaneStructureRecord rootLSR)
101     {
102         this.rootLSR = rootLSR;
103     }
104 
105     /**
106      * @return length
107      */
108     public final Length.Rel getLength()
109     {
110         return this.length;
111     }
112 
113 }