Kaitlyn’s Status Report for 3/30/24

Work Done

This week I completed the SUMO/TraCI simulation.

I modified the simulation to include calibrators, a SUMO feature that allows the simulation to spawn cars to sync with the speed and vehicles per hour you desire. I initially attempted to manually spawn cars but faced issues with the routing of cars, which I will explain in more detail later. However, I did additional research and discovered this feature in SUMO and realized that it is better suited to modeling the API data, so I proceeded to implement it in our simulation.

Here is a link to the calibrators working: LINK

Additionally, I implemented functions to spawn cars on each side of the intersection. As mentioned before, I had trouble inserting cars into the simulation individually because the software kept throwing an error that the routes I defined were invalid. I tried a lot of different modifications to try to fix the routing and eventually I was able to get them to work. I’m not completely sure what the problems were since I tried so many different things at once, but I think the problems were:

  1. The routes had to directly be added to the additional.xml file if I wanted to use them in that file, since the additional file gets loaded before the actual network for some reason (this honestly seems like bad design to me, but there’s probably some reasoning for this).
  2. The routes have to end outside of the simulation. I previously had routes that just ended on random roads, expecting the software to take care of what happened to the car after it reached the end of the route and either route it for me or just delete the car, but this does not seem to be the case.
    1. The documentation made it seem like it could automatically route the cars so it is misleading.
  3. The routes have to have consecutive segments of road.
    1. The documentation also stated that it can automatically route cars for routes that are not connecting, but it did not work.

Here is a link to the video of the spawning working: LINK

In the video, the white cars are the ones spawned manually. It is currently set to spawn only at the west side of the intersection at a constant rate, however I have the functions for each side implemented. Each side was defined to spawn at approximately before the lane area detector starts, which took some testing to get accurate.

Finally, I created functions for setting the traffic light durations dynamically and preventing an infinite loop by ensuring traffic light states take in the time elapsed of the light’s current state.

For reference, the following is what the xml for the traffic light logic looks like without the dynamic code:

<tlLogic id="GS_105097632" type="static" programID="0" offset="0">

        <phase duration="25" state="GGGggrrrrGGGggrrrr" minDur="4" maxDur="50"/>

        <phase duration="4"  state="yyyyyrrrryyyyyrrrr"/>

        <phase duration="25" state="rrrrrGGggrrrrrGGgg" minDur="4" maxDur="50"/>

        <phase duration="4"  state="rrrrryyyyrrrrryyyy"/>

 </tlLogic>

The setup for this took longer than the actual code because I had to modify our simulation to figure out which of the indices in the “state” definition correspond to which lane of the intersection.

This image shows the modified simulation, which displays each lanes indices in “state” as well as the current phase index of the light in the center.

I also ran into an issue where it seemed like the light was never changing state, but I realized the issue was that I had a light duration of 20 seconds for one phase and kept resetting the state to the beginning of that phase every time I modify the light, but then the light gets modified every 20 seconds, so it would permanently get stuck in that phase, so I designed the code to only set the duration to be the remaining time for the first iteration, preventing the infinite loop.

I did not get a chance to start the actual ML model, however I already have the pseudocode for it and have looked into some tutorials on Q-learning in Pytorch.

Schedule

  • I am still a bit behind schedule, since the basic ML model is still not done yet, however I plan on working on it tomorrow through Tuesday, so I am only a couple days behind. I modified the schedule to display this.

Tasks This Week

  • Finish basic ML model structure
  • Get the SUMO simulation on the Raspberry Pi with Ankita

 



Leave a Reply

Your email address will not be published. Required fields are marked *