20 #ifndef MSDevice_ToC_h 21 #define MSDevice_ToC_h 41 class Command_ToCTrigger;
42 class Command_ToCProcess;
58 static std::set<MSDevice_ToC*, ComparatorNumericalIdLess>
myInstances;
68 OpenGapParams(
double timegap,
double spacing,
double changeRate,
double maxDecel,
bool active) :
69 newTimeHeadway(timegap), newSpaceHeadway(spacing), changeRate(changeRate), maxDecel(maxDecel), active(active)
94 static const std::set<MSDevice_ToC*, ComparatorNumericalIdLess>&
getInstances() {
155 double newSpeed)
override;
158 std::string
getParameter(
const std::string& key)
const override;
161 void setParameter(
const std::string& key,
const std::string& value)
override;
210 std::string manualType, std::string automatedType,
SUMOTime responseTime,
double recoveryRate,
211 double lcAbstinence,
double initialAwareness,
double mrmDecel,
212 double dynamicToCThreshold,
double dynamicMRMProbability,
double maxPreparationAccel,
325 std::queue<std::pair<SUMOTime, std::string> >
myEvents;
364 return MIN2(2 * sqrt(leadTime), 0.7 * leadTime);
int myPreviousLCMode
LC mode overridden during MRM, stored for restoration.
static int LCModeMRM
LC mode operational during an MRM.
double myOriginalMaxAccel
Storage for original maximal acceleration of vehicle.
void setParameter(const std::string &key, const std::string &value) override
try to set the given parameter for this device. Throw exception for unsupported key ...
MSDevice_ToC(SUMOVehicle &holder, const std::string &id, const std::string &outputFilename, std::string manualType, std::string automatedType, SUMOTime responseTime, double recoveryRate, double lcAbstinence, double initialAwareness, double mrmDecel, double dynamicToCThreshold, double dynamicMRMProbability, double maxPreparationAccel, bool mrmKeepRight, bool useColorScheme, OpenGapParams ogp)
Constructor.
static bool getMRMKeepRight(const SUMOVehicle &v, const OptionsCont &oc)
static std::set< MSDevice_ToC *, ComparatorNumericalIdLess > myInstances
static double getMaxPreparationAccel(const SUMOVehicle &v, const OptionsCont &oc)
static std::string getManualType(const SUMOVehicle &v, const OptionsCont &oc)
bool myIssuedDynamicToC
Flag to indicate that a dynamically triggered ToC is in preparation.
Representation of a vehicle in the micro simulation.
void descheduleRecovery()
Remove ongoing awareness recovery process from the event-queue.
ToCState myState
Current state of the device.
std::queue< std::pair< SUMOTime, std::string > > myEvents
Storage for events to be written to the output.
bool isAutomated()
Whether the current operation mode is automated.
static double responseTimeMean(double leadTime)
Mean of the response time distribution. (Only depends on given lead time)
bool checkDynamicToC()
Check if the vehicle should induce a ToC due to internal reasons. That is, if the route cannot be fol...
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_ToC-options.
static double getLCAbstinence(const SUMOVehicle &v, const OptionsCont &oc)
static double getRecoveryRate(const SUMOVehicle &v, const OptionsCont &oc)
SUMOTime MRMExecutionStep(SUMOTime t)
Continue the MRM for one time step.
bool isManuallyDriven()
Whether the current operation mode is manual.
void descheduleToCPreparation()
Remove ongoing ToC-Preparation process from the event-queue.
static ToCState _2ToCState(const std::string &)
void descheduleMRM()
Break MRM Process or remove MRM-Trigger command from the event-queue.
SUMOTime triggerUpwardToC(SUMOTime t)
Trigger execution of a ToC X–>AUTOMATED ("upwards")
static OpenGapParams getOpenGapParams(const SUMOVehicle &v, const OptionsCont &oc)
MSDevice_ToC & operator=(const MSDevice_ToC &)
Invalidated assignment operator.
WrappingCommand< MSDevice_ToC > * myExecuteMRMCommand
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed) override
Return value indicates whether the device still wants to be notified about the vehicle movement...
static double getResponseTime(const SUMOVehicle &v, const OptionsCont &oc)
static std::set< std::string > createdOutputFiles
void initColorScheme()
Initialize vehicle colors for different states.
static std::string _2string(ToCState state)
SUMOTime triggerDownwardToC(SUMOTime t)
Trigger execution of a ToC X–>MANUAL ("downwards")
static bool useColorScheme(const SUMOVehicle &v, const OptionsCont &oc)
std::string myAutomatedTypeID
vehicle type ID for automated driving
const std::string deviceName() const override
return the name for this type of device
void requestMRM()
Request an MRM to be initiated immediately. No downward ToC will be scheduled.
void deactivateDeliberateLCs()
Resets the holder's LC mode to the operational LC-mode of the ToC Device (.
bool myDynamicToCActive
Switch for considering dynamic ToCs,.
static std::mt19937 myResponseTimeRNG
Random generator for ToC devices.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice *> &into)
Build devices for the given vehicle, if needed.
static std::vector< double > lookupResponseTimeMRMProbs
Grid of the response time distribution.
WrappingCommand< MSDevice_ToC > * myTriggerMRMCommand
static void cleanup()
Closes root tags of output files.
static std::string getOutputFilename(const SUMOVehicle &v, const OptionsCont &oc)
void setAwareness(double value)
Set the awareness to the given value.
static std::mt19937 * getResponseTimeRNG()
bool myUseColorScheme
Whether a coloring scheme shall by applied to indicate the different toc stages,. ...
Representation of a vehicle.
OutputDevice * myOutputFile
The file the devices output goes to.
double myLCAbstinence
Level of the awareness below which no lane-changes are performed.
ToCState
Enum describing the different regimes for the device,.
bool myMRMKeepRight
Whether vehicle tries to change to the right during an MRM.
MSVehicle * myHolderMS
The holder vehicle casted to MSVehicle*.
double myMRMProbability
Probability of an MRM to occur after a dynamically triggered ToC.
SUMOTime myResponseTime
Average response time needed by the driver to take back control.
static double getMRMDecel(const SUMOVehicle &v, const OptionsCont &oc)
std::string myManualTypeID
vehicle type ID for manual driving
double sampleResponseTime(double leadTime) const
Samples a random driver response time from a truncated Gaussian with parameters according to the look...
double myCurrentAwareness
Current awareness-level of the driver in [0,1].
static double getInitialAwareness(const SUMOVehicle &v, const OptionsCont &oc)
SUMOTime ToCPreparationStep(SUMOTime t)
Continue the ToC preparation for one time step.
void requestToC(SUMOTime timeTillMRM, SUMOTime responseTime=-1000)
Request a ToC. If the device is in AUTOMATED or MRM state, a driver response time is sampled and the ...
Representation of a vehicle or person.
OpenGapParams(double timegap, double spacing, double changeRate, double maxDecel, bool active)
double myMaxPreparationAccel
Maximal acceleration that may be applied during the ToC preparation phase TODO: Make effective...
int myDynamicToCLane
Lane, on which the ongoing dynamic ToC was issued. It can only be aborted if the lane was changed...
A storage for options typed value containers)
Abstract in-vehicle device.
void setState(ToCState state)
Set the ToC device's state.
void descheduleToC()
Remove scheduled ToC-Trigger command from the event-queue.
double myRecoveryRate
Recovery rate for the driver's awareness after a ToC.
Static storage of an output device and its base (abstract) implementation.
std::string getParameter(const std::string &key) const override
try to retrieve the given parameter from this device. Throw exception for unsupported key ...
static const std::set< MSDevice_ToC *, ComparatorNumericalIdLess > & getInstances()
returns all currently existing ToC devices
WrappingCommand< MSDevice_ToC > * myRecoverAwarenessCommand
SUMOTime awarenessRecoveryStep(SUMOTime t)
Continue the awareness recovery for one time step.
~MSDevice_ToC()
Destructor.
void resetDeliberateLCs()
Resets the holder's LC mode to the last differing to LCModeMRM.
WrappingCommand< MSDevice_ToC > * myTriggerToCCommand
static double getDynamicMRMProbability(const SUMOVehicle &v, const OptionsCont &oc)
static double getDynamicToCThreshold(const SUMOVehicle &v, const OptionsCont &oc)
static std::vector< double > lookupResponseTimeLeadTimes
void switchHolderType(const std::string &targetTypeID)
Switch the device holder's vehicle type.
static double interpolateVariance(double leadTime, double pMRM)
Two-dimensional interpolation of variance from lookup table assumes pMRM >= 0, leadTime >= 0...
static std::vector< std::vector< double > > lookupResponseTimeVariances
Variances of the response time distribution. Given the lead time and the MRM probability the variance...
OpenGapParams myOpenGapParams
Parameters for the openGap mechanism applied during ToC preparation phase.
double myDynamicToCThreshold
Duration in s. for which the vehicle needs to be able to follow its route without a lane change to co...
SUMOTime triggerMRM(SUMOTime t)
Trigger execution of an MRM.
WrappingCommand< MSDevice_ToC > * myPrepareToCCommand
std::map< ToCState, RGBColor > myColorScheme
Coloring scheme,.
bool generatesOutput()
Whether this device requested to write output.
The ToC Device controls transition of control between automated and manual driving.
void writeOutput()
Write output to file given by option device.toc.file.
double myMRMDecel
Deceleration rate applied during MRM.
double myInitialAwareness
Average awareness the driver has initially after a ToC.
static std::string getAutomatedType(const SUMOVehicle &v, const OptionsCont &oc)