Prototype Traffic Simulator

Hey folks,

I’m doing a PhD in Electrical and Computer Engineering and my research focus is on Agent Based Models. I’m usually applying the principles of ABM to pandemic disease outbreaks but to get the old funding train rolling I need to branch out every now and then.

I put a quick prototype together using Unity along with CityEngine and OpenStreetMap. The video (bottom of post) is of afternoon/evening traffic. Sorry, there’s no audio yet, that’s being put in tomorrow.

Basic explanation:

We have sanitized cell data we received from MTS (my province’s formerly government owned phone company) that gives us a device id (it’s been cleaned so we can’t find out who owned the phone) and what cell tower and sector that device is using every fifteen minutes or so (unless the device was turned off). We’ve been using the term trajectory for the cell data (one device and all it’s locations/timestamps = one trajectory). Using this data I created agents that chase a target around the city, the target’s location is determined by the cell data.

The agents themselves are pretty dumb in the way they chase the target around, when they come to an intersection they decide which node in the street graph will get them closest to the target and go that way. Because it’s a greedy decision agents can get stuck in local minima from time to time. This is going to be remedied by implementing a pathfinding component for the agents so they no longer get stuck.

There are eight trajectories running in the video with around 256 agents each. There’s also a group of another 256 agents that randomly walks the graph without a target as background noise.

Part of the reason I chose to do this in Unity is that I wanted to show my supervisor/labmates that using a game engine could drastically cut down on our development time of new models. Unsurprisingly my strategy worked :slight_smile:

As for future work for this thing (needs a lot of love), I’ll be sticking in actual pathfinding code and updating the street graph so that it contains proper directionality as well as speedlimits and capacity (number of lanes).

When I’m satisfied with the traffic aspects of the model I’ll be integratingSIR models so I can keep using the sim for my main line of research.

Anyway, just thought I’d show you guys what I’ve been up to the last week or so (most of that time was fighting with CityEngine and OpenStreetMap). If anyone is interested I can give a bit more detail about the pipeline from OpenStreetMap to Unity, pretty simple but time consuming.

I’m a bit over caffeinated right now so if anything didn’t make sense just let me know and I’ll clarify.

Thanks for reading!

P.S. You may notice there’s no road mesh. That’s because somewhere in the map there’s something causing CityEngine to throw an error on model export. I’m pretty sure I know what’s causing it but I have to inspect the model in CE and I didn’t have time, so if you see vehicles driving across the rivers on nothing that’s why.

WOw, this would be so useful for me. I’m watching closely :wink:

I am intrigued.

pretty neat. i have also been looking at city engine. I’m keen to see what you can come up with in the future…

Hey,

Very impressive work in such a short time. I´m very interested in your experience with the CE to Unity pipeline. I recently worked on that pipeline and had a lot of issues because of CEs way of merging the meshes and Unitiy´s triangle count limit per mesh. Additionally I had to run a script in unity to apply an offset on vertex positions to deal with floating point inaccuracy. How did you solve these issues and how do you streamline exporting smaller areas one by one?

xad

Hey hey,

Sorry for the delay but I’ve been busy with conferences this month. First off thank you, it’s a pretty simple system but it looks cool :slight_smile:

I have a love/hate relationship with CE. It spits out god awful vertex counts (partly due to me using only slightly modified stock cga scripts but even so, cga isn’t generally great for v-counts).

To get around floating point errors in Unity I had to shrink the model down to either 25% or 12.5% (can’t remember off hand, I think it was 12.5) and even then it’s rather large. At the time I built it I used the stock exporter but limited the file size so that I could have “manageable” meshes. It didn’t turn out spectacularly (missing roads and curbs etc). The mesh merging is also horrible by default.

I don’t want to harp on CE too badly though because it is a really good tool, it just does a few things in a not so hot fashion.

I’m working on an exporter that splits up the city using a grid so that you can get some locality. In the meshes used in the video there are fields in the south end of the city that are part of the same mesh as a field in the north end so I feel your pain.

When I have a sane exporter I’ll likely post it somewhere around here.

Cheers

Sounds like an awesome job/PhD to do! Get to mess around with some neat software all day!

Haha definitely!

I’m about to dive into two months of disease modelling in MATLAB though. :confused:

I need to make the simulator not so off the shelf software dependent so I might have to replicate some of CE’s functionality then hook it into Unity. We’ll see, should be fun :slight_smile:

where can i free download this