Skip to content

Latest commit

 

History

History
151 lines (111 loc) · 4.69 KB

ReadMe.md

File metadata and controls

151 lines (111 loc) · 4.69 KB

RNDF Reader

This directory contains the scripts to read an RNDF file and extract the adjacency list and waypoints information, which will be used to generate the waypoints dictionary and control points dictionary.

How to use
  • Place the rndf that needs to be parsed using rndfreader in 'src' directory

  • Run the script 'rndf2dicts.py'

        $ python rndf2dicts.py
  • After the execution of the above command, wait for the script to finish the execution.

  • This script creates a seperate directory for each RNDF file with the file name in 'dicts' directory.

  • Now, go to each directory and check the control points dictionary. From the control points dictionary, we need to remove the duplicates and modify the entry that is prefixed with '*'.

  • To modify the entry, use approximate2circulararc script. Before using, fit a circular arc between the two waypoints.

  • After the modification, waypoints_dict.txt, adjacencylist_dict.txt, and controlpoints_dict.txt are ready to be used in the ros package. Move the folder with these files to 'package_location/scripts/database/'



PACKAGE INFORMATION
Dependencies

re collections StringIO networkx numpy matplotlib

Directory Structure
        rndf_reader
        |-- approximate2circulararc.py
        |-- bezier_interpolation_def.py
        |-- dicts
        |-- ReadMe.md
        |-- readrndf.py
        |-- rndf2dicts.py
        `-- src
            |-- road1.rndf
            `-- road2.rndf

'src/' directory contains the RNDF files to be parsed.

Read RNDF module (readrndf.py)

This script has classes defined to read RNDF file. These classes segregate the different sections in order for the other scripts to have access to the data, and create waypoints dictionary and Adjacency list.

class readrndf.waypointsDict(rndf_filename)

Create an instance of the class 'waypointsDict' and call the method 'dict()' to create a dictionary of all the waypoints (waypoint ids as keys and locations as values)

Ex:

    >>> from readrndf import *
    >>> wpd = waypointsDict('example.rndf')
    >>> wpDict = wpd.dict()

Here, we are following the top-bottom approach to read an RNDF file.

class readrndf.segmentDict(rndf_filename)

'segmentsDict' breaks the file and stores the information as a dictionary where segment id is the key and the information of the lanes is the value

Ex:

    >>> from readrndf import *
    >>> sd = segmentDict('example.rndf')
    >>> sDict = sd.dict()

class readrndf.rndfSegments(segment_info)

'rndfSegments' class reads info that we get from segment dictionary. This class provides access to the information of the segment such as segment name, segment id, and number of lanes present in the segment. Also, it has method to break the segment information and generate a dictionary which stores lane information mapped to lane serial number

Ex:

    >>> from readrndf import *
    >>> rndfSeg = rndfSegments(segmentInfo) # get segmentInfo from the above dictionary 'sDict'
    >>> segName = rndfSeg.name
    >>> segID   = rndfSeg.segment_id
    >>> segNumLanes = rndfSeg.num_lanes
    >>> segLanes = rndfSeg.laneDict()

class readrndf.rndfLanes(lane_info)

'rndfLanes' class takes information from the rndfSegments class and gives access to the lane id, lane width, boundary information and also creates the list of exit points, stop points, waypoints dictionary.

Ex:

    
    >>> from readrndf import *
    >>> rndfLan = rndfLanes(laneInfo) 
    >>> laneId = rndfLan.laneId
    >>> numWaypoints = rndfLan.numWaypoints
    >>> laneWidth = rndfLan.laneWidth
    >>> leftBoundary = rndfLan.leftBoundary
    >>> rightBoundary = rndfLan.rightBoundary
    >>> checkPoints = rndfLan.checkPoints
    >>> stopPoints = rndfLan.stopPoints
    >>> exitPoints  = rndfLan.exitPoints 
    >>> waypointDict = rndfLan.waypointDict
Create Dictionaries from RNDF (rndf2dicts.py)

This is a script to convert rndf file into waypoints dictionary, control points dictionary, and adjacency list. Some of the entries in the control points dictionary have to be modified if the bezier curve generated by a control points entry violates the deviation and curvature constraint.

Example:

# import this script 
# create an instance and initialize with layout name (ex: example.rndf)

makedicts = makeDicts('example')


# call the method 'createCPDict()' to control points dictionary
makedicts.createCPDict()


# call the method 'createAdjListWaypointsDict()' to create adjacency list
# and waypoints dictionary

makedicts.createAdjListWaypointsDict()


# clean files that are created in the process
makedicts.clean()