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