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