CHAPTER 4. CODING PROCESS
stop function is needed, which can be used for avoiding accidents (red light, car
in front is not moving).
19
All road users have a maximum speed, a current speed and an acceleration. The
setter of the current speed is added, also the methods for acceleration and decel-
eration of road users.
The roads need a maximum speed. This is implemented in class Road. The ac-
cessors are getSpeedMaxAllowed and setSpeedMaxAllowed.
In the editor it is needed to specify the maximum allowed speed of the roads
which are drawn. To add this functionality, (gld.config) EditRoadPanel has to be
changed. The data which is collected in the editor is saved in an infra-file, which
has a XML-layout.
The EditRoadPanel was to small, so the panel needed to be enlarged in ConfigDi-
alog. The maximum allowed speed is written in Road and has to be stored. This
is done in the functions load and saveSelf. When a edit-road-panel is requested,
the value of the maximum allowed speed needs to be initialized. This is done in
the method EditRoadPanel.setRoad.
In the Simulator we should be able to check what the maximum speed is of the
road. This is implemented in (gld.config) SimRoadPanel.
For testing, a map with 3 roads with different maximum allowed speeds is cre-
ated and used in the simulator. All road users were changing their speed to the
allowed speed on the road where they were driving on.
For letting the road users respect the stop-distance and the maximum allowed
speed, the maximum allowed speed on the road, the distance to the previous road-
user and his speed need to be checked. This has to be done every time a road
user moves. The stop-distance needs to be calculated depending on the speed of
the roaduser. stopdistance= velocity2—+ reaction. [stoa, stob] In a simulator the
2 2*sτopforce
reaction is zero.
Moving the road users is done in (gld.sim) SimModel in the methods moveLane
and moveRoaduserOnLane.