simulate_gipps: Simulate Gipps Model

Description Usage Arguments Value Examples

View source: R/simulate_gipps.R

Description

This function takes in the lead vehicle trajectory and calculates speed, spacing and acceleration of the following vehicle using the Gipps Model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
simulate_gipps(
  resolution,
  N,
  dfn1,
  xn1,
  vn1,
  xn_first,
  vn_first,
  ln,
  an,
  Vn,
  tau,
  bn_const,
  bcap
)

Arguments

resolution

Duration of a time frame. Typical values are 0.1, 0.5, 1.0 s. Double. Must match with the resolution of the observed lead vehicle data dfn1 defined below

N

Number of Following Vehicles in the same lane (platoon). Integer.

dfn1

Unquoted name of the dataframe that contains lead vehicle data.

xn1

Name of the column in dfn1 that contains lead vehicle position. Character.

vn1

Name of the column in dfn1 that contains lead vehicle speed. Character.

xn_first

First value of vehicle position of each of the following vehicles. A list of doubles with size equal to N.

vn_first

First value of vehicle speed of each of the following vehicles. A list of doubles with size equal to N.

ln

Length of each of the lead vehicles. A list of doubles with size equal to N. Note that it is called as sn in Gipps Model

an

Maximum acceleration which the driver wishes to undertake m/s2. Double.

Vn

Desired speed/speed at which driver wishes to travel m/s. Double.

tau

Reaction Time s. Double.

bn_const

Most severe braking that the driver wishes to undertake m/s2. Double and Negative.

bcap

An estimate of lead vehicle deceleration m/s2. Double and Negative.

Value

A dataframe with lead and following vehicle(s) trajectories

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Time
last_time <- 3000 ## s
time_frame <- 0.1 ## s
Time <- seq(from = 0, to = last_time, by = time_frame)
time_length <- length(Time)



## Lead vehicle
vn1_first <- 13.9 ## first speed m/s
xn1_first <- 100 ## position of lead vehicle front center m
bn1_complete <- c(rep(0, 29500),
                 rep(-5, time_length - 29500))



#############################################
### Complete speed trajectory of Lead vehicle
#############################################

vn1_complete <- rep(NA_real_, time_length) ### an empty vector
xn1_complete <- rep(NA_real_, time_length) ### an empty vector

vn1_complete[1] <- vn1_first
xn1_complete[1] <- xn1_first

for (t in 2:time_length) {

 ### Lead vehicle calculations
 vn1_complete[t] <- vn1_complete[t-1] + (bn1_complete[t-1] * time_frame)

 vn1_complete[t] <- ifelse(vn1_complete[t] < 0, 0, vn1_complete[t])


xn1_complete[t] <- ifelse(
 vn1_complete[t] > 0,
 xn1_complete[t-1] + (vn1_complete[t-1] * time_frame) +
   (0.5 * bn1_complete[t-1] * (time_frame)^2),
 xn1_complete[t-1]
)

}



ldf <- data.frame(Time, bn1_complete, xn1_complete, vn1_complete)

## Run the Gipps function:
simulate_gipps(

############## Simulation Parameters #######################
resolution=0.1,
N=5,


############### Lead Vehicle Data #########################
dfn1=ldf,
xn1="xn1_complete",
vn1="vn1_complete",


############### Following Vehicle Data ####################
xn_first=list(85, 70, 55, 40, 25),
vn_first=list(12, 12, 12, 12, 12),
ln=list(6.5, 6.5, 6.5, 6.5, 6.5),


############### Model Parameters ##########################
an=2,
Vn=14.4,
tau=0.1,
bn_const=-1.5,
bcap=-2
)

durraniu/CarFollowingModels documentation built on Dec. 20, 2021, 2:15 a.m.