SUMO - Simulation of Urban MObility
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-2016 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/GeomHelper.h>
38 #include <microsim/MSNet.h>
39 #include <microsim/MSLane.h>
40 #include <microsim/MSEdge.h>
41 #include <microsim/MSVehicle.h>
42 #include "MSDevice_Tripinfo.h"
43 #include "MSDevice_BTreceiver.h"
44 #include "MSDevice_BTsender.h"
45 
46 #ifdef CHECK_MEMORY_LEAKS
47 #include <foreign/nvwa/debug_new.h>
48 #endif // CHECK_MEMORY_LEAKS
49 
50 
51 // ===========================================================================
52 // static members
53 // ===========================================================================
58 std::map<std::string, MSDevice_BTreceiver::VehicleInformation*> MSDevice_BTreceiver::sVehicles;
59 
60 
61 // ===========================================================================
62 // method definitions
63 // ===========================================================================
64 // ---------------------------------------------------------------------------
65 // static initialisation methods
66 // ---------------------------------------------------------------------------
67 void
69  insertDefaultAssignmentOptions("btreceiver", "Communication", oc);
70 
71  oc.doRegister("device.btreceiver.range", new Option_Float(300));
72  oc.addDescription("device.btreceiver.range", "Communication", "The range of the bt receiver");
73 
74  oc.doRegister("device.btreceiver.all-recognitions", new Option_Bool(false));
75  oc.addDescription("device.btreceiver.all-recognitions", "Communication", "Whether all recognition point shall be written");
76 
77  oc.doRegister("device.btreceiver.offtime", new Option_Float(0.64));
78  oc.addDescription("device.btreceiver.offtime", "Communication", "The offtime used for calculating detection probability (in seconds)");
79 
80  myWasInitialised = false;
81 }
82 
83 
84 void
85 MSDevice_BTreceiver::buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into) {
87  if (equippedByDefaultAssignmentOptions(oc, "btreceiver", v)) {
88  MSDevice_BTreceiver* device = new MSDevice_BTreceiver(v, "btreceiver_" + v.getID());
89  into.push_back(device);
90  if (!myWasInitialised) {
91  new BTreceiverUpdate();
92  myWasInitialised = true;
93  myRange = oc.getFloat("device.btreceiver.range");
94  myOffTime = oc.getFloat("device.btreceiver.offtime");
95  sRecognitionRNG.seed(oc.getInt("seed"));
96  }
97  }
98 }
99 
100 
101 // ---------------------------------------------------------------------------
102 // MSDevice_BTreceiver::BTreceiverUpdate-methods
103 // ---------------------------------------------------------------------------
106 }
107 
108 
110  for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::const_iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end(); ++i) {
111  (*i).second->amOnNet = false;
112  (*i).second->haveArrived = true;
113  }
114  for (std::map<std::string, MSDevice_BTreceiver::VehicleInformation*>::const_iterator i = MSDevice_BTreceiver::sVehicles.begin(); i != MSDevice_BTreceiver::sVehicles.end(); ++i) {
115  (*i).second->amOnNet = false;
116  (*i).second->haveArrived = true;
117  }
118  execute(MSNet::getInstance()->getCurrentTimeStep());
119 }
120 
121 
122 SUMOTime
124  // build rtree with senders
125  NamedRTree rt;
126  for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::const_iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end(); ++i) {
127  MSDevice_BTsender::VehicleInformation* vi = (*i).second;
128  Boundary b = vi->getBoxBoundary();
129  b.grow(POSITION_EPS);
130  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
131  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
132  rt.Insert(cmin, cmax, vi);
133  }
134 
135  // check visibility for all receivers
137  bool allRecognitions = oc.getBool("device.btreceiver.all-recognitions");
138  bool haveOutput = oc.isSet("bt-output");
139  for (std::map<std::string, MSDevice_BTreceiver::VehicleInformation*>::iterator i = MSDevice_BTreceiver::sVehicles.begin(); i != MSDevice_BTreceiver::sVehicles.end();) {
140  // collect surrounding vehicles
141  MSDevice_BTreceiver::VehicleInformation* vi = (*i).second;
142  Boundary b = vi->getBoxBoundary();
143  b.grow(vi->range);
144  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
145  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
146  std::set<std::string> surroundingVehicles;
147  Named::StoringVisitor sv(surroundingVehicles);
148  rt.Search(cmin, cmax, sv);
149 
150  // loop over surrounding vehicles, check visibility status
151  for (std::set<std::string>::const_iterator j = surroundingVehicles.begin(); j != surroundingVehicles.end(); ++j) {
152  if ((*i).first == *j) {
153  // seeing oneself? skip
154  continue;
155  }
156  updateVisibility(*vi, *MSDevice_BTsender::sVehicles.find(*j)->second);
157  }
158 
159  if (vi->haveArrived) {
160  // vehicle has left the simulation; remove
161  if (haveOutput) {
162  writeOutput((*i).first, vi->seen, allRecognitions);
163  }
164  delete vi;
166  } else {
167  // vehicle is still in the simulation; reset state
168  vi->updates.erase(vi->updates.begin(), vi->updates.end() - 1);
169  ++i;
170  }
171  }
172 
173  // remove arrived senders / reset state
174  for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end();) {
175  MSDevice_BTsender::VehicleInformation* vi = (*i).second;
176  if (vi->haveArrived) {
177  delete vi;
178  MSDevice_BTsender::sVehicles.erase(i++);
179  } else {
180  vi->updates.erase(vi->updates.begin(), vi->updates.end() - 1);
181  ++i;
182  }
183  }
184  return DELTA_T;
185 }
186 
187 
188 void
191  const MSDevice_BTsender::VehicleState& receiverData = receiver.updates.back();
192  const MSDevice_BTsender::VehicleState& senderData = sender.updates.back();
193  if (!receiver.amOnNet || !sender.amOnNet) {
194  // at least one of the vehicles has left the simulation area for any reason
195  if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
196  leaveRange(receiver, receiverData, sender, senderData, 0);
197  }
198  }
199 
200  const Position& oldReceiverPosition = receiver.updates.front().position;
201  const Position& oldSenderPosition = sender.updates.front().position;
202 
203  // let the other's current position be the one obtained by applying the relative direction vector to the initial position
204  const Position senderDelta = senderData.position - oldSenderPosition;
205  const Position receiverDelta = receiverData.position - oldReceiverPosition;
206  const Position translatedSender = senderData.position - receiverDelta;
207  // find crossing points
208  std::vector<SUMOReal> intersections;
209  GeomHelper::findLineCircleIntersections(oldReceiverPosition, receiver.range, oldSenderPosition, translatedSender, intersections);
210  switch (intersections.size()) {
211  case 0:
212  // no intersections -> other vehicle either stays within or beyond range
213  if (receiver.amOnNet && sender.amOnNet && receiverData.position.distanceTo(senderData.position) < receiver.range) {
214  if (receiver.currentlySeen.find(sender.getID()) == receiver.currentlySeen.end()) {
215  enterRange(0., receiverData, sender.getID(), senderData, receiver.currentlySeen);
216  } else {
217  addRecognitionPoint(SIMTIME, receiverData, senderData, receiver.currentlySeen[sender.getID()]);
218  }
219  } else {
220  if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
221  leaveRange(receiver, receiverData, sender, senderData, 0.);
222  }
223  }
224  break;
225  case 1: {
226  // one intersection -> other vehicle either enters or leaves the range
227  MSDevice_BTsender::VehicleState intersection1ReceiverData(receiverData);
228  intersection1ReceiverData.position = oldReceiverPosition + receiverDelta * intersections.front();
229  MSDevice_BTsender::VehicleState intersection1SenderData(senderData);
230  intersection1SenderData.position = oldSenderPosition + senderDelta * intersections.front();
231  if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
232  leaveRange(receiver, intersection1ReceiverData,
233  sender, intersection1SenderData, (intersections.front() - 1.) * TS);
234  } else {
235  enterRange((intersections.front() - 1.) * TS, intersection1ReceiverData,
236  sender.getID(), intersection1SenderData, receiver.currentlySeen);
237  }
238  }
239  break;
240  case 2:
241  // two intersections -> other vehicle enters and leaves the range
242  if (receiver.currentlySeen.find(sender.getID()) == receiver.currentlySeen.end()) {
243  MSDevice_BTsender::VehicleState intersectionReceiverData(receiverData);
244  intersectionReceiverData.position = oldReceiverPosition + receiverDelta * intersections.front();
245  MSDevice_BTsender::VehicleState intersectionSenderData(senderData);
246  intersectionSenderData.position = oldSenderPosition + senderDelta * intersections.front();
247  enterRange((intersections.front() - 1.) * TS, intersectionReceiverData,
248  sender.getID(), intersectionSenderData, receiver.currentlySeen);
249  intersectionReceiverData.position = oldReceiverPosition + receiverDelta * intersections.back();
250  intersectionSenderData.position = oldSenderPosition + senderDelta * intersections.back();
251  leaveRange(receiver, intersectionReceiverData,
252  sender, intersectionSenderData, (intersections.back() - 1.) * TS);
253  } else {
254  WRITE_WARNING("The vehicle '" + sender.getID() + "' cannot be in the range of vehicle '" + receiver.getID() + "', leave, and enter it in one step.");
255  }
256  break;
257  default:
258  WRITE_WARNING("Nope, a circle cannot be crossed more often than twice by a line.");
259  break;
260  }
261 }
262 
263 
264 void
266  const std::string& senderID, const MSDevice_BTsender::VehicleState& senderState,
267  std::map<std::string, SeenDevice*>& currentlySeen) {
268  MeetingPoint mp(SIMTIME + atOffset, receiverState, senderState);
269  SeenDevice* sd = new SeenDevice(mp);
270  currentlySeen[senderID] = sd;
271  addRecognitionPoint(SIMTIME, receiverState, senderState, sd);
272 }
273 
274 
275 void
278  SUMOReal tOffset) {
279  std::map<std::string, SeenDevice*>::iterator i = receiverInfo.currentlySeen.find(senderInfo.getID());
280  // check whether the other was recognized
281  addRecognitionPoint(SIMTIME + tOffset, receiverState, senderState, i->second);
282  // build leaving point
283  i->second->meetingEnd = new MeetingPoint(STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()) + tOffset, receiverState, senderState);
284  ConstMSEdgeVector::const_iterator begin = receiverInfo.route.begin() + i->second->meetingBegin.observerState.routePos;
285  ConstMSEdgeVector::const_iterator end = receiverInfo.route.begin() + receiverState.routePos + 1;
286  i->second->receiverRoute = toString<const MSEdge>(begin, end);
287  begin = senderInfo.route.begin() + i->second->meetingBegin.seenState.routePos;
288  end = senderInfo.route.begin() + senderState.routePos + 1;
289  i->second->senderRoute = toString<const MSEdge>(begin, end);
290  receiverInfo.seen[senderInfo.getID()].push_back(i->second);
291  receiverInfo.currentlySeen.erase(i);
292 }
293 
294 
295 SUMOReal
296 MSDevice_BTreceiver::inquiryDelaySlots(const int backoffLimit) {
297  const int phaseOffset = sRecognitionRNG.randInt(2047);
298  const bool interlaced = sRecognitionRNG.rand() < 0.7;
299  const SUMOReal delaySlots = sRecognitionRNG.rand() * 15;
300  const int backoff = sRecognitionRNG.randInt(backoffLimit);
301  if (interlaced) {
302  return sRecognitionRNG.rand() * 31 + backoff;
303  }
304  if (sRecognitionRNG.randInt(31) < 16) {
305  // correct train for f0
306  return delaySlots + backoff;
307  }
308  if (sRecognitionRNG.randInt(30) < 16) {
309  // correct train for f1
310  return 2048 - phaseOffset + delaySlots + backoff;
311  }
312  if (sRecognitionRNG.randInt(29) < 16) {
313  // f2 is in train A but has overlap with both trains
314  if (2 * 2048 - phaseOffset + backoff < 4096) {
315  return 2 * 2048 - phaseOffset + delaySlots + backoff;
316  }
317  // the following is wrong but should only happen in about 3% of the non-interlaced cases
318  return 2 * 2048 - phaseOffset + delaySlots + backoff;
319  }
320  return 2 * 2048 + delaySlots + backoff;
321 }
322 
323 
324 void
326  const MSDevice_BTsender::VehicleState& senderState,
327  SeenDevice* senderDevice) const {
328  if (senderDevice->nextView == -1.) {
329  senderDevice->nextView = senderDevice->lastView + inquiryDelaySlots(int(myOffTime / 0.000625 + .5)) * 0.000625;
330  }
331  if (tEnd > senderDevice->nextView) {
332  senderDevice->lastView = senderDevice->nextView;
333  MeetingPoint* mp = new MeetingPoint(tEnd, receiverState, senderState);
334  senderDevice->recognitionPoints.push_back(mp);
335  senderDevice->nextView = senderDevice->lastView + inquiryDelaySlots(int(myOffTime / 0.000625 + .5)) * 0.000625;
336  }
337 }
338 
339 
340 void
341 MSDevice_BTreceiver::BTreceiverUpdate::writeOutput(const std::string& id, const std::map<std::string, std::vector<SeenDevice*> >& seen, bool allRecognitions) {
343  os.openTag("bt").writeAttr("id", id);
344  for (std::map<std::string, std::vector<SeenDevice*> >::const_iterator j = seen.begin(); j != seen.end(); ++j) {
345  const std::vector<SeenDevice*>& sts = (*j).second;
346  for (std::vector<SeenDevice*>::const_iterator k = sts.begin(); k != sts.end(); ++k) {
347  os.openTag("seen").writeAttr("id", (*j).first);
348  const MSDevice_BTsender::VehicleState& obsBeg = (*k)->meetingBegin.observerState;
349  const MSDevice_BTsender::VehicleState& seenBeg = (*k)->meetingBegin.seenState;
350  os.writeAttr("tBeg", (*k)->meetingBegin.t)
351  .writeAttr("observerPosBeg", obsBeg.position).writeAttr("observerSpeedBeg", obsBeg.speed)
352  .writeAttr("observerLaneIDBeg", obsBeg.laneID).writeAttr("observerLanePosBeg", obsBeg.lanePos)
353  .writeAttr("seenPosBeg", seenBeg.position).writeAttr("seenSpeedBeg", seenBeg.speed)
354  .writeAttr("seenLaneIDBeg", seenBeg.laneID).writeAttr("seenLanePosBeg", seenBeg.lanePos);
355  const MSDevice_BTsender::VehicleState& obsEnd = (*k)->meetingEnd->observerState;
356  const MSDevice_BTsender::VehicleState& seenEnd = (*k)->meetingEnd->seenState;
357  os.writeAttr("tEnd", (*k)->meetingEnd->t)
358  .writeAttr("observerPosEnd", obsEnd.position).writeAttr("observerSpeedEnd", obsEnd.speed)
359  .writeAttr("observerLaneIDEnd", obsEnd.laneID).writeAttr("observerLanePosEnd", obsEnd.lanePos)
360  .writeAttr("seenPosEnd", seenEnd.position).writeAttr("seenSpeedEnd", seenEnd.speed)
361  .writeAttr("seenLaneIDEnd", seenEnd.laneID).writeAttr("seenLanePosEnd", seenEnd.lanePos)
362  .writeAttr("observerRoute", (*k)->receiverRoute).writeAttr("seenRoute", (*k)->senderRoute);
363  for (std::vector<MeetingPoint*>::iterator l = (*k)->recognitionPoints.begin(); l != (*k)->recognitionPoints.end(); ++l) {
364  os.openTag("recognitionPoint").writeAttr("t", (*l)->t)
365  .writeAttr("observerPos", (*l)->observerState.position).writeAttr("observerSpeed", (*l)->observerState.speed)
366  .writeAttr("observerLaneID", (*l)->observerState.laneID).writeAttr("observerLanePos", (*l)->observerState.lanePos)
367  .writeAttr("seenPos", (*l)->seenState.position).writeAttr("seenSpeed", (*l)->seenState.speed)
368  .writeAttr("seenLaneID", (*l)->seenState.laneID).writeAttr("seenLanePos", (*l)->seenState.lanePos)
369  .closeTag();
370  if (!allRecognitions) {
371  break;
372  }
373  }
374  os.closeTag();
375  }
376  }
377  os.closeTag();
378 }
379 
380 
381 
382 
383 // ---------------------------------------------------------------------------
384 // MSDevice_BTreceiver-methods
385 // ---------------------------------------------------------------------------
387  : MSDevice(holder, id) {
388 }
389 
390 
392 }
393 
394 
395 bool
397  if (reason == MSMoveReminder::NOTIFICATION_DEPARTED && sVehicles.find(veh.getID()) == sVehicles.end()) {
398  sVehicles[veh.getID()] = new VehicleInformation(veh.getID(), myRange);
399  sVehicles[veh.getID()]->route.push_back(veh.getEdge());
400  }
401  if (reason == MSMoveReminder::NOTIFICATION_TELEPORT && sVehicles.find(veh.getID()) != sVehicles.end()) {
402  sVehicles[veh.getID()]->amOnNet = true;
403  }
405  sVehicles[veh.getID()]->route.push_back(veh.getEdge());
406  }
407  const MSVehicle& v = static_cast<MSVehicle&>(veh);
408  sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(veh.getSpeed(), veh.getPosition(), v.getLane()->getID(), veh.getPositionOnLane(), v.getRoutePosition()));
409  return true;
410 }
411 
412 
413 bool
415  if (sVehicles.find(veh.getID()) == sVehicles.end()) {
416  WRITE_WARNING("btreceiver: Can not update position of vehicle '" + veh.getID() + "' which is not on the road.");
417  return true;
418  }
419  const MSVehicle& v = static_cast<MSVehicle&>(veh);
420  sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(newSpeed, veh.getPosition(), v.getLane()->getID(), newPos, v.getRoutePosition()));
421  return true;
422 }
423 
424 
425 bool
428  return true;
429  }
430  if (sVehicles.find(veh.getID()) == sVehicles.end()) {
431  WRITE_WARNING("btreceiver: Can not update position of vehicle '" + veh.getID() + "' which is not on the road.");
432  return true;
433  }
434  const MSVehicle& v = static_cast<MSVehicle&>(veh);
435  sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(veh.getSpeed(), veh.getPosition(), v.getLane()->getID(), veh.getPositionOnLane(), v.getRoutePosition()));
437  sVehicles[veh.getID()]->amOnNet = false;
438  }
439  if (reason >= MSMoveReminder::NOTIFICATION_ARRIVED) {
440  sVehicles[veh.getID()]->amOnNet = false;
441  sVehicles[veh.getID()]->haveArrived = true;
442  }
443  return true;
444 }
445 
446 
447 
448 
449 
450 /****************************************************************************/
451 
int getRoutePosition() const
Definition: MSVehicle.cpp:679
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:86
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:82
long long int SUMOTime
Definition: SUMOTime.h:43
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
void writeOutput(const std::string &id, const std::map< std::string, std::vector< SeenDevice *> > &seen, bool allRecognitions)
Writes the output.
SUMOReal lanePos
The position at the lane of the vehicle.
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:487
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:221
int routePos
The position in the route of the vehicle.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
The vehicle arrived at a junction.
std::string laneID
The lane the vehicle was at.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
Notification
Definition of a vehicle state.
A RT-tree for efficient storing of SUMO&#39;s Named objects.
Definition: NamedRTree.h:72
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:142
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
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
static MTRand sRecognitionRNG
A random number generator used to determine whether the opposite was recognized.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:148
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, Notification reason)
Moves (the known) vehicle from running to arrived vehicles&#39; list.
const std::string & getID() const
Returns the id.
Definition: Named.h:66
SUMOReal lastView
Last recognition point.
#define TS
Definition: SUMOTime.h:52
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:130
#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:69
#define SIMTIME
Definition: SUMOTime.h:70
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)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
Class representing a single seen device.
Representation of a vehicle.
Definition: SUMOVehicle.h:66
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.
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:58
bool haveArrived
Whether the vehicle was removed from the simulation.
SUMOReal nextView
Next possible recognition point.
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:94
#define POSITION_EPS
Definition: config.h:187
~MSDevice_BTreceiver()
Destructor.
SUMOTime execute(SUMOTime currentTime)
Performs the update.
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived receivers.
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
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:410
Abstract in-vehicle device.
Definition: MSDevice.h:69
Holds the information about exact positions/speeds/time of the begin/end of a meeting.
void addRecognitionPoint(const SUMOReal tEnd, const MSDevice_BTsender::VehicleState &receiverState, const MSDevice_BTsender::VehicleState &senderState, SeenDevice *senderDevice) const
Adds a point of recognition.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, SUMOVehicle &v)
Determines whether a vehicle should get a certain device.
Definition: MSDevice.cpp:108
Allows to store the object; used as context while traveling the rtree in TraCI.
Definition: Named.h:100
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:232
The vehicle has departed (was inserted into the network)
virtual SUMOReal getSpeed() const =0
Returns the vehicle&#39;s current speed.
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:136
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
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:99
virtual Position getPosition(const SUMOReal offset=0) const =0
Return current position (x/y, cartesian)
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:213
Stores the information of a vehicle.
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.
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.
Boundary getBoxBoundary() const
Returns the boundary of passed positions.
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
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&#39;s radius.
The vehicle is being teleported.