SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSDevice_BTreceiver.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A BT sender
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2013-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
36 #include <utils/geom/Position.h>
37 #include <utils/geom/Line.h>
38 #include <utils/geom/GeomHelper.h>
39 #include <microsim/MSNet.h>
40 #include <microsim/MSLane.h>
41 #include <microsim/MSEdge.h>
42 #include <microsim/MSVehicle.h>
43 #include "MSDevice_Tripinfo.h"
44 #include "MSDevice_BTreceiver.h"
45 #include "MSDevice_BTsender.h"
46 
47 #ifdef CHECK_MEMORY_LEAKS
48 #include <foreign/nvwa/debug_new.h>
49 #endif // CHECK_MEMORY_LEAKS
50 
51 
52 // ===========================================================================
53 // static members
54 // ===========================================================================
59 std::map<std::string, MSDevice_BTreceiver::VehicleInformation*> MSDevice_BTreceiver::sVehicles;
60 
61 
62 // ===========================================================================
63 // method definitions
64 // ===========================================================================
65 // ---------------------------------------------------------------------------
66 // static initialisation methods
67 // ---------------------------------------------------------------------------
68 void
70  insertDefaultAssignmentOptions("btreceiver", "Communication", oc);
71 
72  oc.doRegister("device.btreceiver.range", new Option_Float(300));
73  oc.addDescription("device.btreceiver.range", "Communication", "The range of the bt receiver");
74 
75  oc.doRegister("device.btreceiver.all-recognitions", new Option_Bool(false));
76  oc.addDescription("device.btreceiver.all-recognitions", "Communication", "Whether all recognition point shall be written");
77 
78  oc.doRegister("device.btreceiver.offtime", new Option_Float(0.64));
79  oc.addDescription("device.btreceiver.offtime", "Communication", "The offtime used for calculating detection probability (in seconds)");
80 
81  myWasInitialised = false;
82 }
83 
84 
85 void
86 MSDevice_BTreceiver::buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into) {
88  if (equippedByDefaultAssignmentOptions(oc, "btreceiver", v)) {
89  MSDevice_BTreceiver* device = new MSDevice_BTreceiver(v, "btreceiver_" + v.getID());
90  into.push_back(device);
91  if (!myWasInitialised) {
92  new BTreceiverUpdate();
93  myWasInitialised = true;
94  myRange = oc.getFloat("device.btreceiver.range");
95  myOffTime = oc.getFloat("device.btreceiver.offtime");
96  sRecognitionRNG.seed(oc.getInt("seed"));
97  }
98  }
99 }
100 
101 
102 // ---------------------------------------------------------------------------
103 // MSDevice_BTreceiver::BTreceiverUpdate-methods
104 // ---------------------------------------------------------------------------
107 }
108 
109 
111  for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::const_iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end(); ++i) {
112  (*i).second->amOnNet = false;
113  (*i).second->haveArrived = true;
114  }
115  for (std::map<std::string, MSDevice_BTreceiver::VehicleInformation*>::const_iterator i = MSDevice_BTreceiver::sVehicles.begin(); i != MSDevice_BTreceiver::sVehicles.end(); ++i) {
116  (*i).second->amOnNet = false;
117  (*i).second->haveArrived = true;
118  }
119  execute(MSNet::getInstance()->getCurrentTimeStep());
120 }
121 
122 
123 SUMOTime
125  // build rtree with senders
126  NamedRTree rt;
127  for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::const_iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end(); ++i) {
128  MSDevice_BTsender::VehicleInformation* vi = (*i).second;
129  Boundary b = vi->getBoxBoundary();
130  b.grow(POSITION_EPS);
131  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
132  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
133  rt.Insert(cmin, cmax, vi);
134  }
135 
136  // check visibility for all receivers
138  bool allRecognitions = oc.getBool("device.btreceiver.all-recognitions");
139  bool haveOutput = oc.isSet("bt-output");
140  for (std::map<std::string, MSDevice_BTreceiver::VehicleInformation*>::iterator i = MSDevice_BTreceiver::sVehicles.begin(); i != MSDevice_BTreceiver::sVehicles.end();) {
141  // collect surrounding vehicles
142  MSDevice_BTreceiver::VehicleInformation* vi = (*i).second;
143  Boundary b = vi->getBoxBoundary();
144  b.grow(vi->range);
145  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
146  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
147  std::set<std::string> surroundingVehicles;
148  Named::StoringVisitor sv(surroundingVehicles);
149  rt.Search(cmin, cmax, sv);
150 
151  // loop over surrounding vehicles, check visibility status
152  for (std::set<std::string>::const_iterator j = surroundingVehicles.begin(); j != surroundingVehicles.end(); ++j) {
153  if ((*i).first == *j) {
154  // seeing oneself? skip
155  continue;
156  }
157  updateVisibility(*vi, *MSDevice_BTsender::sVehicles.find(*j)->second);
158  }
159 
160  if (vi->haveArrived) {
161  // vehicle has left the simulation; remove
162  if (haveOutput) {
163  writeOutput((*i).first, vi->seen, allRecognitions);
164  }
165  delete vi;
167  } else {
168  // vehicle is still in the simulation; reset state
169  vi->updates.erase(vi->updates.begin(), vi->updates.end() - 1);
170  ++i;
171  }
172  }
173 
174  // remove arrived senders / reset state
175  for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end();) {
176  MSDevice_BTsender::VehicleInformation* vi = (*i).second;
177  if (vi->haveArrived) {
178  delete vi;
179  MSDevice_BTsender::sVehicles.erase(i++);
180  } else {
181  vi->updates.erase(vi->updates.begin(), vi->updates.end() - 1);
182  ++i;
183  }
184  }
185  return DELTA_T;
186 }
187 
188 
189 void
192  const MSDevice_BTsender::VehicleState& receiverData = receiver.updates.back();
193  const MSDevice_BTsender::VehicleState& senderData = sender.updates.back();
194  if (!receiver.amOnNet || !sender.amOnNet) {
195  // at least one of the vehicles has left the simulation area for any reason
196  if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
197  leaveRange(receiver.currentlySeen, receiver.seen, receiverData.position, receiverData.speed, receiverData.laneID, receiverData.lanePos,
198  sender.getID(), senderData.position, senderData.speed, senderData.laneID, senderData.lanePos, 0);
199  }
200  }
201 
202  const Position& oldReceiverPosition = receiver.updates.front().position;
203  const Position& oldSenderPosition = sender.updates.front().position;
204 
205  // let the other's current position be the one obtained by applying the relative direction vector to the initial position
206  const Position senderDelta = senderData.position - oldSenderPosition;
207  const Position receiverDelta = receiverData.position - oldReceiverPosition;
208  const Position translatedSender = senderData.position - receiverDelta;
209  // find crossing points
210  std::vector<SUMOReal> intersections;
211  GeomHelper::FindLineCircleIntersections(oldReceiverPosition, receiver.range, oldSenderPosition, translatedSender, intersections);
212  switch (intersections.size()) {
213  case 0:
214  // no intersections -> other vehicle either stays within or beyond range
215  if (receiver.amOnNet && sender.amOnNet && receiverData.position.distanceTo(senderData.position) < receiver.range) {
216  if (receiver.currentlySeen.find(sender.getID()) == receiver.currentlySeen.end()) {
217  enterRange(0., receiverData.position, receiverData.speed, receiverData.laneID, receiverData.lanePos,
218  sender.getID(), senderData.position, senderData.speed, senderData.laneID, senderData.lanePos, receiver.currentlySeen);
219  } else {
220  addRecognitionPoint(SIMTIME, receiverData.position, receiverData.speed, receiverData.laneID, receiverData.lanePos,
221  senderData.position, senderData.speed, senderData.laneID, senderData.lanePos, receiver.currentlySeen[sender.getID()]);
222  }
223  } else {
224  if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
225  leaveRange(receiver.currentlySeen, receiver.seen, receiverData.position, receiverData.speed, receiverData.laneID, receiverData.lanePos,
226  sender.getID(), senderData.position, senderData.speed, senderData.laneID, senderData.lanePos, 0.);
227  }
228  }
229  break;
230  case 1: {
231  // one intersection -> other vehicle either enters or leaves the range
232  const Position intersection1Sender = oldSenderPosition + senderDelta * intersections.front();
233  const Position intersection1Receiver = oldReceiverPosition + receiverDelta * intersections.front();
234  if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
235  leaveRange(receiver.currentlySeen, receiver.seen, intersection1Receiver, receiverData.speed, receiverData.laneID, receiverData.lanePos,
236  sender.getID(), intersection1Sender, senderData.speed, senderData.laneID, senderData.lanePos, (intersections.front() - 1.) * TS);
237  } else {
238  enterRange((intersections.front() - 1.) * TS, intersection1Receiver, receiverData.speed, receiverData.laneID, receiverData.lanePos,
239  sender.getID(), intersection1Sender, senderData.speed, senderData.laneID, senderData.lanePos, receiver.currentlySeen);
240  }
241  }
242  break;
243  case 2:
244  // two intersections -> other vehicle enters and leaves the range
245  if (receiver.currentlySeen.find(sender.getID()) == receiver.currentlySeen.end()) {
246  const Position intersection1Sender = oldSenderPosition + senderDelta * intersections.front();
247  const Position intersection1Receiver = oldReceiverPosition + receiverDelta * intersections.front();
248  enterRange((intersections.front() - 1.) * TS, intersection1Receiver, receiverData.speed, receiverData.laneID, receiverData.lanePos,
249  sender.getID(), intersection1Sender, senderData.speed, senderData.laneID, senderData.lanePos, receiver.currentlySeen);
250  const Position intersection2Sender = oldSenderPosition + senderDelta * intersections.back();
251  const Position intersection2Receiver = oldReceiverPosition + receiverDelta * intersections.back();
252  leaveRange(receiver.currentlySeen, receiver.seen, intersection2Receiver, receiverData.speed, receiverData.laneID, receiverData.lanePos,
253  sender.getID(), intersection2Sender, senderData.speed, senderData.laneID, senderData.lanePos, (intersections.back() - 1.) * TS);
254  } else {
255  WRITE_WARNING("The vehicle '" + sender.getID() + "' cannot be in the range of '" + receiver.getID() + "', leave, and enter it in one step.");
256  }
257  break;
258  default:
259  WRITE_WARNING("Nope, a circle cannot be crossed more often than twice by a line.");
260  break;
261  }
262 }
263 
264 
265 void
267  const Position& thisPos, SUMOReal thisSpeed, const std::string& thisLaneID, SUMOReal thisLanePos,
268  const std::string& otherID, const Position& otherPos, SUMOReal otherSpeed, const std::string& otherLaneID, SUMOReal otherLanePos,
269  std::map<std::string, SeenDevice*>& currentlySeen) {
270  MeetingPoint mp(SIMTIME + atOffset, thisPos, thisSpeed, thisLaneID, thisLanePos, otherPos, otherSpeed, otherLaneID, otherLanePos);
271  SeenDevice* sd = new SeenDevice(mp);
272  currentlySeen[otherID] = sd;
273  addRecognitionPoint(SIMTIME, thisPos, thisSpeed, thisLaneID, thisLanePos,
274  otherPos, otherSpeed, otherLaneID, otherLanePos, sd);
275 }
276 
277 
278 void
279 MSDevice_BTreceiver::BTreceiverUpdate::leaveRange(std::map<std::string, SeenDevice*>& currentlySeen, std::map<std::string, std::vector<SeenDevice*> >& seen,
280  const Position& thisPos, SUMOReal thisSpeed, const std::string& thisLaneID, SUMOReal thisLanePos,
281  const std::string& otherID, const Position& otherPos, SUMOReal otherSpeed, const std::string& otherLaneID, SUMOReal otherLanePos,
282  SUMOReal tOffset) {
283  std::map<std::string, SeenDevice*>::iterator i = currentlySeen.find(otherID);
284  // check whether the other was recognized
285  addRecognitionPoint(SIMTIME + tOffset, thisPos, thisSpeed, thisLaneID, thisLanePos,
286  otherPos, otherSpeed, otherLaneID, otherLanePos, (*i).second);
287  // build leaving point
288  MeetingPoint mp(STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()) + tOffset, thisPos, thisSpeed, thisLaneID, thisLanePos, otherPos, otherSpeed, otherLaneID, otherLanePos);
289  (*i).second->meetingEnd = mp;
290  if (seen.find(otherID) == seen.end()) {
291  seen[otherID] = std::vector<SeenDevice*>();
292  }
293  seen[otherID].push_back((*i).second);
294  currentlySeen.erase(i);
295 }
296 
297 
298 void
299 MSDevice_BTreceiver::BTreceiverUpdate::addRecognitionPoint(const SUMOReal tEnd, const Position& thisPos, const SUMOReal thisSpeed, const std::string& thisLaneID, const SUMOReal thisLanePos,
300  const Position& otherPos, const SUMOReal otherSpeed, const std::string& otherLaneID, const SUMOReal otherLanePos,
301  SeenDevice* otherDevice) const {
302  const SUMOReal t = tEnd - MAX2(SIMTIME - TS, otherDevice->lastView);
303  // probability of a miss 0.5 (may be in the wrong train), backoff time 0.64s
304  if (sRecognitionRNG.rand() <= 1 - pow(0.5, t / myOffTime)) {
305  otherDevice->lastView = tEnd;
306  MeetingPoint* mp = new MeetingPoint(tEnd, thisPos, thisSpeed, thisLaneID, thisLanePos, otherPos, otherSpeed, otherLaneID, otherLanePos);
307  otherDevice->recognitionPoints.push_back(mp);
308  }
309 }
310 
311 
312 void
313 MSDevice_BTreceiver::BTreceiverUpdate::writeOutput(const std::string& id, const std::map<std::string, std::vector<SeenDevice*> >& seen, bool allRecognitions) {
315  os.openTag("bt").writeAttr("id", id);
316  for (std::map<std::string, std::vector<SeenDevice*> >::const_iterator j = seen.begin(); j != seen.end(); ++j) {
317  const std::vector<SeenDevice*>& sts = (*j).second;
318  for (std::vector<SeenDevice*>::const_iterator k = sts.begin(); k != sts.end(); ++k) {
319  os.openTag("seen").writeAttr("id", (*j).first);
320  os.writeAttr("tBeg", (*k)->meetingBegin.t)
321  .writeAttr("observerPosBeg", (*k)->meetingBegin.observerPos).writeAttr("observerSpeedBeg", (*k)->meetingBegin.observerSpeed)
322  .writeAttr("observerLaneIDBeg", (*k)->meetingBegin.observerLaneID).writeAttr("observerLanePosBeg", (*k)->meetingBegin.observerLanePos)
323  .writeAttr("seenPosBeg", (*k)->meetingBegin.seenPos).writeAttr("seenSpeedBeg", (*k)->meetingBegin.seenSpeed)
324  .writeAttr("seenLaneIDBeg", (*k)->meetingBegin.seenLaneID).writeAttr("seenLanePosBeg", (*k)->meetingBegin.seenLanePos);
325  os.writeAttr("tEnd", (*k)->meetingEnd.t)
326  .writeAttr("observerPosEnd", (*k)->meetingEnd.observerPos).writeAttr("observerSpeedEnd", (*k)->meetingEnd.observerSpeed)
327  .writeAttr("observerLaneIDEnd", (*k)->meetingEnd.observerLaneID).writeAttr("observerLanePosEnd", (*k)->meetingEnd.observerLanePos)
328  .writeAttr("seenPosEnd", (*k)->meetingEnd.seenPos).writeAttr("seenSpeedEnd", (*k)->meetingEnd.seenSpeed)
329  .writeAttr("seenLaneIDEnd", (*k)->meetingEnd.seenLaneID).writeAttr("seenLanePosEnd", (*k)->meetingEnd.seenLanePos);
330  for (std::vector<MeetingPoint*>::iterator l = (*k)->recognitionPoints.begin(); l != (*k)->recognitionPoints.end(); ++l) {
331  os.openTag("recognitionPoint").writeAttr("t", (*l)->t)
332  .writeAttr("observerPos", (*l)->observerPos).writeAttr("observerSpeed", (*l)->observerSpeed)
333  .writeAttr("observerLaneID", (*l)->observerLaneID).writeAttr("observerLanePos", (*l)->observerLanePos)
334  .writeAttr("seenPos", (*l)->seenPos).writeAttr("seenSpeed", (*l)->seenSpeed)
335  .writeAttr("seenLaneID", (*l)->seenLaneID).writeAttr("seenLanePos", (*l)->seenLanePos)
336  .closeTag();
337  if (!allRecognitions) {
338  break;
339  }
340  }
341  os.closeTag();
342  }
343  }
344  os.closeTag();
345 }
346 
347 
348 
349 
350 // ---------------------------------------------------------------------------
351 // MSDevice_BTreceiver-methods
352 // ---------------------------------------------------------------------------
354  : MSDevice(holder, id) {
355 }
356 
357 
359 }
360 
361 
362 bool
364  if (reason == MSMoveReminder::NOTIFICATION_DEPARTED && sVehicles.find(veh.getID()) == sVehicles.end()) {
365  sVehicles[veh.getID()] = new VehicleInformation(veh.getID(), myRange);
366  }
367  if (reason == MSMoveReminder::NOTIFICATION_TELEPORT && sVehicles.find(veh.getID()) != sVehicles.end()) {
368  sVehicles[veh.getID()]->amOnNet = true;
369  }
370  sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(veh.getSpeed(), static_cast<MSVehicle&>(veh).getPosition(), static_cast<MSVehicle&>(veh).getLane()->getID(), veh.getPositionOnLane()));
371  return true;
372 }
373 
374 
375 bool
377  if (sVehicles.find(veh.getID()) == sVehicles.end()) {
378  WRITE_WARNING("btreceiver: Can not update position of a vehicle that is not within the road network (" + veh.getID() + ").");
379  return true;
380  }
381  sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(newSpeed, static_cast<MSVehicle&>(veh).getPosition(), static_cast<MSVehicle&>(veh).getLane()->getID(), newPos));
382  return true;
383 }
384 
385 
386 bool
389  return true;
390  }
391  if (sVehicles.find(veh.getID()) == sVehicles.end()) {
392  WRITE_WARNING("btreceiver: Can not update position of a vehicle that is not within the road network (" + veh.getID() + ").");
393  return true;
394  }
395  sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(veh.getSpeed(), static_cast<MSVehicle&>(veh).getPosition(), static_cast<MSVehicle&>(veh).getLane()->getID(), veh.getPositionOnLane()));
397  sVehicles[veh.getID()]->amOnNet = false;
398  }
399  if (reason >= MSMoveReminder::NOTIFICATION_ARRIVED) {
400  sVehicles[veh.getID()]->amOnNet = false;
401  sVehicles[veh.getID()]->haveArrived = true;
402  }
403  return true;
404 }
405 
406 
407 
408 
409 
410 /****************************************************************************/
411 
bool amOnNet
Whether the vehicle is within the simulated network.
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
Definition: NamedRTree.h:90
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:84
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:257
double rand()
Position position
The position of the vehicle.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:78
SUMOReal lanePos
The position at the lane of the vehicle.
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
std::string laneID
The lane the vehicle was at.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:112
Notification
Definition of a vehicle state.
A RT-tree for efficient storing of SUMO&#39;s Named objects.
Definition: NamedRTree.h:72
std::vector< MeetingPoint * > recognitionPoints
List of recognition points.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:156
T MAX2(T a, T b)
Definition: StdDefs.h:74
static MTRand sRecognitionRNG
A random number generator used to determine whether the opposite was recognized.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:229
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, Notification reason)
Moves (the known) vehicle from running to arrived vehicles&#39; list.
SUMOReal lastView
Last recognition point.
Boundary getBoxBoundary() const
Returns the boundary of passed positions.
#define TS
Definition: SUMOTime.h:52
static void FindLineCircleIntersections(const Position &c, SUMOReal radius, const Position &p1, const Position &p2, std::vector< SUMOReal > &into)
Returns the positions the given circle is crossed by the given line.
Definition: GeomHelper.cpp:158
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:118
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
const MSLane * getLane() const
Returns the lane the reminder works on.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
MSDevice_BTreceiver(SUMOVehicle &holder, const std::string &id)
Constructor.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
#define SIMTIME
Definition: SUMOTime.h:96
std::map< std::string, std::vector< SeenDevice * > > seen
The past episodes of removed vehicle.
static SUMOReal myRange
The range of the device.
const std::string & getID() const
Returns the id.
Definition: Named.h:60
Class representing a single seen device.
Representation of a vehicle.
Definition: SUMOVehicle.h:64
static bool myWasInitialised
Whether the bt-system was already initialised.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A single movement state of the vehicle.
bool haveArrived
Whether the vehicle was removed from the simulation.
void writeOutput(const std::string &id, const std::map< std::string, std::vector< SeenDevice * > > &seen, bool allRecognitions)
Writes the output.
The vehicle arrived at its destination (is deleted)
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
SUMOReal speed
The speed of the vehicle.
bool notifyEnter(SUMOVehicle &veh, Notification reason)
Adds the vehicle to running vehicles if it (re-) enters the network.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc)
Adds common command options that allow to assign devices to vehicles.
Definition: MSDevice.cpp:84
#define POSITION_EPS
Definition: config.h:189
~MSDevice_BTreceiver()
Destructor.
SUMOTime execute(SUMOTime currentTime)
Performs the update.
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived receivers.
virtual SUMOTime addEvent(Command *operation, SUMOTime execTimeStep, AdaptType type)
Adds an Event.
Stores the information of a vehicle.
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition: MSNet.h:364
Abstract in-vehicle device.
Definition: MSDevice.h:69
Holds the information about exact positions/speeds/time of the begin/end of a meeting.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, SUMOVehicle &v)
Determines whether a vehicle should get a certain device.
Definition: MSDevice.cpp:98
Allows to store the object; used as context while traveling the rtree in TraCI.
Definition: Named.h:92
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:200
The vehicle has departed (was inserted into the network)
virtual SUMOReal getSpeed() const =0
Returns the vehicle&#39;s current speed.
void addRecognitionPoint(const SUMOReal tEnd, const Position &thisPos, const SUMOReal thisSpeed, const std::string &thisLaneID, const SUMOReal thisLanePos, const Position &otherPos, const SUMOReal otherSpeed, const std::string &otherLaneID, const SUMOReal otherLanePos, SeenDevice *otherDevice) const
Adds a point of recognition.
void enterRange(SUMOReal atOffset, const Position &thisPos, SUMOReal thisSpeed, const std::string &thisLaneID, SUMOReal thisLanePos, const std::string &otherID, const Position &otherPos, SUMOReal otherSpeed, const std::string &otherLaneID, SUMOReal otherLanePos, std::map< std::string, SeenDevice * > &currentlySeen)
Informs the receiver about a sender entering it&#39;s radius.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
std::map< std::string, SeenDevice * > currentlySeen
The map of devices seen by the vehicle at removal time.
void seed(const uint32 oneSeed)
std::vector< VehicleState > updates
List of position updates during last step.
static SUMOReal myOffTime
The offtime of the device.
A storage for options typed value containers)
Definition: OptionsCont.h:108
int SUMOTime
Definition: SUMOTime.h:43
const SUMOReal range
Recognition range of the vehicle.
Patch the time in a way that it is at least as high as the simulation begin time. ...
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
bool closeTag()
Closes the most recently opened tag.
#define SUMOReal
Definition: config.h:218
Stores the information of a vehicle.
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
#define DELTA_T
Definition: SUMOTime.h:50
void updateVisibility(VehicleInformation &receiver, MSDevice_BTsender::VehicleInformation &sender)
Rechecks the visibility for a given receiver/sender pair.
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived senders.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
Definition: NamedRTree.h:123
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into)
Build devices for the given vehicle, if needed.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTreceiver-options.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
void leaveRange(std::map< std::string, SeenDevice * > &currentlySeen, std::map< std::string, std::vector< SeenDevice * > > &seen, const Position &thisPos, SUMOReal thisSpeed, const std::string &thisLaneID, SUMOReal thisLanePos, const std::string &otherID, const Position &otherPos, SUMOReal otherSpeed, const std::string &otherLaneID, SUMOReal otherLanePos, SUMOReal tOffset)
Removes the sender from the currently seen devices to past episodes.
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
The vehicle is being teleported.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.