Files Walkthrough - AD-EYE/AD-EYE_Core GitHub Wiki
File by File Walkthrough of the VectorMapper
Utils.py
• Circle_from_p1p2r(p1,p2,r)
Give the position of the center of the circle going through P1 and P2 with a radius equal to r
• Radius_of_circle(p1,p2,angle)
Give the radius of a circle that goes thought P1and P2 with the angle between P1Center and P2Center being equal to the angle
• Dist(p1,p2)
Return the distance between P1 and P2
• Intersection_Lines(L1, L2)
Find the point of intersection between two lines represented by a tab of (x,y) points (L1 and L2) If the lines are parallel, return a middle point
• Intersection_Circle(C1, C2)
Find the point(s) of intersection between two circles represented by a tab containing the coordinate of the center of the circle and its radius
Path.py
Define useful geometry in order to build different available road types. So basically, define the building block (Bend, Curve, and Straight) that will be used to define every RT (Roundabout, Straight Road and so on) In order to do that, the first class define is an iterable class which will define the actual path (with points!) of the object that will be defined later
- Path
Define the actual path object which is iterable
-Init
-Next
Those two define the iterable class
-Getstart/Getend
Provide the start/end point of the path (the eval function used in those functions are defined for each path type cf 3 next classes)
- Bend(Path)
Define a path which is a part of a circle
-Init
x0, y0: Starting Coordinate of the Bend Path
A0: Global heading of the ST point
da: Heading at the endpoint relative to the curve heading
r: distance of the curve from the center of the circle used to rep the curve
Path.init(self, 1/r, np.ad(da)) => init the path with the right values
-Eval(t)
Return the coordinate of the point at t
- Curve(Path)
Define a path which is represented by a Bezier Curve
-Init
xs, ys: Tab of 4 points that define the Bezier curve
Offset: The offset allow to offset the curve according to your liking (similar to the b in ax+b)
c: Points defining the curve itself
Path.init(self, 1/len( c ), 1) => init the path with the right values
-Dpdt(t)
Calculate the next iteration
-eval(t)
Return the coord of the point at t
- Straight(Path)
Define a path which is represented by a Straight line
-Init
x0, y0: Starting Coordinate of the Bend Path
h: Global Heading of the road
Path.init(self, 1, 0),l => init the path with the right values
-eval(t)
Return the coord of the point at t
Road.py
Define all the road type (RT) that made the simulation (Straight Road, Bend road, X crossing and so on) using the geometry define in path.py Here how this module shapes up: First we define a class name Road. We do this because every RT has some things in common (such as a centerline, lanes, speed limits, edges and so on) Then using this class, we build each RT as a class that uses the Road class as an object and define the rest of things that are unique to the specific RT (For instance, for Roundabout, you’ll see the mention of exit lanes)
- Road
So just like class Path, this class define an object road that will be used by each RT class
-Init
ID: String that ref the RT (those ID are defined by prescan, cf List of ID)
c: Tab of point OR Path Object that defines the centerline of the Road
e1/e2: Tab of point OR Path Object that defines the edges of the Road
l: Tab of lanes (so it’s basically a tab of tab of points representing the lanes of the roads)
SpeedLimit/RefSpeed: Define the speed limit of the road and the speed at which you should go (ref speed)
-Getstart/getend
Give the centers point of the beginning /ending of the road
- BendRoad(Road)
This class define the RT bend road which is a turn that can be represented by a part of a circle
-Init
ID: Give the ID of BendRoad to feed it to the init method of Road Class
x0, y0: Starting point (STP) of the road (center of the road)
l: Tab of lanes (so it’s basically a tab of tab of points representing the lanes of the roads)
h: global heading of the road at the STP
rh: Heading relative of the end of the road
lw: lane width
nb_of_lanes: nb of lanes in total
nb_of_lanes_in_x_dir : nb of lanes going in the x-direction
Init fill up e1/e2 / c / l of the Road object with the Bend class define in path.py
- CurvedRoad(Road)
This class define the RT curve road with is a road define by a Bezier curve
-Init
ID: Give the ID of BendRoad to feed it to the init method of Road Class
x0, y0: Starting point (STP) of the road (center of the road)
l: Tab of lanes (so it’s basically a tab of tab of points representing the lanes of the roads)
h: global heading of the road at the STP
rh: Heading relative of the end of the road
lw: lane width
nb_of_lanes: nb of lanes in total
nb_of_lanes_in_x_dir : nb of lanes going in the x-direction
cp1: Represent the distance between the first control point (P1) to the STP w/ an angle between those two points of h
cp2: Represent the distance between the snd control point (P2) to the STP w/ an angle between those two points of rh
dx/dy : offset endpoint / STP
- StraightRoad(Road)
This class defines the RT StraightRoad which is a ... Straight road!
-Init
ID: Give the ID of StraightRoad to feed it to the init method of Road Class
x0,y0: Starting point (STP) of the road (center of the road)
l: Tab of lanes (so it’s basically a tab of tab of points representing the lanes of the roads)
h: global heading of the road at the STP
lw: lane width
nb_of_lanes: nb of lanes in total
nb_of_lanes_in_x_dir : nb of lanes going in the x-direction
Init fill up e1/e2 / c / l of the Road object with the Bend class define in path.py
- AdapterRoad(Road)
This class define the RT AdapterRoad which is a road use to add/remove a lane
-Init
ID: Give the ID of StraightRoad to feed it to the init method of Road Class
x0,y0: Starting point (STP) of the road (center of the road)
l: Tab of lanes (so it’s basically a tab of tab of points representing the lanes of the roads)
h: global heading of the road at the STP
lw: lane width
nb_of_lanes: nb of lanes in total
nb_of_lanes_in_x_dir: nb of lanes going in the x-direction
Init fill up e1/e2 / c / l of the Road object with the Bend class define in path.py
Parse.py
The Parse module takes everything useful that define the Road network created in Prescan, and fill up two lists: a list called Road, which contains everything related to roads that compose the Road Network, and a list called StaticalObject that contains only information related to traffic light, at the time of writing. Those two lists are filled up using two function called get_staticalobject and get_roads
Let's first study get_roads get_roas call others function get_X with X being a Road Type: Those get_X functions are the one that goe and take the relevant information concerning the road being added to the road list that is in the road network. Most Road type share parameters in common, such as General Heading of the Road, number of lanes, speed limit of the road and so on. So for most road type, the get_X has no notable feature. But for some, such as Roundabout, X and Y crossing, and Straight Road, some feature should be discussed further.
Roundabout
For Roundabout, in addition to all the basic things, you'll find for every Road type, you have the heading and number of lanes for each crosssection. Moreover, you'll find that the parse also outputs a list called TabPointCon, which basically gives out the middle point of each crosssection's beginning.
X/Y Crossing
Much like Roundabout, you'll find that the get_X/Ycrossing function return heading and the number of lanes per crosssection. But you'll also find that the length of each crosssection is outputted as well: This lead to the final difference: stop lines for each crosssection are directly calculated here, in a way that supports multilane stop line. This means that if your X crossing, for instance, has 3 lanes with are concerned by the stop line, only one stop line will be created, and that stop line will be created across the 3 lanes. So for X/Y crossing, you don't have the usual one lane = one stop line
Straight Road
The only main difference with Straight Road is that multi-lane support for traffics light for attempted. You'll see that in the Stop line tab, the last int of the tab is not 1 but the number of lane on the opposite of x-direction.
Preproc.py
The Preproc Module has 2 main classes: The RoadProcessor and the StaticalObjectProcessor
Those two classes work in the same way, so we'll only have a detailed view of the RoadProcessor class.
Images/InnerWorkingPreproc.PNG
As you can see, the RoadProccesor class has 5 Lists as variables: Road, Lane, Stopline, Edges, and Centers.
Edges, Centers, and Lane will be filled by an object Lane, which is a class (with a confusing name) used to describe Edges, Centers and Lanes by describing those as lists of points and some other information (cf image)
Roads is a list filled by Road define using the Road.py module: This list basically contains the Road Network we define while creating the simulated world in Prescan.
Stopline is a list of 3 points (start of the stop line, end of the stop line and middle point of the stop line) and an integer giving the number of lanes on the road on which the stopline is (usefull for traffic light)
The road list is an input given by the parse module. All the other lists are filled by the __create_lane function, which called every __create_RoadType functions that use two functions: __get_RoadType and __add_RoadType