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