54 oc.
addDescription(
"device.bluelight.reactiondist",
"Bluelight Device",
"Set the distance at which other drivers react to the blue light and siren sound");
64 into.push_back(device);
73 double reactionDist) :
75 myReactionDist(reactionDist) {
76 #ifdef DEBUG_BLUELIGHT
77 std::cout <<
"initialized device '" <<
id <<
"' with myReactionDist=" <<
myReactionDist <<
"\n";
88 double ,
double newSpeed) {
89 #ifdef DEBUG_BLUELIGHT
90 std::cout <<
"device '" <<
getID() <<
"' notifyMove: newSpeed=" << newSpeed <<
"\n";
121 std::vector<const MSEdge*> myUpcomingEdges;
123 for (
const MSLane*
const l : myUpcomingLanes) {
124 myUpcomingEdges.push_back(&l->getEdge());
128 assert(veh2 !=
nullptr);
129 if (veh2->
getLane() ==
nullptr) {
133 if (std::find(myUpcomingEdges.begin(), myUpcomingEdges.end(), &veh2->
getLane()->
getEdge()) != myUpcomingEdges.end()) {
157 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
174 double reactionProb = 0.189;
175 if (distanceDelta < 12.5) {
176 reactionProb = 0.577;
178 if (reaction < reactionProb) {
207 if (targetType !=
nullptr) {
220 && myUpcomingEdges.size() > 1) {
224 if (next ==
nullptr) {
225 next = myUpcomingEdges[1];
230 double bestJump = std::numeric_limits<double>::max();
231 double newPosLat = 0;
232 if (allowed !=
nullptr) {
233 for (
MSLane* nextCand : *allowed) {
234 for (
auto ili : nextCand->getIncomingLanes()) {
235 if (&ili.lane->getEdge() == currentEdge) {
237 if (jump < bestJump) {
244 newPosLat =
MAX2(-maxVehOffset, newPosLat);
245 newPosLat =
MIN2(maxVehOffset, newPosLat);
265 #ifdef DEBUG_BLUELIGHT
266 std::cout <<
"device '" <<
getID() <<
"' notifyEnter: reason=" << reason <<
" currentEdge=" << veh.
getEdge()->
getID() <<
"\n";
277 #ifdef DEBUG_BLUELIGHT
278 std::cout <<
"device '" <<
getID() <<
"' notifyLeave: reason=" << reason <<
" currentEdge=" << veh.
getEdge()->
getID() <<
"\n";
289 if (tripinfoOut !=
nullptr) {
290 tripinfoOut->
openTag(
"bluelight");
297 if (key ==
"reactiondist") {
312 if (key ==
"reactiondist") {
@ LATALIGN_RIGHT
drive on the right side
@ LATALIGN_LEFT
drive on the left side
@ LATALIGN_ARBITRARY
maintain the current alignment
@ SUMO_ATTR_LCA_SPEEDGAIN_LOOKAHEAD
@ SUMO_ATTR_LCA_STRATEGIC_PARAM
#define UNUSED_PARAMETER(x)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual void prepareStep()
virtual void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this laneChangeModel. Throw exception for unsupported key
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
A device which collects info on the vehicle trip (mainly on departure and arrival)
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Bluelight-options.
std::map< std::string, std::string > influencedTypes
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
double myReactionDist
reaction distance of other vehicle (i.e. due to different noise levels of the siren)
~MSDevice_Bluelight()
Destructor.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
const std::string deviceName() const
return the name for this type of device
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing tripinfo output.
MSDevice_Bluelight(SUMOVehicle &holder, const std::string &id, double reactionDist)
Constructor.
std::set< std::string > influencedVehicles
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
static double getFloatParam(const SUMOVehicle &v, const OptionsCont &oc, std::string paramName, double deflt, bool required)
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
A road/street connecting two junctions.
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal) const
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Representation of a lane in the micro simulation.
double getLength() const
Returns the lane's length.
int getIndex() const
Returns the lane's index.
MSEdge & getEdge() const
Returns the lane's edge.
double getWidth() const
Returns the lane's width.
Notification
Definition of a vehicle state.
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Changes the wished vehicle speed / lanes.
void setLaneChangeMode(int value)
Sets lane changing behavior.
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
The class responsible for building and deletion of vehicles.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=nullptr)
Returns the named vehicle type or a sample from the named distribution.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
Abstract in-vehicle device.
Representation of a vehicle in the micro simulation.
bool enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
const std::vector< const MSLane * > getUpcomingLanesUntil(double distance) const
Returns the upcoming (best followed by default 0) sequence of lanes to continue the route starting at...
void setTentativeLaneAndPosition(MSLane *lane, double pos, double posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
MSAbstractLaneChangeModel & getLaneChangeModel()
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
void leaveLane(const MSMoveReminder::Notification reason, const MSLane *approachedLane=0)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane.
Influencer & getInfluencer()
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getSpeed() const
Returns the vehicle's current speed.
double getPositionOnLane() const
Get the vehicle's position along the lane.
const MSLane * getLane() const
Returns the lane the vehicle is on.
The car-following model and parameter.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
void setPreferredLateralAlignment(LateralAlignment latAlignment)
Set vehicle's preferred lateral alignment.
const std::string & getID() const
Returns the name of the vehicle type.
const SUMOVTypeParameter & getParameter() const
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
static double rand(std::mt19937 *rng=nullptr)
Returns a random real number in [0, 1)
Representation of a vehicle, person, or container.
virtual SUMOTime getWaitingTime() const =0
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
std::string getLCParamString(const SumoXMLAttr attr, const std::string &defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
Representation of a vehicle.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter