#include <IDM.h>
Public Member Functions | |
IDM () | |
virtual | ~IDM () |
double | update (double vel, double dist) |
Updates the IDM's acceleration. | |
double | get_T () |
double | get_A () |
double | get_B () |
double | get_S0 () |
double | get_S1 () |
double | get_V0 () |
double | get_Delta () |
double | get_Polite () |
double | get_Bias () |
double | get_DeltaAth () |
void | set_T (double val) |
void | set_A (double val) |
void | set_B (double val) |
void | set_S0 (double val) |
void | set_S1 (double val) |
void | set_V0 (double val) |
void | set_Delta (double val) |
void | set_Polite (double val) |
void | set_Bias (double val) |
void | set_DeltaAth (double val) |
virtual void | ClearRestriction () |
Clears all restrictions on the IDM. | |
virtual void | ClearGradient () |
Clears all gradient restrictions on the IDM. | |
virtual void | SetGradient (double gradient) |
virtual void | ClearSpeedLimit () |
Clears all speedlimit restrictions on the IDM. | |
virtual void | SetSpeedLimit (double newV0) |
Sets the properties for an IDM entering a speedlimit. | |
virtual double | getDesiredVel () |
Gets the desired velocity of the IDM. | |
virtual void | setVel (double vel) |
Sets the velocity of the IDM. | |
double | LaneChange (double GapToFront, double GapToBack, double FrontChangeAccel, double CurrentBackAccel, double ProposedBackAccel, bool overtake) |
Finds the advantage that a vehicle would gain from changing lane. | |
Private Member Functions | |
double | s_star (double vel) |
double | dvdt (double m_speed, double s) |
Private Attributes | |
double | m_T |
Safe time headway. | |
double | m_A |
Maximum acceleration. | |
double | m_B |
Desired deceleration. | |
double | m_S0 |
double | m_S1 |
double | m_V0 |
double | m_Delta |
double | m_Polite |
MOBIL: Consideration towards other drivers. | |
double | m_Bias |
MOBIL: Desire to keep to slow lane. | |
double | m_DeltaAth |
MOBIL: Dampens overtaking occurances. | |
double | m_V0_BeforeSpeedLimit |
double | m_T_BeforeGradient |
double | m_A_BeforeGradient |
double | m_B_BeforeGradient |
double | m_V0_BeforeGradient |
double | m_V0_Initial |
double | m_speed |
double | LANECHANGE_MIN_GAP |
double | SAFE_BRAKING |
bool | A_FLAG |
double | A_MIN |
bool | B_FLAG |
double | T_SLOPE |
double | V0_MIN |
double | V0_SLOPE |
Definition at line 9 of file IDM.h.
IDM::IDM | ( | ) |
Definition at line 8 of file IDM.cpp.
References CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Param_Modifiers::A_FLAG, A_FLAG, CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Param_Modifiers::A_MIN, A_MIN, CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Param_Modifiers::B_FLAG, B_FLAG, CConfigData::Road_Config::RoadFeatures_Config::Gradient, CConfigData::IDM, CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Modifiers, CConfigData::IDM_Config::LANECHANGE_MIN_GAP, LANECHANGE_MIN_GAP, m_A, m_A_BeforeGradient, m_B, m_B_BeforeGradient, m_Bias, m_Delta, m_DeltaAth, m_Polite, m_S0, m_S1, m_T, m_T_BeforeGradient, m_V0, m_V0_BeforeGradient, m_V0_BeforeSpeedLimit, m_V0_Initial, CConfigData::Road, CConfigData::Road_Config::RoadFeatures, CConfigData::IDM_Config::SAFE_BRAKING, SAFE_BRAKING, CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Param_Modifiers::T_SLOPE, T_SLOPE, CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Param_Modifiers::V0_MIN, V0_MIN, CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Param_Modifiers::V0_SLOPE, and V0_SLOPE.
00009 { 00010 LANECHANGE_MIN_GAP = g_ConfigData.IDM.LANECHANGE_MIN_GAP; 00011 SAFE_BRAKING = g_ConfigData.IDM.SAFE_BRAKING; 00012 00013 A_FLAG = g_ConfigData.Road.RoadFeatures.Gradient.IDM_Modifiers.A_FLAG; 00014 A_MIN = g_ConfigData.Road.RoadFeatures.Gradient.IDM_Modifiers.A_MIN; 00015 B_FLAG = g_ConfigData.Road.RoadFeatures.Gradient.IDM_Modifiers.B_FLAG; 00016 T_SLOPE = g_ConfigData.Road.RoadFeatures.Gradient.IDM_Modifiers.T_SLOPE; 00017 V0_MIN = g_ConfigData.Road.RoadFeatures.Gradient.IDM_Modifiers.V0_MIN; 00018 V0_SLOPE = g_ConfigData.Road.RoadFeatures.Gradient.IDM_Modifiers.V0_SLOPE; 00019 00020 m_T = 0.0; 00021 m_A = 0.0; 00022 m_B = 0.0; 00023 m_S0 = 0.0; 00024 m_S1 = 0.0; 00025 m_V0 = 0.0; 00026 m_Delta = 0.0; 00027 m_Polite = 0.0; 00028 m_Bias = 0.0; 00029 m_DeltaAth = 0.0; 00030 00031 m_V0_BeforeSpeedLimit = 0.0; 00032 m_V0_BeforeGradient = 0.0; 00033 m_T_BeforeGradient = 0.0; 00034 m_A_BeforeGradient = 0.0; 00035 m_B_BeforeGradient = 0.0; 00036 00037 m_V0_Initial = 0.0; 00038 }
double IDM::update | ( | double | vel, | |
double | dist | |||
) | [virtual] |
Updates the IDM's acceleration.
vel | The vehicle's velocity | |
dist | The distance to the next vehicle |
Implements DriverModel.
Definition at line 56 of file IDM.cpp.
References dvdt().
00057 { 00058 double accel = dvdt(vel, dist); 00059 return accel; 00060 }
double IDM::get_T | ( | ) |
Definition at line 169 of file IDM.cpp.
References m_T.
Referenced by Vehicle::getDataString().
00170 { 00171 // Unit - input: secs 00172 // - output: secs 00173 return m_T; 00174 }
double IDM::get_A | ( | ) |
Definition at line 186 of file IDM.cpp.
References m_A.
Referenced by Vehicle::getDataString().
00187 { 00188 // Unit - input: m/s^2 00189 // - output: m/s^2 00190 return m_A; 00191 }
double IDM::get_B | ( | ) |
Definition at line 203 of file IDM.cpp.
References m_B.
Referenced by Vehicle::getDataString().
00204 { 00205 // Unit - input: m/s^2 00206 // - output: m/s^2 00207 return m_B; 00208 }
double IDM::get_S0 | ( | ) |
Definition at line 219 of file IDM.cpp.
References m_S0.
Referenced by Vehicle::getDataString().
00220 { 00221 // Unit - input: m 00222 // - output: m 00223 return m_S0; 00224 }
double IDM::get_S1 | ( | ) |
Definition at line 235 of file IDM.cpp.
References m_S1.
Referenced by Vehicle::getDataString().
00236 { 00237 // Unit - input: m 00238 // - output: m 00239 return m_S1; 00240 }
double IDM::get_V0 | ( | ) |
Definition at line 253 of file IDM.cpp.
References m_V0.
Referenced by Vehicle::getDataString().
00254 { 00255 // Unit - input: m/s 00256 // - output: m/s //km/h 00257 return m_V0;// * M_PER_S_TO_KM_PER_H; 00258 }
double IDM::get_Delta | ( | ) |
Definition at line 269 of file IDM.cpp.
References m_Delta.
Referenced by Vehicle::getDataString().
00270 { 00271 // Unit - input: none 00272 // - output: none 00273 return m_Delta; 00274 }
double IDM::get_Polite | ( | ) |
Definition at line 285 of file IDM.cpp.
References m_Polite.
Referenced by Vehicle::getDataString().
00286 { 00287 // Unit - input: none 00288 // - output: none 00289 return m_Polite; 00290 }
double IDM::get_Bias | ( | ) |
Definition at line 301 of file IDM.cpp.
References m_Bias.
Referenced by Vehicle::getDataString().
00302 { 00303 // Unit - input: none 00304 // - output: none 00305 return m_Bias; 00306 }
double IDM::get_DeltaAth | ( | ) |
Definition at line 317 of file IDM.cpp.
References m_DeltaAth.
Referenced by Vehicle::getDataString().
00318 { 00319 // Unit - input: none 00320 // - output: none 00321 return m_DeltaAth; 00322 }
void IDM::set_T | ( | double | val | ) |
Definition at line 162 of file IDM.cpp.
References m_T.
Referenced by CIDMParameterSet::Generate().
00163 { 00164 // Unit - input: secs 00165 // - output: secs 00166 m_T = val; 00167 }
void IDM::set_A | ( | double | val | ) |
void IDM::set_B | ( | double | val | ) |
void IDM::set_S0 | ( | double | val | ) |
Definition at line 212 of file IDM.cpp.
References m_S0.
Referenced by CIDMParameterSet::Generate().
00213 { 00214 // Unit - input: m 00215 // - output: m 00216 m_S0 = val; 00217 }
void IDM::set_S1 | ( | double | val | ) |
Definition at line 228 of file IDM.cpp.
References m_S1.
Referenced by CIDMParameterSet::Generate().
00229 { 00230 // Unit - input: m 00231 // - output: m 00232 m_S1 = val; 00233 }
void IDM::set_V0 | ( | double | val | ) |
Definition at line 244 of file IDM.cpp.
References KM_PER_H_TO_M_PER_S, m_V0, and m_V0_Initial.
Referenced by CIDMParameterSet::Generate().
00245 { 00246 // Unit - input: km/h 00247 // - output: m/s 00248 m_V0 = val * KM_PER_H_TO_M_PER_S; 00249 m_V0_Initial = m_V0; 00250 ASSERT(m_V0 > 0); 00251 }
void IDM::set_Delta | ( | double | val | ) |
Definition at line 262 of file IDM.cpp.
References m_Delta.
Referenced by CIDMParameterSet::Generate().
00263 { 00264 // Unit - input: none 00265 // - output: none 00266 m_Delta = val; 00267 }
void IDM::set_Polite | ( | double | val | ) |
Definition at line 278 of file IDM.cpp.
References m_Polite.
Referenced by CIDMParameterSet::Generate().
00279 { 00280 // Unit - input: none 00281 // - output: none 00282 m_Polite = val; 00283 }
void IDM::set_Bias | ( | double | val | ) |
Definition at line 294 of file IDM.cpp.
References m_Bias.
Referenced by CIDMParameterSet::Generate().
00295 { 00296 // Unit - input: none 00297 // - output: none 00298 m_Bias = val; 00299 }
void IDM::set_DeltaAth | ( | double | val | ) |
Definition at line 310 of file IDM.cpp.
References m_DeltaAth.
Referenced by CIDMParameterSet::Generate().
00311 { 00312 // Unit - input: none 00313 // - output: none 00314 m_DeltaAth = val; 00315 }
void IDM::ClearRestriction | ( | ) | [virtual] |
Clears all restrictions on the IDM.
This function removes all of the speed/gradient restrictions on an IDM, and is only called once the IDM's vehicle has left all previous road segments and has not entered another one. The desired velocity of the IDM is set back to its original desired velocity
Reimplemented from DriverModel.
Definition at line 439 of file IDM.cpp.
References m_V0, and m_V0_Initial.
00440 { 00441 // This is only called if we are entering a clear road and 00442 // have already been removed from all segments. 00443 m_V0 = m_V0_Initial; 00444 }
void IDM::ClearGradient | ( | ) | [virtual] |
Clears all gradient restrictions on the IDM.
This function removes all of the restrictions imposed upon an IDM when the IDM's vehicle enters a gradient road segment. The variables affected are all set back to the value they were previous to the vehicle entering the gradient segment.
Reimplemented from DriverModel.
Definition at line 417 of file IDM.cpp.
References m_A, m_A_BeforeGradient, m_B, m_B_BeforeGradient, DriverModel::m_bInGradient, m_T, m_T_BeforeGradient, m_V0, and m_V0_BeforeGradient.
00418 { 00419 if(!m_bInGradient) 00420 TRACE("***Grad: Removed but not in\n"); 00421 ASSERT(m_V0_BeforeGradient > 0); // if this happens it means vehicle wasn't added to segment but was removed from it 00422 00423 m_bInGradient = false; 00424 m_T = m_T_BeforeGradient; 00425 m_A = m_A_BeforeGradient; 00426 m_B = m_B_BeforeGradient; 00427 m_V0 = m_V0_BeforeGradient; 00428 }
void IDM::SetGradient | ( | double | gradient | ) | [virtual] |
Reimplemented from DriverModel.
Definition at line 348 of file IDM.cpp.
References A_FLAG, A_MIN, B_FLAG, KM_PER_H_TO_M_PER_S, m_A, m_A_BeforeGradient, m_B, m_B_BeforeGradient, DriverModel::m_bInGradient, DriverModel::m_bInSpeedLimit, m_T, m_T_BeforeGradient, m_V0, m_V0_BeforeGradient, m_V0_Initial, T_SLOPE, V0_MIN, and V0_SLOPE.
00349 { 00350 m_bInGradient = true; 00351 m_A_BeforeGradient = m_A; m_T_BeforeGradient = m_T; 00352 m_B_BeforeGradient = m_B; m_V0_BeforeGradient = m_V0; 00353 00354 // increase T - regardless of uphill or downhill 00355 double ABSgradient = gradient < 0 ? -gradient : gradient; 00356 m_T += ABSgradient/T_SLOPE; 00357 00358 // Reduce A - for uphill 00359 // MAGIC NUMBER 10 accounts for component of gravity acceleration 00360 // parallel to road surface - sin of small angle 00361 if(A_FLAG) 00362 { 00363 m_A -= gradient/10; 00364 m_A = m_A < A_MIN ? A_MIN : m_A; // set to min at least 00365 } 00366 00367 // Increase B for uphill only - MAGIC NUMBER 10 as for A 00368 if(B_FLAG && gradient > 0) 00369 m_B += gradient/10; 00370 00371 // Reduce V0 for uphill only 00372 if(gradient > 0) 00373 { 00374 // reduce V0 from the 'free' desired velocity 00375 // so if not in speed limit zone, we're free to reduce to gradient, else 00376 if(!m_bInSpeedLimit) 00377 m_V0 -= (gradient/V0_SLOPE)*KM_PER_H_TO_M_PER_S; 00378 else // we're in a speed limit so see if speed limit or gradient governs V0 00379 { 00380 double FreeV0 = m_V0_Initial; // Do NOT change value of m_V0_BeforeSpeedLimit here! 00381 double SpeedLimitV0 = m_V0; 00382 double GradientV0 = FreeV0 - (gradient/V0_SLOPE)*KM_PER_H_TO_M_PER_S; 00383 m_V0 = SpeedLimitV0 < GradientV0 ? SpeedLimitV0 : GradientV0; 00384 } 00385 if(m_V0 < V0_MIN) 00386 { 00387 //TRACE("*** V0 of: %f\t set to: %f\n",m_V0, V0_MIN); 00388 m_V0 = V0_MIN; // set to min at least 00389 } 00390 } // end if gradient uphill 00391 }
void IDM::ClearSpeedLimit | ( | ) | [virtual] |
Clears all speedlimit restrictions on the IDM.
This function removes the speed restriction imposed upon an IDM when the IDM's vehicle enters a speedlimit road segment. The desired velocity of the vehicle is set back to the value it was previous to the vehicle entering the speedlimit segment
Reimplemented from DriverModel.
Definition at line 400 of file IDM.cpp.
References DriverModel::m_bInSpeedLimit, m_V0, and m_V0_BeforeSpeedLimit.
00401 { 00402 if(!m_bInSpeedLimit) 00403 TRACE("***SL: Removed but not in\n"); 00404 ASSERT(m_V0_BeforeSpeedLimit > 0); // if this happens it means vehicle wasn't added to segment but was removed from it 00405 m_bInSpeedLimit = false; 00406 m_V0 = m_V0_BeforeSpeedLimit; 00407 }
void IDM::SetSpeedLimit | ( | double | newV0 | ) | [virtual] |
Sets the properties for an IDM entering a speedlimit.
newV0 | The new desired velocity of the IDM |
Reimplemented from DriverModel.
Definition at line 335 of file IDM.cpp.
References DriverModel::m_bInSpeedLimit, m_V0, and m_V0_BeforeSpeedLimit.
00336 { 00337 m_bInSpeedLimit = true; 00338 m_V0_BeforeSpeedLimit = m_V0; 00339 00340 m_V0 = newV0; 00341 ASSERT(m_V0 > 0); 00342 ASSERT(m_V0_BeforeSpeedLimit > 0); 00343 }
double IDM::getDesiredVel | ( | ) | [virtual] |
void IDM::setVel | ( | double | vel | ) | [virtual] |
double IDM::LaneChange | ( | double | GapToFront, | |
double | GapToBack, | |||
double | FrontChangeAccel, | |||
double | CurrentBackAccel, | |||
double | ProposedBackAccel, | |||
bool | overtake | |||
) | [virtual] |
Finds the advantage that a vehicle would gain from changing lane.
GapToFront | The gap to the vehicle in front in the new lane | |
GapToBack | The gap to the vehicle behind in the new lane | |
FrontChangeAccel | The change in acceleration the vehicle will experience with a new front vehicle | |
CurrentBackAccel | The current acceleration of the vehicle behind in the new lane | |
ProposedBackAccel | The new acceleration the vehicle behind will experience with a new front vehicle | |
overtake | Whether or not the vehicle is overtaking |
Implements DriverModel.
Definition at line 129 of file IDM.cpp.
References LANECHANGE_MIN_GAP, m_Bias, m_DeltaAth, m_Polite, and SAFE_BRAKING.
00131 { 00132 double advantage = 0.0; 00133 double othersDisadv = 0.0; 00134 double netAdvantage = 0.0; 00135 00136 if(GapToFront >= LANECHANGE_MIN_GAP && GapToBack >= LANECHANGE_MIN_GAP && ProposedBackAccel >= SAFE_BRAKING) 00137 { 00138 advantage = FrontChangeAccel + (overtake ? -1 : 1) * m_Bias; 00139 othersDisadv = CurrentBackAccel - ProposedBackAccel; 00140 } 00141 00142 if(othersDisadv < 0.0) 00143 othersDisadv = 0.0; 00144 00145 netAdvantage = advantage - othersDisadv * m_Polite; 00146 00147 if(netAdvantage <= m_DeltaAth) // if it's under the threshold 00148 netAdvantage = 0.0; 00149 00150 return netAdvantage; 00151 }
double IDM::s_star | ( | double | vel | ) | [private] |
Definition at line 78 of file IDM.cpp.
References m_A, m_B, m_S0, m_S1, m_speed, m_T, and m_V0.
Referenced by dvdt().
00079 { 00080 // Desired gap 00081 ASSERT(m_V0 > 0); // it has to be because of the division & sqrt below 00082 ASSERT(m_A > 0); 00083 ASSERT(m_B > 0); 00084 double s_str = m_S0 + m_S1 * sqrt(m_speed/m_V0) 00085 + m_T*m_speed + (m_speed*dv)/(2*sqrt(m_A*m_B)); 00086 00087 return s_str; 00088 }
double IDM::dvdt | ( | double | m_speed, | |
double | s | |||
) | [private] |
Definition at line 62 of file IDM.cpp.
References m_A, m_Delta, m_speed, m_V0, s_star(), and SAFE_BRAKING.
Referenced by update().
00063 { 00064 double s_str = s_star(dv); 00065 double intel_acc = m_A*(1-pow(m_speed/m_V0,m_Delta)); 00066 double intel_dec = -m_A*pow(s_str/s,2); 00067 00068 double net_acc = intel_acc + intel_dec; 00069 00070 // THIS NEEDS TO BE CAPPED OR BREAKDOWN OCCURS (net_acc ~ -30000) 00071 // Test value of -100 given 00072 if(net_acc < SAFE_BRAKING) 00073 net_acc = SAFE_BRAKING; 00074 00075 return net_acc; 00076 }
double IDM::m_T [private] |
Safe time headway.
Definition at line 44 of file IDM.h.
Referenced by ClearGradient(), get_T(), IDM(), s_star(), set_T(), and SetGradient().
double IDM::m_A [private] |
Maximum acceleration.
Definition at line 46 of file IDM.h.
Referenced by ClearGradient(), dvdt(), get_A(), IDM(), s_star(), set_A(), and SetGradient().
double IDM::m_B [private] |
Desired deceleration.
Definition at line 48 of file IDM.h.
Referenced by ClearGradient(), get_B(), IDM(), s_star(), set_B(), and SetGradient().
double IDM::m_S0 [private] |
double IDM::m_S1 [private] |
double IDM::m_V0 [private] |
Definition at line 54 of file IDM.h.
Referenced by ClearGradient(), ClearRestriction(), ClearSpeedLimit(), dvdt(), get_V0(), getDesiredVel(), IDM(), s_star(), set_V0(), SetGradient(), and SetSpeedLimit().
double IDM::m_Delta [private] |
double IDM::m_Polite [private] |
MOBIL: Consideration towards other drivers.
Definition at line 59 of file IDM.h.
Referenced by get_Polite(), IDM(), LaneChange(), and set_Polite().
double IDM::m_Bias [private] |
MOBIL: Desire to keep to slow lane.
Definition at line 61 of file IDM.h.
Referenced by get_Bias(), IDM(), LaneChange(), and set_Bias().
double IDM::m_DeltaAth [private] |
MOBIL: Dampens overtaking occurances.
Definition at line 63 of file IDM.h.
Referenced by get_DeltaAth(), IDM(), LaneChange(), and set_DeltaAth().
double IDM::m_V0_BeforeSpeedLimit [private] |
double IDM::m_T_BeforeGradient [private] |
double IDM::m_A_BeforeGradient [private] |
double IDM::m_B_BeforeGradient [private] |
double IDM::m_V0_BeforeGradient [private] |
double IDM::m_V0_Initial [private] |
Definition at line 70 of file IDM.h.
Referenced by ClearRestriction(), IDM(), set_V0(), and SetGradient().
double IDM::m_speed [private] |
double IDM::LANECHANGE_MIN_GAP [private] |
double IDM::SAFE_BRAKING [private] |
bool IDM::A_FLAG [private] |
double IDM::A_MIN [private] |
bool IDM::B_FLAG [private] |
double IDM::T_SLOPE [private] |
double IDM::V0_MIN [private] |
double IDM::V0_SLOPE [private] |