1 - Go to the main SmartAHS directory (the one where you unpacked).
2 - Run the command 'configure' (if '.' - dot - is not in your path,
run ' ./configure');
this will check a few things and
set up the environment for your work.
Normally, 'configure' will set up '/usr/local'
as the installation directory.
You can override this behavior by using
the '--prefix' command line switch to 'configure',
as in
$ configure --prefix=$HOME/my-smartahs-dir
3 - Run 'make install'.
The SmartAHS framework is now installed.
The core set of the SmartAHS building blocks is contained within the following directory structure
Let us create a highway specification as follows:
HIGHWAY SEC1
LANE 1
GEOMETRY LINE 300
HIGHWAY SEC2
LANE 1
GEOMETRY ARC 100 500 L
GEOMETRY ARC 100 500 R
HIGHWAY SEC3
LANE 1
GEOMETRY LINE 100
PIN SEC1 0 0 0 0
CONNECT SEC1 (1 1) SEC2 (1 1)
CONNECT SEC2 (1 1) SEC3 (1 1)
global Source source1 := create(Source,
gxp := 0,
gyp := 2,
gzp := 0,
section := sec1, // original
section name
segment := _sec1_sg1, // derived segment name
lane := _sec1_l1, // derived lane
name
rxp := 0,
ryp := 2,
rzp := 0,
lyp := 0,
vgam11 := 1,
vgam12 := 0,
vgam13 := 0,
vgam21 := 0,
vgam22 := 1,
vgam23 := 0,
vgam31 := 0,
vgam32 := 0,
vgam33 := 1,
sink := sink1,
vehiclesToCreate := 10,
duration := 0,
period := 1);
The file od.hs should be included into your main file:
You should create a file myvehicle.hs - it will contain the type description for your vehicle:
// specify the vehicle model and controller
output VehicleDynamics vehicle_dynamics;
VehicleDynamics_2D
vd2d;
Controller controller;
HDM_engine_controller
human_tsb_controller;
. . . .
.
// attach
to a particular source / sink
Source source;
Sink
sink;
// link
the vehicle to the road
VREP
vrep;
// vehicle
parameters
continuous number
gxp, gyp, gzp;
continuous number
xDot, yDot, zDot;
continuous number
xDDot, yDDot, zDDot;
continuous number
heading, pitch, roll;
number length,
width;
. . . . . .
Controller tcontroller
:= create (HDM_engine_controller,
vehicle := self);
VREP tvrep := create(VREP,
rzp := rzp(source),
lyp := lyp(source),
vgam11 := vgam11(source),
. . . .
vehicle := self);
Trajectory ttraj := create(Trajectory,
v := self);
}
// assign the above
created instances to the state variables
do
{
vehicle_dynamics :=
tvehicle_dynamics;
controller := tcontroller;
vrep := tvrep;
traj := ttraj;
}
// establish the connections between
modules
connect
{
// link
the position/velocity of the vehicle to the VREP
xDot(tvrep) <- xDot(tvehicle_dynamics);
.
. . .
followLane(tvrep) <-
followLane(tcontroller);
// link
the control lines
throttle(tvehicle_dynamics)
<- throttle(tcontroller);
brake(tvehicle_dynamics)
<- brake(tcontroller)
steering(tvehicle_dynamics)
<- steering(tcontroller);
.
. . .
// additional
connections required by the model
rxp(tcontroller) <-
rxp(tvrep);
lyp(tcontroller) <-
lyp(tvrep);
.
. . .
section(tcontroller)
<- section(tvrep);
lane(tcontroller) <-
lane(tvrep);
segment(tcontroller)
<- segment(tvrep);
. . . .
desired_speed(tcontroller)
<- desired_speed;
range(tcontroller) <-
range;
range_rate(tcontroller)
<- range_rate;
. . . .
input
/** Starting section */
Section section;
/** Cell number */
number cellN;
/** Sampling time */
timer sample_timer;
state
set(Vehicle) cell;
/** Vehicles which passed the flow check point
*/
set(Vehicle) passedVehicles := {};
/** Vehicles which passed the flow check point
in the last timer
* click and wich didn't leave the
cell yet
*/
set(Vehicle) oldPassedVehicles := {};
continuous number period := 0;
number vehCount := 0;
output
/** The flow is calculated at the entrance of
the cell */
number vehFlow;
setup
do {
cell := cells(section)[cellN];
};
flow
default {
period' = 1;
};
discrete
s;
transition
/** This happens when a new vehicle enters the
cell */
s -> s {} when exists v in cell :
not (v in passedVehicles) and (not
(v in oldPassedVehicles))
do {
passedVehicles +:= v;
vehCount +:= 1;
},
/** This calculates the flow */
s -> s {sample_timer:timer_tick}
do {
vehFlow := if vehCount > 0
then
period /
vehCount
else
0;
oldPassedVehicles := {v : v in passedVehicles,
v in cell};
passedVehicles := {};
period := 0;
vehCount := 0;
};
}