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 
int getRoutePosition() const
Definition: MSVehicle.cpp:1180
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:82
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:75
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:131
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:125
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&#39;s radius.
Position position
The position of the vehicle.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
long long int SUMOTime
Definition: SUMOTime.h:35
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
void writeOutput(const std::string &id, const std::map< std::string, std::vector< SeenDevice *> > &seen, bool allRecognitions)
Writes the output.
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:561
int routePos
The position in the route of the vehicle.
The vehicle arrived at a junction.
std::string laneID
The lane the vehicle was at.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:60
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
Notification
Definition of a vehicle state.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
A RT-tree for efficient storing of SUMO&#39;s Named objects.
Definition: NamedRTree.h:64
std::vector< MeetingPoint * > recognitionPoints
List of recognition points.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice *> &into)
Build devices for the given vehicle, if needed.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
double lastView
Last recognition point.
const std::string & getID() const
Returns the id.
Definition: Named.h:77
#define TS
Definition: SUMOTime.h:44
double lanePos
The position at the lane of the vehicle.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
MSDevice_BTreceiver(SUMOVehicle &holder, const std::string &id)
Constructor.
ConstMSEdgeVector route
List of edges travelled.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
#define SIMTIME
Definition: SUMOTime.h:64
std::map< std::string, std::vector< SeenDevice * > > seen
The past episodes of removed vehicle.
static double inquiryDelaySlots(const int backoffLimit)
static std::mt19937 sRecognitionRNG
A random number generator used to determine whether the opposite was recognized.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
Class representing a single seen device.
double nextView
Next possible recognition point.
Representation of a vehicle.
Definition: SUMOVehicle.h:61
static bool myWasInitialised
Whether the bt-system was already initialised.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
A single movement state of the vehicle.
bool haveArrived
Whether the vehicle was removed from the simulation.
The vehicle arrived at its destination (is deleted)
static double sd[6]
Definition: odrSpiral.cpp:52
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
#define STEPS2TIME(x)
Definition: SUMOTime.h:57
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:119
#define POSITION_EPS
Definition: config.h:169
~MSDevice_BTreceiver()
Destructor.
SUMOTime execute(SUMOTime currentTime)
Performs the update.
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
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
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.
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
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
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:440
Holds the information about exact positions/speeds/time of the begin/end of a meeting.
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
Allows to store the object; used as context while traveling the rtree in TraCI.
Definition: Named.h:93
The vehicle has departed (was inserted into the network)
Representation of a vehicle or person.
double speed
The speed of the vehicle.
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
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.
std::vector< VehicleState > updates
List of position updates during last step.
A storage for options typed value containers)
Definition: OptionsCont.h:90
Abstract in-vehicle device.
virtual double getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:234
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Stores the information of a vehicle.
static double myRange
The range of the device.
const double range
Recognition range of the vehicle.
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.
static double myOffTime
The offtime of the device.
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:137
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTreceiver-options.
virtual double getSpeed() const =0
Returns the vehicle&#39;s current speed.
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
Boundary getBoxBoundary() const
Returns the boundary of passed positions.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
void addRecognitionPoint(const double tEnd, const MSDevice_BTsender::VehicleState &receiverState, const MSDevice_BTsender::VehicleState &senderState, SeenDevice *senderDevice) const
Adds a point of recognition.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Moves (the known) vehicle from running to arrived vehicles&#39; list.
The vehicle is being teleported.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
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.