Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDevice_BTreceiver.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2013-2026 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
24#include <algorithm>
25
30#include <utils/geom/Position.h>
32#include <microsim/MSNet.h>
33#include <microsim/MSLane.h>
34#include <microsim/MSEdge.h>
35#include <microsim/MSVehicle.h>
39#include "MSDevice_Tripinfo.h"
40#include "MSDevice_BTreceiver.h"
41#include "MSDevice_BTsender.h"
42
43
44// ===========================================================================
45// static members
46// ===========================================================================
52std::map<std::string, MSDevice_BTreceiver::VehicleInformation*> MSDevice_BTreceiver::sVehicles;
53
54
55// ===========================================================================
56// method definitions
57// ===========================================================================
58// ---------------------------------------------------------------------------
59// static initialisation methods
60// ---------------------------------------------------------------------------
61
62void
64 insertDefaultAssignmentOptions("btreceiver", "Communication", oc);
65
66 oc.doRegister("device.btreceiver.range", new Option_Float(300));
67 oc.addDescription("device.btreceiver.range", "Communication", TL("The range of the bt receiver"));
68
69 oc.doRegister("device.btreceiver.all-recognitions", new Option_Bool(false));
70 oc.addDescription("device.btreceiver.all-recognitions", "Communication", TL("Whether all recognition point shall be written"));
71
72 oc.doRegister("device.btreceiver.offtime", new Option_Float(0.64));
73 oc.addDescription("device.btreceiver.offtime", "Communication", TL("The offtime used for calculating detection probability (in seconds)"));
74
75 myWasInitialised = false;
76 myHasPersons = false;
77}
78
79
80void
81MSVehicleDevice_BTreceiver::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into) {
83 if (equippedByDefaultAssignmentOptions(oc, "btreceiver", v, false)) {
84 MSVehicleDevice_BTreceiver* device = new MSVehicleDevice_BTreceiver(v, "btreceiver_" + v.getID());
85 into.push_back(device);
86 if (!myWasInitialised) {
87 new BTreceiverUpdate();
88 myWasInitialised = true;
89 myRange = oc.getFloat("device.btreceiver.range");
90 myOffTime = oc.getFloat("device.btreceiver.offtime");
91 sRecognitionRNG.seed(oc.getInt("seed"));
92 }
93 }
94}
95
96void
100
101
102void
103MSTransportableDevice_BTreceiver::buildDevices(MSTransportable& t, std::vector<MSTransportableDevice*>& into) {
105 if (equippedByDefaultAssignmentOptions(oc, "btreceiver", t, false, true)) {
106 MSTransportableDevice_BTreceiver* device = new MSTransportableDevice_BTreceiver(t, "btreceiver_" + t.getID());
107 into.push_back(device);
108 myHasPersons = true;
109 if (!myWasInitialised) {
110 new BTreceiverUpdate();
111 myWasInitialised = true;
112 myRange = oc.getFloat("device.btreceiver.range");
113 myOffTime = oc.getFloat("device.btreceiver.offtime");
114 sRecognitionRNG.seed(oc.getInt("seed"));
115 }
116 }
117}
118
119
120// ---------------------------------------------------------------------------
121// MSDevice_BTreceiver::BTreceiverUpdate-methods
122// ---------------------------------------------------------------------------
126
127
129 for (const auto& vehicleInfo : MSDevice_BTsender::sVehicles) {
130 vehicleInfo.second->amOnNet = false;
131 vehicleInfo.second->haveArrived = true;
132 }
133 for (const auto& vehicleInfo : MSDevice_BTreceiver::sVehicles) {
134 vehicleInfo.second->amOnNet = false;
135 vehicleInfo.second->haveArrived = true;
136 }
137 execute(MSNet::getInstance()->getCurrentTimeStep());
138}
139
140
143 // loop over equipped persons to update their positions
144 if (myHasPersons && MSNet::getInstance()->hasPersons()) { // the check whether the net has persons is only important in the final cleanup
146 for (MSTransportableControl::constVehIt i = c.loadedBegin(); i != c.loadedEnd(); ++i) {
147 MSTransportable* t = i->second;
151 if (snd) {
152 snd->notifyMove(*t, t->getPositionOnLane(), t->getPositionOnLane(), t->getSpeed());
153 if (MSDevice_BTsender::sVehicles[t->getID()]->route.back() != t->getEdge()) {
154 MSDevice_BTsender::sVehicles[t->getID()]->route.push_back(t->getEdge());
155 }
156 }
157 if (rec) {
158 rec->notifyMove(*t, t->getPositionOnLane(), t->getPositionOnLane(), t->getSpeed());
159 if (sVehicles[t->getID()]->route.back() != t->getEdge()) {
160 sVehicles[t->getID()]->route.push_back(t->getEdge());
161 }
162 }
163 }
164 }
165 }
166
167 // build rtree with senders
168 NamedRTree rt;
169 for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::const_iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end(); ++i) {
171 Boundary b = vi->getBoxBoundary();
172 b.grow(POSITION_EPS);
173 const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
174 const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
175 rt.Insert(cmin, cmax, vi);
176 }
177
178 // check visibility for all receivers
180 bool allRecognitions = oc.getBool("device.btreceiver.all-recognitions");
181 bool haveOutput = oc.isSet("bt-output");
182 for (std::map<std::string, MSDevice_BTreceiver::VehicleInformation*>::iterator i = MSDevice_BTreceiver::sVehicles.begin(); i != MSDevice_BTreceiver::sVehicles.end();) {
183 // collect surrounding vehicles
185 Boundary b = vi->getBoxBoundary();
186 b.grow(vi->range);
187 const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
188 const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
189 std::set<const Named*> surroundingVehicles;
190 Named::StoringVisitor sv(surroundingVehicles);
191 rt.Search(cmin, cmax, sv);
192 // in id order, since the visibility checks draw from the recognition RNG
193 std::vector<const Named*> sortedVehicles(surroundingVehicles.begin(), surroundingVehicles.end());
194 std::sort(sortedVehicles.begin(), sortedVehicles.end(), ComparatorIdLess());
195
196 // loop over surrounding vehicles, check visibility status
197 for (const Named* vehicle : sortedVehicles) {
198 if ((*i).first == vehicle->getID()) {
199 // seeing oneself? skip
200 continue;
201 }
202 updateVisibility(*vi, *MSDevice_BTsender::sVehicles.find(vehicle->getID())->second);
203 }
204
205 if (vi->haveArrived) {
206 // vehicle has left the simulation; remove
207 if (haveOutput) {
208 writeOutput((*i).first, vi->seen, allRecognitions);
209 }
210 delete vi;
212 } else {
213 // vehicle is still in the simulation; reset state
214 vi->updates.erase(vi->updates.begin(), vi->updates.end() - 1);
215 ++i;
216 }
217 }
218
219 // remove arrived senders / reset state
220 for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end();) {
222 if (vi->haveArrived) {
223 delete vi;
225 } else {
226 vi->updates.erase(vi->updates.begin(), vi->updates.end() - 1);
227 ++i;
228 }
229 }
230 return DELTA_T;
231}
232
233
234void
237 const MSDevice_BTsender::VehicleState& receiverData = receiver.updates.back();
238 const MSDevice_BTsender::VehicleState& senderData = sender.updates.back();
239 if (!receiver.amOnNet || !sender.amOnNet) {
240 // at least one of the vehicles has left the simulation area for any reason
241 if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
242 leaveRange(receiver, receiverData, sender, senderData, 0);
243 }
244 }
245
246 const Position& oldReceiverPosition = receiver.updates.front().position;
247 const Position& oldSenderPosition = sender.updates.front().position;
248
249 // let the other's current position be the one obtained by applying the relative direction vector to the initial position
250 const Position senderDelta = senderData.position - oldSenderPosition;
251 const Position receiverDelta = receiverData.position - oldReceiverPosition;
252 const Position translatedSender = senderData.position - receiverDelta;
253 // find crossing points
254 std::vector<double> intersections;
255 GeomHelper::findLineCircleIntersections(oldReceiverPosition, receiver.range, oldSenderPosition, translatedSender, intersections);
256 switch (intersections.size()) {
257 case 0:
258 // no intersections -> other vehicle either stays within or beyond range
259 if (receiver.amOnNet && sender.amOnNet && receiverData.position.distanceTo(senderData.position) < receiver.range) {
260 if (receiver.currentlySeen.find(sender.getID()) == receiver.currentlySeen.end()) {
261 enterRange(0., receiverData, sender.getID(), senderData, receiver.currentlySeen);
262 } else {
263 addRecognitionPoint(SIMTIME, receiverData, senderData, receiver.currentlySeen[sender.getID()]);
264 }
265 } else {
266 if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
267 leaveRange(receiver, receiverData, sender, senderData, 0.);
268 }
269 }
270 break;
271 case 1: {
272 // one intersection -> other vehicle either enters or leaves the range
273 MSDevice_BTsender::VehicleState intersection1ReceiverData(receiverData);
274 intersection1ReceiverData.position = oldReceiverPosition + receiverDelta * intersections.front();
275 MSDevice_BTsender::VehicleState intersection1SenderData(senderData);
276 intersection1SenderData.position = oldSenderPosition + senderDelta * intersections.front();
277 if (receiver.currentlySeen.find(sender.getID()) != receiver.currentlySeen.end()) {
278 leaveRange(receiver, intersection1ReceiverData,
279 sender, intersection1SenderData, (intersections.front() - 1.) * TS);
280 } else {
281 enterRange((intersections.front() - 1.) * TS, intersection1ReceiverData,
282 sender.getID(), intersection1SenderData, receiver.currentlySeen);
283 }
284 }
285 break;
286 case 2:
287 // two intersections -> other vehicle enters and leaves the range
288 if (receiver.currentlySeen.find(sender.getID()) == receiver.currentlySeen.end()) {
289 MSDevice_BTsender::VehicleState intersectionReceiverData(receiverData);
290 intersectionReceiverData.position = oldReceiverPosition + receiverDelta * intersections.front();
291 MSDevice_BTsender::VehicleState intersectionSenderData(senderData);
292 intersectionSenderData.position = oldSenderPosition + senderDelta * intersections.front();
293 enterRange((intersections.front() - 1.) * TS, intersectionReceiverData,
294 sender.getID(), intersectionSenderData, receiver.currentlySeen);
295 intersectionReceiverData.position = oldReceiverPosition + receiverDelta * intersections.back();
296 intersectionSenderData.position = oldSenderPosition + senderDelta * intersections.back();
297 leaveRange(receiver, intersectionReceiverData,
298 sender, intersectionSenderData, (intersections.back() - 1.) * TS);
299 } else {
300 WRITE_WARNINGF(TL("The vehicle '%' cannot be in the range of vehicle '%', leave, and enter it in one step."), sender.getID(), receiver.getID());
301 }
302 break;
303 default:
304 WRITE_WARNING("Nope, a circle cannot be crossed more often than twice by a line.");
305 break;
306 }
307}
308
309
310void
312 const std::string& senderID, const MSDevice_BTsender::VehicleState& senderState,
313 std::map<std::string, SeenDevice*>& currentlySeen) {
314 MeetingPoint mp(SIMTIME + atOffset, receiverState, senderState);
315 SeenDevice* sd = new SeenDevice(mp);
316 currentlySeen[senderID] = sd;
317 addRecognitionPoint(SIMTIME, receiverState, senderState, sd);
318}
319
320
321void
324 double tOffset) {
325 std::map<std::string, SeenDevice*>::iterator i = receiverInfo.currentlySeen.find(senderInfo.getID());
326 // check whether the other was recognized
327 addRecognitionPoint(SIMTIME + tOffset, receiverState, senderState, i->second);
328 // build leaving point
329 i->second->meetingEnd = new MeetingPoint(STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()) + tOffset, receiverState, senderState);
330 ConstMSEdgeVector::const_iterator begin = receiverInfo.route.begin() + i->second->meetingBegin.observerState.routePos;
331 ConstMSEdgeVector::const_iterator end = receiverInfo.route.begin() + receiverState.routePos + 1;
332 i->second->receiverRoute = toString<const MSEdge>(begin, end);
333 begin = senderInfo.route.begin() + i->second->meetingBegin.seenState.routePos;
334 end = senderInfo.route.begin() + senderState.routePos + 1;
335 i->second->senderRoute = toString<const MSEdge>(begin, end);
336 receiverInfo.seen[senderInfo.getID()].push_back(i->second);
337 receiverInfo.currentlySeen.erase(i);
338}
339
340
341void
343 const MSDevice_BTsender::VehicleState& senderState,
344 SeenDevice* senderDevice) const {
345 if (senderDevice->nextView == -1.) {
346 senderDevice->nextView = senderDevice->lastView + inquiryDelaySlots(int(myOffTime / 0.000625 + .5)) * 0.000625;
347 }
348 if (tEnd > senderDevice->nextView) {
349 senderDevice->lastView = senderDevice->nextView;
350 MeetingPoint* mp = new MeetingPoint(tEnd, receiverState, senderState);
351 senderDevice->recognitionPoints.push_back(mp);
352 senderDevice->nextView = senderDevice->lastView + inquiryDelaySlots(int(myOffTime / 0.000625 + .5)) * 0.000625;
353 }
354}
355
356
357void
358MSDevice_BTreceiver::BTreceiverUpdate::writeOutput(const std::string& id, const std::map<std::string, std::vector<SeenDevice*> >& seen, bool allRecognitions) {
360 os.openTag("bt").writeAttr("id", id);
361 for (const auto& item : seen) {
362 for (const SeenDevice* const device : item.second) {
363 os.openTag("seen").writeAttr("id", item.first);
364 const MSDevice_BTsender::VehicleState& obsBeg = device->meetingBegin.observerState;
365 const MSDevice_BTsender::VehicleState& seenBeg = device->meetingBegin.seenState;
366 os.writeAttr("tBeg", device->meetingBegin.t)
367 .writeAttr("observerPosBeg", obsBeg.position).writeAttr("observerSpeedBeg", obsBeg.speed)
368 .writeAttr("observerLaneIDBeg", obsBeg.laneID).writeAttr("observerLanePosBeg", obsBeg.lanePos)
369 .writeAttr("seenPosBeg", seenBeg.position).writeAttr("seenSpeedBeg", seenBeg.speed)
370 .writeAttr("seenLaneIDBeg", seenBeg.laneID).writeAttr("seenLanePosBeg", seenBeg.lanePos);
371 const MSDevice_BTsender::VehicleState& obsEnd = device->meetingEnd->observerState;
372 const MSDevice_BTsender::VehicleState& seenEnd = device->meetingEnd->seenState;
373 os.writeAttr("tEnd", device->meetingEnd->t)
374 .writeAttr("observerPosEnd", obsEnd.position).writeAttr("observerSpeedEnd", obsEnd.speed)
375 .writeAttr("observerLaneIDEnd", obsEnd.laneID).writeAttr("observerLanePosEnd", obsEnd.lanePos)
376 .writeAttr("seenPosEnd", seenEnd.position).writeAttr("seenSpeedEnd", seenEnd.speed)
377 .writeAttr("seenLaneIDEnd", seenEnd.laneID).writeAttr("seenLanePosEnd", seenEnd.lanePos)
378 .writeAttr("observerRoute", device->receiverRoute).writeAttr("seenRoute", device->senderRoute);
379 for (const MeetingPoint* const mp : device->recognitionPoints) {
380 os.openTag("recognitionPoint").writeAttr("t", mp->t)
381 .writeAttr("observerPos", mp->observerState.position).writeAttr("observerSpeed", mp->observerState.speed)
382 .writeAttr("observerLaneID", mp->observerState.laneID).writeAttr("observerLanePos", mp->observerState.lanePos)
383 .writeAttr("seenPos", mp->seenState.position).writeAttr("seenSpeed", mp->seenState.speed)
384 .writeAttr("seenLaneID", mp->seenState.laneID).writeAttr("seenLanePos", mp->seenState.lanePos)
385 .closeTag();
386 if (!allRecognitions) {
387 break;
388 }
389 }
390 os.closeTag();
391 }
392 }
393 os.closeTag();
394}
395
396
397// ---------------------------------------------------------------------------
398// MSDevice_BTreceiver-methods
399// ---------------------------------------------------------------------------
402
403
404bool
406 if (reason == MSMoveReminder::NOTIFICATION_DEPARTED && sVehicles.find(veh.getID()) == sVehicles.end()) {
407 sVehicles[veh.getID()] = new VehicleInformation(veh.getID(), myRange);
408 sVehicles[veh.getID()]->route.push_back(veh.getEdge());
409 }
410 if (reason == MSMoveReminder::NOTIFICATION_TELEPORT && sVehicles.find(veh.getID()) != sVehicles.end()) {
411 sVehicles[veh.getID()]->amOnNet = true;
412 }
414 sVehicles[veh.getID()]->route.push_back(veh.getEdge());
415 }
416 const std::string location = MSDevice_BTsender::getLocation(veh);
417 sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(veh.getSpeed(), veh.getPosition(), location, veh.getPositionOnLane(), veh.getRoutePosition()));
418 return true;
419}
420
421
422bool
423MSDevice_BTreceiver::notifyMove(SUMOTrafficObject& veh, double /* oldPos */, double newPos, double newSpeed) {
424 if (sVehicles.find(veh.getID()) == sVehicles.end()) {
425 WRITE_WARNINGF(TL("btreceiver: Can not update position of vehicle '%' which is not on the road."), veh.getID());
426 return true;
427 }
428 const std::string location = MSDevice_BTsender::getLocation(veh);
429 sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(newSpeed, veh.getPosition(), location, newPos, veh.getRoutePosition()));
430 return true;
431}
432
433
434bool
435MSDevice_BTreceiver::notifyLeave(SUMOTrafficObject& veh, double /* lastPos */, MSMoveReminder::Notification reason, const MSLane* /* enteredLane */) {
437 return true;
438 }
439 if (sVehicles.find(veh.getID()) == sVehicles.end()) {
440 WRITE_WARNINGF(TL("btreceiver: Can not update position of vehicle '%' which is not on the road."), veh.getID());
441 return true;
442 }
443 const std::string location = MSDevice_BTsender::getLocation(veh);
444 sVehicles[veh.getID()]->updates.push_back(MSDevice_BTsender::VehicleState(veh.getSpeed(), veh.getPosition(), location, veh.getPositionOnLane(), veh.getRoutePosition()));
446 sVehicles[veh.getID()]->amOnNet = false;
447 }
449 sVehicles[veh.getID()]->amOnNet = false;
450 sVehicles[veh.getID()]->haveArrived = true;
451 }
452 return true;
453}
454
455
456double
458 const int phaseOffset = RandHelper::rand(2047, &sRecognitionRNG);
459 const bool interlaced = RandHelper::rand(&sRecognitionRNG) < 0.7;
460 const double delaySlots = RandHelper::rand(&sRecognitionRNG) * 15;
461 const int backoff = RandHelper::rand(backoffLimit, &sRecognitionRNG);
462 if (interlaced) {
463 return RandHelper::rand(&sRecognitionRNG) * 31 + backoff;
464 }
465 if (RandHelper::rand(31, &sRecognitionRNG) < 16) {
466 // correct train for f0
467 return delaySlots + backoff;
468 }
469 if (RandHelper::rand(30, &sRecognitionRNG) < 16) {
470 // correct train for f1
471 return 2048 - phaseOffset + delaySlots + backoff;
472 }
473 if (RandHelper::rand(29, &sRecognitionRNG) < 16) {
474 // f2 is in train A but has overlap with both trains
475 if (2 * 2048 - phaseOffset + backoff < 4096) {
476 return 2 * 2048 - phaseOffset + delaySlots + backoff;
477 }
478 // the following is wrong but should only happen in about 3% of the non-interlaced cases
479 return 2 * 2048 - phaseOffset + delaySlots + backoff;
480 }
481 return 2 * 2048 + delaySlots + backoff;
482}
483
484
485/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:299
#define WRITE_WARNING(msg)
Definition MsgHandler.h:298
#define TL(string)
Definition MsgHandler.h:316
SUMOTime DELTA_T
Definition SUMOTime.cpp:39
#define STEPS2TIME(x)
Definition SUMOTime.h:58
#define TS
Definition SUMOTime.h:45
#define SIMTIME
Definition SUMOTime.h:70
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:127
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:115
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:133
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:121
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.
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 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 std::map< std::string, VehicleInformation * > sVehicles
The list of arrived receivers.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Adds the vehicle to running vehicles if it (re-) enters the network.
static bool myHasPersons
Whether the bt-system includes persons.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::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::string getLocation(const SUMOTrafficObject &o)
return either lane or edge id (depending on availability)
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
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:181
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:213
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
Representation of a lane in the micro simulation.
Definition MSLane.h:84
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:201
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition MSNet.h:506
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition MSNet.cpp:1317
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
std::map< std::string, MSTransportable * >::const_iterator constVehIt
Definition of the internal transportables map iterator.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTreceiver-options.
static void buildDevices(MSTransportable &t, std::vector< MSTransportableDevice * > &into)
Build devices for the given vehicle, if needed.
double getPositionOnLane() const override
Get the object's position along the lane.
virtual double getSpeed() const override
the current speed of the transportable
MSDevice * getDevice(const std::type_info &type) const override
Returns a device of the given type if it exists or nullptr if not.
MSStageType getCurrentStageType() const
the current stage type of the transportable
const MSEdge * getEdge() const override
Returns the current edge.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_BTreceiver-options.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
Allows to store the object; used as context while traveling the rtree in TraCI.
Definition Named.h:89
Base class for objects which have an id.
Definition Named.h:53
const std::string & getID() const
Returns the id.
Definition Named.h:73
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:92
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
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)
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
void doRegister(const std::string &name, Option *o)
Adds an option under the given name.
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.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute
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 dimensions
Definition Position.h:263
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
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 int getRoutePosition() const =0
return index of edge within route
virtual const MSEdge * getEdge() const =0
Returns the (normal) route 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:63
static double sd[6]
Definition odrSpiral.cpp:57
Function-object for stable sorting of objects acting like Named without being derived (SUMOVehicle)
Definition Named.h:29