How to use Traffic Lights

This howto explains how to build a simple junction with traffic lights. Using this howto and the examples of more complicated junctions you should probably be able to make your own junctions. If you need help with the user interface or termonology, please refer to the usage help.


Placing the source and sink nodes

In this howto we will make a junction with two incoming flows that merge to one exit. I have started by placing two source nodes and one sink node using the node tool. The default destination name is just the node number which in bigger networks will be hard to remember. In this example I rename the destination to exit.

  1. Select node tool if it is not already selected
  2. Select action: create source node
  3. Click to place first source node
  4. Select action: create source node
  5. Click to place second source node
  6. Select action: create sink node
  7. Click to place sink node
  8. To open the property windows of each node: select the node by clicking on it and then use the Properties... action (with an icon that looks like a window)
  9. In the property window of the sink node, click on the rename button
  10. Change the destination name to exit and click OK
step 1

For each source node you set the flow separately for each destination. In this example we only have one destination. I have chosen 800 vehicles per hour for each of the source nodes.

step 2

Building the network

Now that the flows and destinations have been set up, the next step is to build the network. (You do not necessarily need to follow this order)

First I construct a link from one of the sink nodes to where I want to have my junction.

  1. Close all node windows
  2. Switch to link tool
  3. Select action: new link
  4. Click on the lower source node
  5. Click on the place where we want our junction
  6. Hit escape to finish new link
step 3

After that I continue to construct two more links: one from the other source node to the junction location and another to the sink node. The junction node is automatically placed when the second link is placed.

  1. Deselect the first link if it is still selected (hit escape again or click outside of the link)
  2. Select action: new link
  3. Click on the upper source node
  4. Click near the location where the first link ends (within the grid tile). This completes the second link and creates a junction node
  5. Deselect link
  6. Select action: new link
  7. Click on the junction node
  8. Click on the sink node. Also in this case the link is completed automatically

Configuring the junction node

Next, using the node tool, double click on the junction node to bring up the node window.

  1. Switch to node tool
  2. Select the junction node
  3. Select action: properties ... (or double click on the junction node)
step 4

Pick Traffic Lights from the control type list to enable traffic lights on this junction node. Some more controls appear as you can see on the next screenshot.

I have entered one tag for each of our two incoming links: and entry.bottom. The dot in the name has no special meaning but can be used to organize your names as you see fit.

The numbers to the left of the tag edit boxes corresponds to the numbers in the figure at the top left of the junction node window. These numbers are calculated on the fly based on the angle of the incoming and outgoing links so they change if you rearrange your junctions.

An entry or exit that you do not assign a tag will always be green. Since there is only one exit and no need to give partial green to only some exits in this junction, I have not given a tag to the exit. In the 3-way_junction.xml example file you can see how output tags can be used.

step 5

Traffic schedule

The next step in this tutorial is to define a traffic schedule. To do so I have opened up the Traffic Lights Schedule window. (found in the Signal Control menu)

I have created four periods. The first one gives green to all inputs on any junction node that is tagged The second period is a three second long all-red period to clear the shared area and to account for red-light drivers. The third and fourth periods are similar to the first and second, just that the other input is given green.

step 6

Testing - Simulation

Now the junction has been constructed and a traffic light schedule has been created. To test the junction, start simulation (Simulation -> Start). Then wait some time and watch the first vehicle arrive.

step 7 - simulation

Junctioneer have some additional display options that can be useful both in build mode and in simulations:

step 8 - 3d


You have now created a fully working example. It has nodes, links, vehicles that arrive and a traffic controlled junction so that cars don't collide.

The final result is located in the junction_howto.xml file in the examples folder. You may also take a look on the other examples and examine how they are constructed.

Suggested expansions

To expand, you could try to add a third input arm with a sink that generates traffic. Another expansion that you could try is to add a new exit arm from the junction node with a new sink node. Click on the existing source nodes and assign some new traffic flows to the new destination.