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