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