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-sim.org/
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 // ===========================================================================
57 std::map<std::string, MSDevice_BTreceiver::VehicleInformation*> MSDevice_BTreceiver::sVehicles;
58 
59 
60 // ===========================================================================
61 // method definitions
62 // ===========================================================================
63 // ---------------------------------------------------------------------------
64 // static initialisation methods
65 // ---------------------------------------------------------------------------
66 void
68  insertDefaultAssignmentOptions("btreceiver", "Communication", oc);
69 
70  oc.doRegister("device.btreceiver.range", new Option_Float(300));
71  oc.addDescription("device.btreceiver.range", "Communication", "The range of the bt receiver");
72 
73  oc.doRegister("device.btreceiver.all-recognitions", new Option_Bool(false));
74  oc.addDescription("device.btreceiver.all-recognitions", "Communication", "Whether all recognition point shall be written");
75 }
76 
77 
78 void
79 MSDevice_BTreceiver::buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into) {
81  if (equippedByDefaultAssignmentOptions(oc, "btreceiver", v)) {
82  MSDevice_BTreceiver* device = new MSDevice_BTreceiver(v, "btreceiver_" + v.getID(), oc.getFloat("device.btreceiver.range"));
83  into.push_back(device);
84  if (!myWasInitialised) {
85  new BTreceiverUpdate();
86  myWasInitialised = true;
87  sRecognitionRNG.seed(oc.getInt("seed"));
88  }
89  }
90 }
91 
92 
93 // ---------------------------------------------------------------------------
94 // MSDevice_BTreceiver::BTreceiverUpdate-methods
95 // ---------------------------------------------------------------------------
98 }
99 
100 
102  for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::const_iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end(); ++i) {
103  (*i).second->amOnNet = false;
104  (*i).second->haveArrived = true;
105  }
106  for (std::map<std::string, MSDevice_BTreceiver::VehicleInformation*>::const_iterator i = MSDevice_BTreceiver::sVehicles.begin(); i != MSDevice_BTreceiver::sVehicles.end(); ++i) {
107  (*i).second->amOnNet = false;
108  (*i).second->haveArrived = true;
109  }
110  execute(MSNet::getInstance()->getCurrentTimeStep());
111 }
112 
113 
114 SUMOTime
116  // build rtree with senders
117  NamedRTree rt;
118  for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::const_iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end(); ++i) {
119  MSDevice_BTsender::VehicleInformation* vi = (*i).second;
120  Boundary b = vi->getBoxBoundary();
121  b.grow(3.);
122  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
123  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
124  rt.Insert(cmin, cmax, vi);
125  }
126 
127  // check visibility for all receivers
129  bool allRecognitions = oc.getBool("device.btreceiver.all-recognitions");
130  bool haveOutput = oc.isSet("bt-output");
131  for (std::map<std::string, MSDevice_BTreceiver::VehicleInformation*>::iterator i = MSDevice_BTreceiver::sVehicles.begin(); i != MSDevice_BTreceiver::sVehicles.end();) {
132  // compute own direction vector
133  MSDevice_BTreceiver::VehicleState& state = (*i).second->updates.back();
134  Position egoPosition = state.position;
135  SUMOReal angle = state.angle * M_PI / 180.;
136  SUMOReal speed = state.speed;
137  SUMOReal dist = SPEED2DIST(speed);
138  Position egoP2 = egoPosition;
139  Position egoP1(egoP2.x() - sin(angle)*dist, egoP2.y() + cos(angle)*dist);
140  Position egoD = egoP2 - egoP1;
141 
142  // collect surrounding vehicles
143  MSDevice_BTreceiver::VehicleInformation* vi = (*i).second;
144  Boundary b = vi->getBoxBoundary();
145  b.grow(vi->range + 500 / 3.6); // two vehicles passing at 250*2 km/h
146  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
147  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
148  std::set<std::string> surroundingVehicles;
149  Named::StoringVisitor sv(surroundingVehicles);
150  rt.Search(cmin, cmax, sv);
151 
152  // loop over surrounding vehicles, check visibility status
153  for (std::set<std::string>::const_iterator j = surroundingVehicles.begin(); j != surroundingVehicles.end(); ++j) {
154  if ((*i).first == *j) {
155  // seeing oneself? skip
156  continue;
157  }
158  updateVisibility(*vi, *MSDevice_BTsender::sVehicles.find(*j)->second, egoP1, egoD);
159  }
160 
161  if (vi->haveArrived) {
162  // vehicle has left the simulation; remove
163  if (haveOutput) {
164  writeOutput((*i).first, vi->seen, allRecognitions);
165  }
166  delete(*i).second;
168  } else {
169  // vehicle is still in the simulation; reset state
170  VehicleState last = (*i).second->updates.back();
171  (*i).second->updates.clear();
172  (*i).second->updates.push_back(last);
173  ++i;
174  }
175  }
176 
177  // remove arrived senders / reset state
178  for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end();) {
179  if ((*i).second->haveArrived) {
180  delete(*i).second;
181  MSDevice_BTsender::sVehicles.erase(i++);
182  } else {
183  MSDevice_BTsender::VehicleState last = (*i).second->updates.back();
184  (*i).second->updates.clear();
185  (*i).second->updates.push_back(last);
186  ++i;
187  }
188  }
189  return DELTA_T;
190 }
191 
192 
193 void
195  const Position& receiverStartPos, const Position& receiverD) {
196  Position receiverPos = receiver.updates.back().position;
197  std::vector<SUMOReal> intersections;
198  if (!receiver.amOnNet || !sender.amOnNet) {
199  // at least one of the vehicles has left the simulation area for any reason
200  if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
201  leaveRange(receiver.currentlySeen, receiver.seen, receiverPos, receiver.updates.back().speed, receiver.updates.back().laneID, receiver.updates.back().lanePos,
202  sender.getID(), sender.updates.back().position, sender.updates.back().speed, sender.updates.back().laneID, sender.updates.back().lanePos, 0);
203  }
204  }
205 
206  // get the encountered vehicle's current and prior position (based on speed and direction)
207  Position otherPosition = sender.updates.back().position;
208  Position otherP2 = otherPosition;
209  const SUMOReal angle = sender.updates.back().angle * M_PI / 180.;
210  const SUMOReal speed = sender.updates.back().speed;
211  const SUMOReal dist = SPEED2DIST(speed);
212 
213  // let the other's current position be the one obtained by applying the relative direction vector to the initial position
214  Position otherP1(otherPosition.x() - sin(angle)*dist, otherPosition.y() + cos(angle)*dist);
215  Position otherD = otherP2 - otherP1;
216  otherP2 = otherP1 - receiverD + otherD;
217  // find crossing points
218  GeomHelper::FindLineCircleIntersections(receiverStartPos, receiver.range, otherP1, otherP2, intersections);
219  switch (intersections.size()) {
220  case 0:
221  // no intersections -> other vehicle either stays within or beyond range
222  if (receiver.amOnNet && sender.amOnNet && receiverPos.distanceTo(otherPosition) < receiver.range) {
223  if (receiver.currentlySeen.find(sender.getID()) == receiver.currentlySeen.end()) {
224  enterRange(0., receiverPos, receiver.updates.back().speed, receiver.updates.back().laneID, receiver.updates.back().lanePos,
225  sender.getID(), otherPosition, sender.updates.back().speed, sender.updates.back().laneID, sender.updates.back().lanePos, receiver.currentlySeen);
226  } else {
227  addRecognitionPoint(STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), receiverPos, receiver.updates.back().speed, receiver.updates.back().laneID, receiver.updates.back().lanePos,
228  otherPosition, sender.updates.back().speed, sender.updates.back().laneID, sender.updates.back().lanePos, receiver.currentlySeen[sender.getID()]);
229  }
230  } else {
231  if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
232  leaveRange(receiver.currentlySeen, receiver.seen, receiverPos, receiver.updates.back().speed, receiver.updates.back().laneID, receiver.updates.back().lanePos,
233  sender.getID(), otherPosition, sender.updates.back().speed, sender.updates.back().laneID, sender.updates.back().lanePos, 0.);
234  }
235  }
236  break;
237  case 1: {
238  // one intersection -> other vehicle either enters or leaves the range
239  Position intersection1Other = otherP1 + otherD * intersections.front();
240  Position intersection1Ego = receiverStartPos + receiverD * intersections.front();
241  if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
242  leaveRange(receiver.currentlySeen, receiver.seen, intersection1Ego, receiver.updates.back().speed, receiver.updates.back().laneID, receiver.updates.back().lanePos,
243  sender.getID(), intersection1Other, sender.updates.back().speed, sender.updates.back().laneID, sender.updates.back().lanePos, (intersections.front() - 1.) * TS);
244  } else {
245  enterRange((intersections.front() - 1.) * TS, intersection1Ego, receiver.updates.back().speed, receiver.updates.back().laneID, receiver.updates.back().lanePos,
246  sender.getID(), intersection1Other, sender.updates.back().speed, sender.updates.back().laneID, sender.updates.back().lanePos, receiver.currentlySeen);
247  }
248  }
249  break;
250  case 2:
251  // two intersections -> other vehicle enters and leaves the range
252  if (receiver.currentlySeen.find(sender.getID()) == receiver.currentlySeen.end()) {
253  Position intersection1Other = otherP1 + otherD * intersections.front();
254  Position intersection1Ego = receiverStartPos + receiverD * intersections.front();
255  enterRange((intersections.front() - 1.) * TS, intersection1Ego, receiver.updates.back().speed, receiver.updates.back().laneID, receiver.updates.back().lanePos,
256  sender.getID(), intersection1Other, sender.updates.back().speed, sender.updates.back().laneID, sender.updates.back().lanePos, receiver.currentlySeen);
257  Position intersection2Other = otherP1 + otherD * intersections[1];
258  Position intersection2Ego = receiverStartPos + receiverD * intersections[1];
259  leaveRange(receiver.currentlySeen, receiver.seen, intersection2Ego, receiver.updates.back().speed, receiver.updates.back().laneID, receiver.updates.back().lanePos,
260  sender.getID(), intersection2Other, sender.updates.back().speed, sender.updates.back().laneID, sender.updates.back().lanePos, (intersections.back() - 1.) * TS);
261  } else {
262  WRITE_WARNING("Nope, a vehicle cannot be in the range, leave, and enter it in one step.");
263  }
264  break;
265  default:
266  WRITE_WARNING("Nope, a circle cannot be crossed more often than twice by a line.");
267  break;
268  }
269 }
270 
271 
272 void
274  const Position& thisPos, SUMOReal thisSpeed, const std::string& thisLaneID, SUMOReal thisLanePos,
275  const std::string& otherID, const Position& otherPos, SUMOReal otherSpeed, const std::string& otherLaneID, SUMOReal otherLanePos,
276  std::map<std::string, SeenDevice*>& currentlySeen) {
277  MeetingPoint mp(STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()) + atOffset, thisPos, thisSpeed, thisLaneID, thisLanePos, otherPos, otherSpeed, otherLaneID, otherLanePos);
278  SeenDevice* sd = new SeenDevice(mp);
279  currentlySeen[otherID] = sd;
280  addRecognitionPoint(STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), thisPos, thisSpeed, thisLaneID, thisLanePos,
281  otherPos, otherSpeed, otherLaneID, otherLanePos, sd);
282 }
283 
284 
285 void
286 MSDevice_BTreceiver::BTreceiverUpdate::leaveRange(std::map<std::string, SeenDevice*>& currentlySeen, std::map<std::string, std::vector<SeenDevice*> >& seen,
287  const Position& thisPos, SUMOReal thisSpeed, const std::string& thisLaneID, SUMOReal thisLanePos,
288  const std::string& otherID, const Position& otherPos, SUMOReal otherSpeed, const std::string& otherLaneID, SUMOReal otherLanePos,
289  SUMOReal tOffset) {
290  std::map<std::string, SeenDevice*>::iterator i = currentlySeen.find(otherID);
291  // check whether the other was recognized
292  addRecognitionPoint(STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()) + tOffset, thisPos, thisSpeed, thisLaneID, thisLanePos,
293  otherPos, otherSpeed, otherLaneID, otherLanePos, (*i).second);
294  // build leaving point
295  MeetingPoint mp(STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()) + tOffset, thisPos, thisSpeed, thisLaneID, thisLanePos, otherPos, otherSpeed, otherLaneID, otherLanePos);
296  (*i).second->meetingEnd = mp;
297  if (seen.find(otherID) == seen.end()) {
298  seen[otherID] = std::vector<SeenDevice*>();
299  }
300  seen[otherID].push_back((*i).second);
301  currentlySeen.erase(i);
302 }
303 
304 
305 void
306 MSDevice_BTreceiver::BTreceiverUpdate::addRecognitionPoint(const SUMOReal tEnd, const Position& thisPos, const SUMOReal thisSpeed, const std::string& thisLaneID, const SUMOReal thisLanePos,
307  const Position& otherPos, const SUMOReal otherSpeed, const std::string& otherLaneID, const SUMOReal otherLanePos,
308  SeenDevice* otherDevice) const {
309  const SUMOReal t = tEnd - MAX2(STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()) - TS, otherDevice->lastView);
310  // probability of a miss 0.5 (may be in the wrong train), backoff time 0.64s
311  if (sRecognitionRNG.rand() <= 1 - pow(0.5, t / 0.64)) {
312  otherDevice->lastView = tEnd;
313  MeetingPoint* mp = new MeetingPoint(tEnd, thisPos, thisSpeed, thisLaneID, thisLanePos, otherPos, otherSpeed, otherLaneID, otherLanePos);
314  otherDevice->recognitionPoints.push_back(mp);
315  }
316 }
317 
318 
319 void
320 MSDevice_BTreceiver::BTreceiverUpdate::writeOutput(const std::string& id, const std::map<std::string, std::vector<SeenDevice*> >& seen, bool allRecognitions) {
322  os.openTag("bt").writeAttr("id", id);
323  for (std::map<std::string, std::vector<SeenDevice*> >::const_iterator j = seen.begin(); j != seen.end(); ++j) {
324  const std::vector<SeenDevice*>& sts = (*j).second;
325  for (std::vector<SeenDevice*>::const_iterator k = sts.begin(); k != sts.end(); ++k) {
326  os.openTag("seen").writeAttr("id", (*j).first);
327  os.writeAttr("tBeg", (*k)->meetingBegin.t)
328  .writeAttr("observerPosBeg", (*k)->meetingBegin.observerPos).writeAttr("observerSpeedBeg", (*k)->meetingBegin.observerSpeed)
329  .writeAttr("observerLaneIDBeg", (*k)->meetingBegin.observerLaneID).writeAttr("observerLanePosBeg", (*k)->meetingBegin.observerLanePos)
330  .writeAttr("seenPosBeg", (*k)->meetingBegin.seenPos).writeAttr("seenSpeedBeg", (*k)->meetingBegin.seenSpeed)
331  .writeAttr("seenLaneIDBeg", (*k)->meetingBegin.seenLaneID).writeAttr("seenLanePosBeg", (*k)->meetingBegin.seenLanePos);
332  os.writeAttr("tEnd", (*k)->meetingEnd.t)
333  .writeAttr("observerPosEnd", (*k)->meetingEnd.observerPos).writeAttr("observerSpeedEnd", (*k)->meetingEnd.observerSpeed)
334  .writeAttr("observerLaneIDEnd", (*k)->meetingEnd.observerLaneID).writeAttr("observerLanePosEnd", (*k)->meetingEnd.observerLanePos)
335  .writeAttr("seenPosEnd", (*k)->meetingEnd.seenPos).writeAttr("seenSpeedEnd", (*k)->meetingEnd.seenSpeed)
336  .writeAttr("seenLaneIDEnd", (*k)->meetingEnd.seenLaneID).writeAttr("seenLanePosEnd", (*k)->meetingEnd.seenLanePos);
337  for (std::vector<MeetingPoint*>::iterator l = (*k)->recognitionPoints.begin(); l != (*k)->recognitionPoints.end(); ++l) {
338  os.openTag("recognitionPoint").writeAttr("t", (*l)->t)
339  .writeAttr("observerPos", (*l)->observerPos).writeAttr("observerSpeed", (*l)->observerSpeed)
340  .writeAttr("observerLaneID", (*l)->observerLaneID).writeAttr("observerLanePos", (*l)->observerLanePos)
341  .writeAttr("seenPos", (*l)->seenPos).writeAttr("seenSpeed", (*l)->seenSpeed)
342  .writeAttr("seenLaneID", (*l)->seenLaneID).writeAttr("seenLanePos", (*l)->seenLanePos)
343  .closeTag();
344  if (!allRecognitions) {
345  break;
346  }
347  }
348  os.closeTag();
349  }
350  }
351  os.closeTag();
352 }
353 
354 
355 
356 
357 // ---------------------------------------------------------------------------
358 // MSDevice_BTreceiver-methods
359 // ---------------------------------------------------------------------------
360 MSDevice_BTreceiver::MSDevice_BTreceiver(SUMOVehicle& holder, const std::string& id, SUMOReal range)
361  : MSDevice(holder, id), myRange(range) {
362 }
363 
364 
366 }
367 
368 
369 bool
371  if (reason == MSMoveReminder::NOTIFICATION_DEPARTED && sVehicles.find(veh.getID()) == sVehicles.end()) {
372  sVehicles[veh.getID()] = new VehicleInformation(veh.getID(), myRange);
373  }
374  if (reason == MSMoveReminder::NOTIFICATION_TELEPORT && sVehicles.find(veh.getID()) != sVehicles.end()) {
375  sVehicles[veh.getID()]->amOnNet = true;
376  }
377  sVehicles[veh.getID()]->updates.push_back(VehicleState(
378  MSNet::getInstance()->getCurrentTimeStep(), veh.getSpeed(), static_cast<MSVehicle&>(veh).getAngle(), static_cast<MSVehicle&>(veh).getPosition(), static_cast<MSVehicle&>(veh).getLane()->getID(), veh.getPositionOnLane()
379  ));
380  return true;
381 }
382 
383 
384 bool
386  if (sVehicles.find(veh.getID()) == sVehicles.end()) {
387  WRITE_WARNING("btreceiver: Can not update position of a vehicle that is not within the road network (" + veh.getID() + ").");
388  return true;
389  }
390  sVehicles[veh.getID()]->updates.push_back(VehicleState(
391  MSNet::getInstance()->getCurrentTimeStep(), newSpeed, static_cast<MSVehicle&>(veh).getAngle(), static_cast<MSVehicle&>(veh).getPosition(), static_cast<MSVehicle&>(veh).getLane()->getID(), newPos
392  ));
393  return true;
394 }
395 
396 
397 bool
400  return true;
401  }
402  if (sVehicles.find(veh.getID()) == sVehicles.end()) {
403  WRITE_WARNING("btreceiver: Can not update position of a vehicle that is not within the road network (" + veh.getID() + ").");
404  return true;
405  }
406  sVehicles[veh.getID()]->updates.push_back(VehicleState(
407  MSNet::getInstance()->getCurrentTimeStep(), veh.getSpeed(), static_cast<MSVehicle&>(veh).getAngle(), static_cast<MSVehicle&>(veh).getPosition(), static_cast<MSVehicle&>(veh).getLane()->getID(), veh.getPositionOnLane()
408  ));
410  sVehicles[veh.getID()]->amOnNet = false;
411  }
412  if (reason >= MSMoveReminder::NOTIFICATION_ARRIVED) {
413  sVehicles[veh.getID()]->amOnNet = false;
414  sVehicles[veh.getID()]->haveArrived = true;
415  }
416  return true;
417 }
418 
419 
420 
421 
422 
423 /****************************************************************************/
424 
bool amOnNet
Whether the vehicle is within the simulated network.
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()
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
#define SPEED2DIST(x)
Definition: SUMOTime.h:55
void updateVisibility(VehicleInformation &receiver, MSDevice_BTsender::VehicleInformation &sender, const Position &receiverPos, const Position &receiverD)
Rechecks the visibility for a given receiver/sender pair.
void Insert(const float a_min[2], const float a_max[2], Named *a_data)
Insert entry.
Definition: NamedRTree.h:91
bool haveArrived
Whether the vehicle was removed from the simulation.
MSEventControl & getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition: MSNet.h:350
#define M_PI
Definition: angles.h:37
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle'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'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:159
T MAX2(T a, T b)
Definition: StdDefs.h:72
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' 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:153
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
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
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
std::map< std::string, std::vector< SeenDevice * > > seen
The past episodes of removed vehicle.
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.
void writeOutput(const std::string &id, const std::map< std::string, std::vector< SeenDevice * > > &seen, bool allRecognitions)
Writes the output.
Position position
The position of the vehicle.
The vehicle arrived at its destination (is deleted)
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
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
~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.
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's current speed.
Boundary getBoxBoundary() const
Returns the boundary of passed positions.
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'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.
std::vector< VehicleState > updates
List of position updates during last step.
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
A storage for options typed value containers)
Definition: OptionsCont.h:108
const SUMOReal range
Recognition range of the vehicle.
MSDevice_BTreceiver(SUMOVehicle &holder, const std::string &id, SUMOReal range)
Constructor.
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:215
Stores the information of a vehicle.
SUMOReal speed
The speed of the vehicle.
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
bool amOnNet
Whether the vehicle is within the simulated network.
#define DELTA_T
Definition: SUMOTime.h:50
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:124
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's ID.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
SUMOReal angle
The angle of the vehicle.
The vehicle is being teleported.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.