next up previous contents
Next: Visualization via gnuplot Up: Visualizer Previous: Introduction   Contents

Vehicle output

The file format for vehicle output is as follows:

0.99snap

The most important fields for our purposes here are time and the two spatial coordinates. When these fields are filled out correctly, the Transims visualizer will work even when all other fields are filled with dummy variables.

Some linear algebra is necessary to calculate the position and the orientation of the vehicles. It goes as follows:

The vector from the fromNode $s$ to the toNode $t$ is

\begin{displaymath}
\vec r_{st}
= \left[\begin{array}{c} x_{st} \\ y_{st} \\ \e...
...
- \left[\begin{array}{c} x_{s} \\ y_{s} \\ \end{array}\right]
\end{displaymath}

When $\theta$ is the angle between the x axis and $\vec r$, then one has

\begin{displaymath}
\tan \theta = \frac{y}{x}
\hbox{\ \ or \ \ }
\theta = \case...
... $y > 0$\ \cr
\frac{3}{2} \pi & if $x = 0$\ and $y < 0$\ \cr
}
\end{displaymath}

A vehicle's distance on the link from the fromNode is given by the position of it's cell; if the cell number is $i$, then the position is $(i+1) \, \ell$, where $\ell$ is the length of a cell (typically 7.5 meters).

The coordinates of the vehicle now essentially are

\begin{displaymath}
\left[\begin{array}{c}x\\ y\\ \end{array}\right]
= \left[\be...
...}{c}d \, \cos \theta \\ d \, \sin \theta
\\ \end{array}\right]
\end{displaymath}

After this calculation, vehicles are on the direct line between two nodes. What is missing is the offset depending on the lane the vehicle is in. This is just

\begin{displaymath}
\left[\begin{array}{c}+ w \, \sin \theta \\ - w \, \cos \theta \\
\end{array}\right] \ ,
\end{displaymath}

which is added to Eq. (8.3). $w$ is the width of a lane, for example 3.75 meters. Large values of $w$ are often useful to ``pull'' road directions apart, which is useful when zooming out.

Corresponding code is

/home/nagel/src/book/sim/book/Link::writeVehFile

For Transims, the header line is significant. For other systems, it may be omitted.

Note the two empty lines between time steps. The empty lines are important for the gnuplot visualization explained below; they are not important for the Transims visualizer and probably not for many other visualizers.

The above is called via


{}
void simulate (...) {
    ...
    for (Links::iterator ll = links.begin(); ll != links.end(); ll++ ) {
        Link* link = ll->second;
        link->writeVehFile(simTime) ;
    }
    ...
}


next up previous contents
Next: Visualization via gnuplot Up: Visualizer Previous: Introduction   Contents
2004-02-02