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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // A BT Receiver
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<const Named*> surroundingVehicles;
136  Named::StoringVisitor sv(surroundingVehicles);
137  rt.Search(cmin, cmax, sv);
138 
139  // loop over surrounding vehicles, check visibility status
140  for (const Named* vehicle : surroundingVehicles) {
141  if ((*i).first == vehicle->getID()) {
142  // seeing oneself? skip
143  continue;
144  }
145  updateVisibility(*vi, *MSDevice_BTsender::sVehicles.find(vehicle->getID())->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 /****************************************************************************/
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define TS
Definition: SUMOTime.h:40
#define SIMTIME
Definition: SUMOTime.h:60
long long int SUMOTime
Definition: SUMOTime.h:32
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:129
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:117
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:299
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:135
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:123
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:46
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:51
int getRoutePosition() const
return index of edge within route
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.
void writeOutput(const std::string &id, const std::map< std::string, std::vector< SeenDevice * > > &seen, bool allRecognitions)
Writes the output.
void addRecognitionPoint(const double tEnd, const MSDevice_BTsender::VehicleState &receiverState, const MSDevice_BTsender::VehicleState &senderState, SeenDevice *senderDevice) const
Adds a point of recognition.
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.
void updateVisibility(VehicleInformation &receiver, MSDevice_BTsender::VehicleInformation &sender)
Rechecks the visibility for a given receiver/sender pair.
SUMOTime execute(SUMOTime currentTime)
Performs the update.
Holds the information about exact positions/speeds/time of the begin/end of a meeting.
Class representing a single seen device.
double nextView
Next possible recognition point.
double lastView
Last recognition point.
std::vector< MeetingPoint * > recognitionPoints
List of recognition points.
Stores the information of a vehicle.
std::map< std::string, SeenDevice * > currentlySeen
The map of devices seen by the vehicle at removal time.
std::map< std::string, std::vector< SeenDevice * > > seen
The past episodes of removed vehicle.
const double range
Recognition range of the vehicle.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTreceiver-options.
static bool myWasInitialised
Whether the bt-system was already initialised.
static double inquiryDelaySlots(const int backoffLimit)
static double myRange
The range of the device.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
static SumoRNG sRecognitionRNG
A random number generator used to determine whether the opposite was recognized.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived receivers.
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane=0)
Adds the vehicle to running vehicles if it (re-) enters the network.
MSDevice_BTreceiver(SUMOVehicle &holder, const std::string &id)
Constructor.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Moves (the known) vehicle from running to arrived vehicles' list.
static double myOffTime
The offtime of the device.
Stores the information of a vehicle.
bool amOnNet
Whether the vehicle is within the simulated network.
bool haveArrived
Whether the vehicle was removed from the simulation.
ConstMSEdgeVector route
List of edges travelled.
Boundary getBoxBoundary() const
Returns the boundary of passed positions.
std::vector< VehicleState > updates
List of position updates during last step.
A single movement state of the vehicle.
int routePos
The position in the route of the vehicle.
double speed
The speed of the vehicle.
Position position
The position of the vehicle.
double lanePos
The position at the lane of the vehicle.
std::string laneID
The lane the vehicle was at.
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived senders.
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:137
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:205
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static bool gUseMesoSim
Definition: MSGlobals.h:94
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
const MSLane * getLane() const
Returns the lane the reminder works on.
Notification
Definition of a vehicle state.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition: MSNet.h:479
Abstract in-vehicle device.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:75
Allows to store the object; used as context while traveling the rtree in TraCI.
Definition: Named.h:90
Base class for objects which have an id.
Definition: Named.h:54
const std::string & getID() const
Returns the id.
Definition: Named.h:74
A RT-tree for efficient storing of SUMO's Named objects.
Definition: NamedRTree.h:61
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
Definition: NamedRTree.h:79
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:112
A storage for options typed value containers)
Definition: OptionsCont.h:89
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:75
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:248
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:242
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Definition: RandHelper.h:119
Representation of a vehicle, person, or container.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
static double sd[6]
Definition: odrSpiral.cpp:52