Skip to content

Commit

Permalink
docs: added documentation for speed camera function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
vijay-jaisankar committed May 6, 2022
1 parent a351fd9 commit e998efc
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 30 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

## Installation
- `python -m pip install --upgrade pip`
- `pip install trafficinterventions xml`
- `pip install --upgrade trafficinterventions`

---
## Documentation
All relevant files can be found [here](https://github.com/WSL-IIITB/Traffic-Interventions/tree/main/docs)

---

## Interventions

### Sample Usage : Edge Manipulation
```py
import trafficinterventions
Expand All @@ -32,3 +34,23 @@ cl = trafficinterventions.ChangeLanes.ChangeLanes(fileName="sample.xml")
ce.changePriorityLanes(["highway.cycleway"], 100, "new_file.xml")

```
## Simulations

### Sample Usage: Speed Camera Placement
```py
import trafficinterventions


sc = trafficinterventions.SpeedCamera.SpeedCamera(
maxTimeSteps= 1000,
nearestNeighbourDisallow= 250.0,
gridArray=[-10000,10000,10000,-10000],
pathCFG="map.sumocfg",
outPath="Outputs/",
summaryFilePath="summary.txt",
numLocs=5
)

# Run the simulation and get outputs
sc.runSimulation()
```
31 changes: 31 additions & 0 deletions docs/change_edges.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import trafficinterventions

"""
Note: If you wish to not rewrite the XML file, please add another parameter to the functions.
"""

"""
Change Edges Functionality
"""

# Instantiating an object of the XML Parser for Lane Modification
fileName = "sample.xml" # Change the path of your file accordingly.
ce = trafficinterventions.ChangeEdges.ChangeEdges(fileName=fileName)

# Get Root Tag
print(ce.getRootElementTag())

# Get Unique Parent Tags
print(ce.getUniqueParentTags())

# Get the first 10 Lane Type IDs
print(ce.getUniqueEdgeIDs()[:10])

# Get Edge Inforation
ce.getEdgeInformation(["-734354815#0"])

# # Selectively disallow vehicle types from edge
ce.disallowAppendTypes(["truck", "bus"], ["-734354815#0"], None)

# Selectively allow vehicle types from edge
ce.allowAppendTypes(["e-scooter"], ["-777797681"], None)
30 changes: 1 addition & 29 deletions docs/index.py → docs/change_lanes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,6 @@
Note: If you wish to not rewrite the XML file, please add another parameter to the functions.
"""

"""
Change Edges Functionality
"""

# Instantiating an object of the XML Parser for Lane Modification
fileName = "sample.xml" # Change the path of your file accordingly.
ce = trafficinterventions.ChangeEdges.ChangeEdges(fileName=fileName)

# Get Root Tag
print(ce.getRootElementTag())

# Get Unique Parent Tags
print(ce.getUniqueParentTags())

# Get the first 10 Lane Type IDs
print(ce.getUniqueEdgeIDs()[:10])

# Get Edge Inforation
ce.getEdgeInformation(["-734354815#0"])

# # Selectively disallow vehicle types from edge
ce.disallowAppendTypes(["truck", "bus"], ["-734354815#0"], None)

# Selectively allow vehicle types from edge
ce.allowAppendTypes(["e-scooter"], ["-777797681"], None)

"""
Change Lanes Functionality
"""
Expand All @@ -47,7 +21,6 @@
print(cl.getLaneTypes())

# Get all Lane Information

print(cl.getLaneInformation())

# Changing priorities of highway.cycleway lanes to 2
Expand All @@ -73,5 +46,4 @@
cl.changeNumLanes(
[l[i][0]],
2 * int(l[i][1]["numLanes"])
)

)
15 changes: 15 additions & 0 deletions docs/speed_camera.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import trafficinterventions

# Initialiasing the object
sc = trafficinterventions.SpeedCamera.SpeedCamera(
maxTimeSteps= 1000, # Number of simulation steps
nearestNeighbourDisallow= 250.0, # Specifies how far detection points should be away from each other
gridArray=[-10000,10000,10000,-10000], # Grid of interest : [left, right, up, down]
pathCFG="map.sumocfg", # Input file path
outPath="Outputs/", # Output file path (for screenshots)
summaryFilePath="summary.txt", # File which contains the appropriate positions - populated after the simulation
numLocs=5 # Number of locations you wish to retrieve
)

# Run the simulation and get outputs
sc.runSimulation()

0 comments on commit e998efc

Please sign in to comment.