3

I'm looking to do some traffic simulation as a side project but I'm having trouble coming up with ideas for how I should represent the road itself. I like the idea of using a series of waypoints (straight lines using lat/long coords) but it seems difficult to represent different lanes of traffic using this method. I've also been looking at some of the other traffic-simulation questions and one of them mentions using a bitmap but I'm having trouble deciding how this would allow me to easily assign real world lengths to road segments and lane widths, etc. Does anyone have any helpful hints or other ideas that would allow a car to exist at a specific point on a road and be able to switch lanes, etc?

Joe Phillips
  • 49,743
  • 32
  • 103
  • 159
  • 2
    if you are interested in very realistic modeling, you might want to mine a database like open street map: http://www.openstreetmap.org/ – Paul W May 28 '11 at 00:56
  • I can confirm that one. We did some projects with openstreetmap in the past and it works quite nice. You may have to simplify the data from openstreetmap tho as they are very detailed and you may not need too complex connections between two nodes on a map (a minor change in direction of a lane might not be of any relevance to you). – marsbear May 28 '11 at 14:52

3 Answers3

2

I would start with a grid of connected nodes. A node would represent a change in the road condition like a crossing, a beginning or ending lane, a widening of the road itself etc. Either you do complex connections that store all information (lanes in both directions? how many lanes per direction? lane properties etc) or you save one connection for each lane. To be sure that 2 connections on different sides of a node are related to the same lane, you can use lane-ids on a per node base.

This way you have a graph you can run calculations on and you have all data to visualize the whole net.

marsbear
  • 1,459
  • 10
  • 23
  • I like the idea of using lane ids on a per-node basis. I'll have to think about that one. My main concern with this method is determining where a car is. What if it's half way between two nodes or in two nodes? – Joe Phillips May 28 '11 at 01:26
  • If you use the one-connection-per-lane way then you can say the vehicle x is on connection y at position z. If you decorate your nodes with position values then each connection has an implicit start- and end-point aswell as a length. An absolute position of a vehicle is the given as mentioned above: connection (lane) + position on lane (maybe in meters) – marsbear May 28 '11 at 14:50
  • I think I'm leaning this way. Just trying to work out the details – Joe Phillips May 28 '11 at 15:20
1

It really depends on what you want to do with your model, so it's hard to come up with "the correct" answer here.

If you want to model congestions, you might not need a network at all. You can simulate that on a circular road.

Any do you really need the concept of lanes? If you do, you could just model them as separate lines between nodes, or maybe it's sufficient to just store the number of lanes per road.

Anyway, what I'm getting at is that you should first think a bit deeper about what you want to achieve before you start thinking about the exact data model.

Wouter van Nifterick
  • 23,603
  • 7
  • 78
  • 122
  • I want to model a real freeway system. In order to do that I think you need to take just about everything into account including lanes. – Joe Phillips May 28 '11 at 01:16
  • If you want to build a model for simulation, it's usually not so wise to do this from the bottom-up. It looks like that's what you're doing here. The reality is usually that you'll end up spending too much time to implement details that don't matter for whatever you're trying to research. If you want to research what the results for traffic flows are when drivers change of lane, you need to introduce lanes. – Wouter van Nifterick May 28 '11 at 01:31
  • In general, I think it's wiser to start out with a model that's as simple as possible. Run simulations with that, and use the results to decide where you need to add detail. – Wouter van Nifterick May 28 '11 at 01:33
  • It's not realistic nor wise to try to start out with a general "world simulator", where you model the cars itself, gravity, driver intelligence, the roads with all their details, traffic lights, traffic rules, and then expect certain (yet undefined) results to show up automatically because the simulation is so realistic. So my view on this is: "no, you don't have to take just about everything into account". I'm not talking about the road model, but about the general approach to modeling a simulator. – Wouter van Nifterick May 28 '11 at 01:46
  • I'm not trying to ruin your fun. To the contrary.. It'll be way more satisfying if you achieve goals that you've set out than if you've just wasted time aimlessly playing around. – Wouter van Nifterick May 28 '11 at 09:42
1

In a previous job, I was the lead developer on a driving simulator, in particular road network modelling. I built what I called the Logical Road Network which was an abstract description of the road network that is used for tracking vehicles along the road.

A lane was simply a path that followed the road but was offset by a positive or negative distance from the central path. Each road was either a straight or curved section and was essentially a path of central vertices with one or more offset lanes either side. The autonomous cars could then follow a lane path.

In short, the polygons that made up the road were built around the central path along the road, e.g.

*------*------*
|\     |\     |
| \    | \    |
|  \   |  \   |
|   \  |   \  |
|    \ |    \ |
|     \|     \|
*------*------*

where * is a vertex, creating 4 polygons for this simple straight road segment.

Interpolation between 2 vertices along a path provided a simple way to move a vehicle in a given direction. On top of this simple path, we then introduced some fuzziness for the autonomous vehicles so that small deviations in the path emerged (creating more realistic traffic). Logically, vehicles were added to and removed from a road segment and vehicles could inspect the segment to see other vehicles in front, behind or on a different lane. This allowed some degree of AI within each vehicle, so that they could slow down behind another vehicle or wait for oncoming traffic to pass before making a turn.

Not sure if this is exactly what you are after, but I hope it helps nonetheless :-)

andyb
  • 43,435
  • 12
  • 121
  • 150