SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MSDevice_BTreceiver.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A BT sender
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2013-2015 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
36 #include <utils/geom/Position.h>
37 #include <utils/geom/Line.h>
38 #include <utils/geom/GeomHelper.h>
39 #include <microsim/MSNet.h>
40 #include <microsim/MSLane.h>
41 #include <microsim/MSEdge.h>
42 #include <microsim/MSVehicle.h>
43 #include "MSDevice_Tripinfo.h"
44 #include "MSDevice_BTreceiver.h"
45 #include "MSDevice_BTsender.h"
46 
47 #ifdef CHECK_MEMORY_LEAKS
48 #include <foreign/nvwa/debug_new.h>
49 #endif // CHECK_MEMORY_LEAKS
50 
51 
52 // ===========================================================================
53 // static members
54 // ===========================================================================
59 std::map<std::string, MSDevice_BTreceiver::VehicleInformation*> MSDevice_BTreceiver::sVehicles;
60 
61 
62 // ===========================================================================
63 // method definitions
64 // ===========================================================================
65 // ---------------------------------------------------------------------------
66 // static initialisation methods
67 // ---------------------------------------------------------------------------
68 void
70  insertDefaultAssignmentOptions("btreceiver", "Communication", oc);
71 
72  oc.doRegister("device.btreceiver.range", new Option_Float(300));
73  oc.addDescription("device.btreceiver.range", "Communication", "The range of the bt receiver");
74 
75  oc.doRegister("device.btreceiver.all-recognitions", new Option_Bool(false));
76  oc.addDescription("device.btreceiver.all-recognitions", "Communication", "Whether all recognition point shall be written");
77 
78  oc.doRegister("device.btreceiver.offtime", new Option_Float(0.64));
79  oc.addDescription("device.btreceiver.offtime", "Communication", "The offtime used for calculating detection probability (in seconds)");
80 
81  myWasInitialised = false;
82 }
83 
84 
85 void
86 MSDevice_BTreceiver::buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into) {
88  if (equippedByDefaultAssignmentOptions(oc, "btreceiver", v)) {
89  MSDevice_BTreceiver* device = new MSDevice_BTreceiver(v, "btreceiver_" + v.getID());
90  into.push_back(device);
91  if (!myWasInitialised) {
92  new BTreceiverUpdate();
93  myWasInitialised = true;
94  myRange = oc.getFloat("device.btreceiver.range");
95  myOffTime = oc.getFloat("device.btreceiver.offtime");
96  sRecognitionRNG.seed(oc.getInt("seed"));
97  }
98  }
99 }
100 
101 
102 // ---------------------------------------------------------------------------
103 // MSDevice_BTreceiver::BTreceiverUpdate-methods
104 // ---------------------------------------------------------------------------
107 }
108 
109 
111  for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::const_iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end(); ++i) {
112  (*i).second->amOnNet = false;
113  (*i).second->haveArrived = true;
114  }
115  for (std::map<std::string, MSDevice_BTreceiver::VehicleInformation*>::const_iterator i = MSDevice_BTreceiver::sVehicles.begin(); i != MSDevice_BTreceiver::sVehicles.end(); ++i) {
116  (*i).second->amOnNet = false;
117  (*i).second->haveArrived = true;
118  }
119  execute(MSNet::getInstance()->getCurrentTimeStep());
120 }
121 
122 
123 SUMOTime
125  // build rtree with senders
126  NamedRTree rt;
127  for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::const_iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end(); ++i) {
128  MSDevice_BTsender::VehicleInformation* vi = (*i).second;
129  Boundary b = vi->getBoxBoundary();
130  b.grow(POSITION_EPS);
131  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
132  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
133  rt.Insert(cmin, cmax, vi);
134  }
135 
136  // check visibility for all receivers
138  bool allRecognitions = oc.getBool("device.btreceiver.all-recognitions");
139  bool haveOutput = oc.isSet("bt-output");
140  for (std::map<std::string, MSDevice_BTreceiver::VehicleInformation*>::iterator i = MSDevice_BTreceiver::sVehicles.begin(); i != MSDevice_BTreceiver::sVehicles.end();) {
141  // collect surrounding vehicles
142  MSDevice_BTreceiver::VehicleInformation* vi = (*i).second;
143  Boundary b = vi->getBoxBoundary();
144  b.grow(vi->range);
145  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
146  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
147  std::set<std::string> surroundingVehicles;
148  Named::StoringVisitor sv(surroundingVehicles);
149  rt.Search(cmin, cmax, sv);
150 
151  // loop over surrounding vehicles, check visibility status
152  for (std::set<std::string>::const_iterator j = surroundingVehicles.begin(); j != surroundingVehicles.end(); ++j) {
153  if ((*i).first == *j) {
154  // seeing oneself? skip
155  continue;
156  }
157  updateVisibility(*vi, *MSDevice_BTsender::sVehicles.find(*j)->second);
158  }
159 
160  if (vi->haveArrived) {
161  // vehicle has left the simulation; remove
162  if (haveOutput) {
163  writeOutput((*i).first, vi->seen, allRecognitions);
164  }
165  delete vi;
167  } else {
168  // vehicle is still in the simulation; reset state
169  vi->updates.erase(vi->updates.begin(), vi->updates.end() - 1);
170  ++i;
171  }
172  }
173 
174  // remove arrived senders / reset state
175  for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end();) {
176  MSDevice_BTsender::VehicleInformation* vi = (*i).second;
177  if (vi->haveArrived) {
178  delete vi;
179  MSDevice_BTsender::sVehicles.erase(i++);
180  } else {
181  vi->updates.erase(vi->updates.begin(), vi->updates.end() - 1);
182  ++i;
183  }
184  }
185  return DELTA_T;
186 }
187 
188 
189 void
192  const MSDevice_BTsender::VehicleState& receiverData = receiver.updates.back();
193  const MSDevice_BTsender::VehicleState& senderData = sender.updates.back();
194  if (!receiver.amOnNet || !sender.amOnNet) {
195  // at least one of the vehicles has left the simulation area for any reason
196  if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
197  leaveRange(receiver, receiverData, sender, senderData, 0);
198  }
199  }
200 
201  const Position& oldReceiverPosition = receiver.updates.front().position;
202  const Position& oldSenderPosition = sender.updates.front().position;
203 
204  // let the other's current position be the one obtained by applying the relative direction vector to the initial position
205  const Position senderDelta = senderData.position - oldSenderPosition;
206  const Position receiverDelta = receiverData.position - oldReceiverPosition;
207  const Position translatedSender = senderData.position - receiverDelta;
208  // find crossing points
209  std::vector<SUMOReal> intersections;
210  GeomHelper::FindLineCircleIntersections(oldReceiverPosition, receiver.range, oldSenderPosition, translatedSender, intersections);
211  switch (intersections.size()) {
212  case 0:
213  // no intersections -> other vehicle either stays within or beyond range
214  if (receiver.amOnNet && sender.amOnNet && receiverData.position.distanceTo(senderData.position) < receiver.range) {
215  if (receiver.currentlySeen.find(sender.getID()) == receiver.currentlySeen.end()) {
216  enterRange(0., receiverData, sender.getID(), senderData, receiver.currentlySeen);
217  } else {
218  addRecognitionPoint(SIMTIME, receiverData, senderData, receiver.currentlySeen[sender.getID()]);
219  }
220  } else {
221  if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
222  leaveRange(receiver, receiverData, sender, senderData, 0.);
223  }
224  }
225  break;
226  case 1: {
227  // one intersection -> other vehicle either enters or leaves the range
228  MSDevice_BTsender::VehicleState intersection1ReceiverData(receiverData);
229  intersection1ReceiverData.position = oldReceiverPosition + receiverDelta * intersections.front();
230  MSDevice_BTsender::VehicleState intersection1SenderData(senderData);
231  intersection1SenderData.position = oldSenderPosition + senderDelta * intersections.front();
232  if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
233  leaveRange(receiver, intersection1ReceiverData,
234  sender, intersection1SenderData, (intersections.front() - 1.) * TS);
235  } else {
236  enterRange((intersections.front() - 1.) * TS, intersection1ReceiverData,
237  sender.getID(), intersection1SenderData, receiver.currentlySeen);
238  }
239  }
240  break;
241  case 2:
242  // two intersections -> other vehicle enters and leaves the range
243  if (receiver.currentlySeen.find(sender.getID()) == receiver.currentlySeen.end()) {
244  MSDevice_BTsender::VehicleState intersectionReceiverData(receiverData);
245  intersectionReceiverData.position = oldReceiverPosition + receiverDelta * intersections.front();
246  MSDevice_BTsender::VehicleState intersectionSenderData(senderData);
247  intersectionSenderData.position = oldSenderPosition + senderDelta * intersections.front();
248  enterRange((intersections.front() - 1.) * TS, intersectionReceiverData,
249  sender.getID(), intersectionSenderData, receiver.currentlySeen);
250  intersectionReceiverData.position = oldReceiverPosition + receiverDelta * intersections.back();
251  intersectionSenderData.position = oldSenderPosition + senderDelta * intersections.back();
252  leaveRange(receiver, intersectionReceiverData,
253  sender, intersectionSenderData, (intersections.back() - 1.) * TS);
254  } else {
255  WRITE_WARNING("The vehicle '" + sender.getID() + "' cannot be in the range of '" + receiver.getID() + "', leave, and enter it in one step.");
256  }
257  break;
258  default:
259  WRITE_WARNING("Nope, a circle cannot be crossed more often than twice by a line.");
260  break;
261  }
262 }
263 
264 
265 void
267  const std::string& senderID, const MSDevice_BTsender::VehicleState& senderState,
268  std::map<std::string, SeenDevice*>& currentlySeen) {
269  MeetingPoint mp(SIMTIME + atOffset, receiverState, senderState);
270  SeenDevice* sd = new SeenDevice(mp);
271  currentlySeen[senderID] = sd;
272  addRecognitionPoint(SIMTIME, receiverState, senderState, sd);
273 }
274 
275 
276 void
279  SUMOReal tOffset) {
280  std::map<std::string, SeenDevice*>::iterator i = receiverInfo.currentlySeen.find(senderInfo.getID());
281  // check whether the other was recognized
282  addRecognitionPoint(SIMTIME + tOffset, receiverState, senderState, i->second);
283  // build leaving point
284  i->second->meetingEnd = new MeetingPoint(STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()) + tOffset, receiverState, senderState);
285  ConstMSEdgeVector::const_iterator begin = receiverInfo.route.begin() + i->second->meetingBegin.observerState.routePos;
286  ConstMSEdgeVector::const_iterator end = receiverInfo.route.begin() + receiverState.routePos + 1;
287  i->second->receiverRoute = toString<const MSEdge>(begin, end);
288  begin = senderInfo.route.begin() + i->second->meetingBegin.seenState.routePos;
289  end = senderInfo.route.begin() + senderState.routePos + 1;
290  i->second->senderRoute = toString<const MSEdge>(begin, end);
291  receiverInfo.seen[senderInfo.getID()].push_back(i->second);
292  receiverInfo.currentlySeen.erase(i);
293 }
294 
295 
296 SUMOReal
297 MSDevice_BTreceiver::inquiryDelaySlots(const int backoffLimit) {
298  const int phaseOffset = sRecognitionRNG.randInt(2047);
299  const bool interlaced = sRecognitionRNG.rand() < 0.7;
300  const SUMOReal delaySlots = sRecognitionRNG.rand() * 15;
301  const int backoff = sRecognitionRNG.randInt(backoffLimit);
302  if (interlaced) {
303  return sRecognitionRNG.rand() * 31 + backoff;
304  }
305  if (sRecognitionRNG.randInt(31) < 16) {
306  // correct train for f0
307  return delaySlots + backoff;
308  }
309  if (sRecognitionRNG.randInt(30) < 16) {
310  // correct train for f1
311  return 2048 - phaseOffset + delaySlots + backoff;
312  }
313  if (sRecognitionRNG.randInt(29) < 16) {
314  // f2 is in train A but has overlap with both trains
315  if (2 * 2048 - phaseOffset + backoff < 4096) {
316  return 2 * 2048 - phaseOffset + delaySlots + backoff;
317  }
318  // the following is wrong but should only happen in about 3% of the non-interlaced cases
319  return 2 * 2048 - phaseOffset + delaySlots + backoff;
320  }
321  return 2 * 2048 + delaySlots + backoff;
322 }
323 
324 
325 void
327  const MSDevice_BTsender::VehicleState& senderState,
328  SeenDevice* senderDevice) const {
329  if (senderDevice->nextView == -1.) {
330  senderDevice->nextView = senderDevice->lastView + inquiryDelaySlots(int(myOffTime / 0.000625 + .5)) * 0.000625;
331  }
332  if (tEnd > senderDevice->nextView) {
333  senderDevice->lastView = senderDevice->nextView;
334  MeetingPoint* mp = new MeetingPoint(tEnd, receiverState, senderState);
335  senderDevice->recognitionPoints.push_back(mp);
336  senderDevice->nextView = senderDevice->lastView + inquiryDelaySlots(int(myOffTime / 0.000625 + .5)) * 0.000625;
337  }
338 }
339 
340 
341 void
342 MSDevice_BTreceiver::BTreceiverUpdate::writeOutput(const std::string& id, const std::map<std::string, std::vector<SeenDevice*> >& seen, bool allRecognitions) {
344  os.openTag("bt").writeAttr("id", id);
345  for (std::map<std::string, std::vector<SeenDevice*> >::const_iterator j = seen.begin(); j != seen.end(); ++j) {
346  const std::vector<SeenDevice*>& sts = (*j).second;
347  for (std::vector<SeenDevice*>::const_iterator k = sts.begin(); k != sts.end(); ++k) {
348  os.openTag("seen").writeAttr("id", (*j).first);
349  const MSDevice_BTsender::VehicleState& obsBeg = (*k)->meetingBegin.observerState;
350  const MSDevice_BTsender::VehicleState& seenBeg = (*k)->meetingBegin.seenState;
351  os.writeAttr("tBeg", (*k)->meetingBegin.t)
352  .writeAttr("observerPosBeg", obsBeg.position).writeAttr("observerSpeedBeg", obsBeg.speed)
353  .writeAttr("observerLaneIDBeg", obsBeg.laneID).writeAttr("observerLanePosBeg", obsBeg.lanePos)
354  .writeAttr("seenPosBeg", seenBeg.position).writeAttr("seenSpeedBeg", seenBeg.speed)
355  .writeAttr("seenLaneIDBeg", seenBeg.laneID).writeAttr("seenLanePosBeg", seenBeg.lanePos);
356  const MSDevice_BTsender::VehicleState& obsEnd = (*k)->meetingEnd->observerState;
357  const MSDevice_BTsender::VehicleState& seenEnd = (*k)->meetingEnd->seenState;
358  os.writeAttr("tEnd", (*k)->meetingEnd->t)
359  .writeAttr("observerPosEnd", obsEnd.position).writeAttr("observerSpeedEnd", obsEnd.speed)
360  .writeAttr("observerLaneIDEnd", obsEnd.laneID).writeAttr("observerLanePosEnd", obsEnd.lanePos)
361  .writeAttr("seenPosEnd", seenEnd.position).writeAttr("seenSpeedEnd", seenEnd.speed)
362  .writeAttr("seenLaneIDEnd", seenEnd.laneID).writeAttr("seenLanePosEnd", seenEnd.lanePos)
363  .writeAttr("observerRoute", (*k)->receiverRoute).writeAttr("seenRoute", (*k)->senderRoute);
364  for (std::vector<MeetingPoint*>::iterator l = (*k)->recognitionPoints.begin(); l != (*k)->recognitionPoints.end(); ++l) {
365  os.openTag("recognitionPoint").writeAttr("t", (*l)->t)
366  .writeAttr("observerPos", (*l)->observerState.position).writeAttr("observerSpeed", (*l)->observerState.speed)
367  .writeAttr("observerLaneID", (*l)->observerState.laneID).writeAttr("observerLanePos", (*l)->observerState.lanePos)
368  .writeAttr("seenPos", (*l)->seenState.position).writeAttr("seenSpeed", (*l)->seenState.speed)
369  .writeAttr("seenLaneID", (*l)->seenState.laneID).writeAttr("seenLanePos", (*l)->seenState.lanePos)
370  .closeTag();
371  if (!allRecognitions) {
372  break;
373  }
374  }
375  os.closeTag();
376  }
377  }
378  os.closeTag();
379 }
380 
381 
382 
383 
384 // ---------------------------------------------------------------------------
385 // MSDevice_BTreceiver-methods
386 // ---------------------------------------------------------------------------
388  : MSDevice(holder, id) {
389 }
390 
391 
393 }
394 
395 
396 bool
398  if (reason == MSMoveReminder::NOTIFICATION_DEPARTED && sVehicles.find(veh.getID()) == sVehicles.end()) {
399  sVehicles[veh.getID()] = new VehicleInformation(veh.getID(), myRange);
400  sVehicles[veh.getID()]->route.push_back(veh.getEdge());
401  }
402  if (reason == MSMoveReminder::NOTIFICATION_TELEPORT && sVehicles.find(veh.getID()) != sVehicles.end()) {
403  sVehicles[veh.getID()]->amOnNet = true;
404  }
406  sVehicles[veh.getID()]->route.push_back(veh.getEdge());
407  }
408  const MSVehicle& v = static_cast<MSVehicle&>(veh);
409  sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(veh.getSpeed(), veh.getPosition(), v.getLane()->getID(), veh.getPositionOnLane(), v.getRoutePosition()));
410  return true;
411 }
412 
413 
414 bool
416  if (sVehicles.find(veh.getID()) == sVehicles.end()) {
417  WRITE_WARNING("btreceiver: Can not update position of a vehicle that is not within the road network (" + veh.getID() + ").");
418  return true;
419  }
420  const MSVehicle& v = static_cast<MSVehicle&>(veh);
421  sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(newSpeed, veh.getPosition(), v.getLane()->getID(), newPos, v.getRoutePosition()));
422  return true;
423 }
424 
425 
426 bool
429  return true;
430  }
431  if (sVehicles.find(veh.getID()) == sVehicles.end()) {
432  WRITE_WARNING("btreceiver: Can not update position of a vehicle that is not within the road network (" + veh.getID() + ").");
433  return true;
434  }
435  const MSVehicle& v = static_cast<MSVehicle&>(veh);
436  sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(veh.getSpeed(), veh.getPosition(), v.getLane()->getID(), veh.getPositionOnLane(), v.getRoutePosition()));
438  sVehicles[veh.getID()]->amOnNet = false;
439  }
440  if (reason >= MSMoveReminder::NOTIFICATION_ARRIVED) {
441  sVehicles[veh.getID()]->amOnNet = false;
442  sVehicles[veh.getID()]->haveArrived = true;
443  }
444  return true;
445 }
446 
447 
448 
449 
450 
451 /****************************************************************************/
452 
bool amOnNet
Whether the vehicle is within the simulated network.
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
Definition: NamedRTree.h:90
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:84
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:257
double rand()
Position position
The position of the vehicle.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
SUMOReal lanePos
The position at the lane of the vehicle.
The vehicle arrived at a junction.
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
std::string laneID
The lane the vehicle was at.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle's position along the lane.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:112
Notification
Definition of a vehicle state.
A RT-tree for efficient storing of SUMO's Named objects.
Definition: NamedRTree.h:72
std::vector< MeetingPoint * > recognitionPoints
List of recognition points.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:159
static MTRand sRecognitionRNG
A random number generator used to determine whether the opposite was recognized.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:229
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, Notification reason)
Moves (the known) vehicle from running to arrived vehicles' list.
SUMOReal lastView
Last recognition point.
Boundary getBoxBoundary() const
Returns the boundary of passed positions.
#define TS
Definition: SUMOTime.h:52
static void FindLineCircleIntersections(const Position &c, SUMOReal radius, const Position &p1, const Position &p2, std::vector< SUMOReal > &into)
Returns the positions the given circle is crossed by the given line.
Definition: GeomHelper.cpp:163
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:118
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
MSDevice_BTreceiver(SUMOVehicle &holder, const std::string &id)
Constructor.
ConstMSEdgeVector route
List of edges travelled.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
#define SIMTIME
Definition: SUMOTime.h:96
std::map< std::string, std::vector< SeenDevice * > > seen
The past episodes of removed vehicle.
static SUMOReal myRange
The range of the device.
static SUMOReal inquiryDelaySlots(const int backoffLimit)
const std::string & getID() const
Returns the id.
Definition: Named.h:60
Class representing a single seen device.
Representation of a vehicle.
Definition: SUMOVehicle.h:65
static bool myWasInitialised
Whether the bt-system was already initialised.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A single movement state of the vehicle.
bool haveArrived
Whether the vehicle was removed from the simulation.
SUMOReal nextView
Next possible recognition point.
void writeOutput(const std::string &id, const std::map< std::string, std::vector< SeenDevice * > > &seen, bool allRecognitions)
Writes the output.
The vehicle arrived at its destination (is deleted)
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
SUMOReal speed
The speed of the vehicle.
bool notifyEnter(SUMOVehicle &veh, Notification reason)
Adds the vehicle to running vehicles if it (re-) enters the network.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc)
Adds common command options that allow to assign devices to vehicles.
Definition: MSDevice.cpp:85
#define POSITION_EPS
Definition: config.h:189
~MSDevice_BTreceiver()
Destructor.
SUMOTime execute(SUMOTime currentTime)
Performs the update.
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived receivers.
virtual SUMOTime addEvent(Command *operation, SUMOTime execTimeStep, AdaptType type)
Adds an Event.
void leaveRange(VehicleInformation &receiverInfo, const MSDevice_BTsender::VehicleState &receiverState, MSDevice_BTsender::VehicleInformation &senderInfo, const MSDevice_BTsender::VehicleState &senderState, SUMOReal tOffset)
Removes the sender from the currently seen devices to past episodes.
Stores the information of a vehicle.
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition: MSNet.h:379
Abstract in-vehicle device.
Definition: MSDevice.h:69
Holds the information about exact positions/speeds/time of the begin/end of a meeting.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, SUMOVehicle &v)
Determines whether a vehicle should get a certain device.
Definition: MSDevice.cpp:99
Allows to store the object; used as context while traveling the rtree in TraCI.
Definition: Named.h:92
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:200
The vehicle has departed (was inserted into the network)
unsigned int routePos
The position in the route of the vehicle.
virtual SUMOReal getSpeed() const =0
Returns the vehicle's current speed.
void enterRange(SUMOReal atOffset, const MSDevice_BTsender::VehicleState &receiverState, const std::string &senderID, const MSDevice_BTsender::VehicleState &senderState, std::map< std::string, SeenDevice * > &currentlySeen)
Informs the receiver about a sender entering it's radius.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
void addRecognitionPoint(const SUMOReal tEnd, const MSDevice_BTsender::VehicleState &receiverState, const MSDevice_BTsender::VehicleState &senderState, SeenDevice *senderDevice) const
Adds a point of recognition.
uint32 randInt()
std::map< std::string, SeenDevice * > currentlySeen
The map of devices seen by the vehicle at removal time.
void seed(const uint32 oneSeed)
std::vector< VehicleState > updates
List of position updates during last step.
static SUMOReal myOffTime
The offtime of the device.
A storage for options typed value containers)
Definition: OptionsCont.h:108
virtual Position getPosition(const SUMOReal offset=0) const =0
Return current position (x/y, cartesian)
int SUMOTime
Definition: SUMOTime.h:43
const SUMOReal range
Recognition range of the vehicle.
Patch the time in a way that it is at least as high as the simulation begin time. ...
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
bool closeTag()
Closes the most recently opened tag.
#define SUMOReal
Definition: config.h:218
Stores the information of a vehicle.
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
#define DELTA_T
Definition: SUMOTime.h:50
void updateVisibility(VehicleInformation &receiver, MSDevice_BTsender::VehicleInformation &sender)
Rechecks the visibility for a given receiver/sender pair.
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived senders.
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:331
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
Definition: NamedRTree.h:123
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into)
Build devices for the given vehicle, if needed.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTreceiver-options.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
unsigned int getRoutePosition() const
Definition: MSVehicle.cpp:511
virtual const std::string & getID() const =0
Get the vehicle's ID.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
The vehicle is being teleported.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.