 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
61 oc.
addDescription(
"device.btreceiver.range",
"Communication",
"The range of the bt receiver");
64 oc.
addDescription(
"device.btreceiver.all-recognitions",
"Communication",
"Whether all recognition point shall be written");
67 oc.
addDescription(
"device.btreceiver.offtime",
"Communication",
"The offtime used for calculating detection probability (in seconds)");
78 into.push_back(device);
100 (*i).second->amOnNet =
false;
101 (*i).second->haveArrived =
true;
104 (*i).second->amOnNet =
false;
105 (*i).second->haveArrived =
true;
119 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
120 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
121 rt.
Insert(cmin, cmax, vi);
126 bool allRecognitions = oc.
getBool(
"device.btreceiver.all-recognitions");
127 bool haveOutput = oc.
isSet(
"bt-output");
133 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
134 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
135 std::set<std::string> surroundingVehicles;
137 rt.
Search(cmin, cmax, sv);
140 for (std::set<std::string>::const_iterator j = surroundingVehicles.begin(); j != surroundingVehicles.end(); ++j) {
141 if ((*i).first == *j) {
151 writeOutput((*i).first, vi->
seen, allRecognitions);
185 leaveRange(receiver, receiverData, sender, senderData, 0);
189 const Position& oldReceiverPosition = receiver.
updates.front().position;
197 std::vector<double> intersections;
199 switch (intersections.size()) {
210 leaveRange(receiver, receiverData, sender, senderData, 0.);
217 intersection1ReceiverData.
position = oldReceiverPosition + receiverDelta * intersections.front();
219 intersection1SenderData.
position = oldSenderPosition + senderDelta * intersections.front();
221 leaveRange(receiver, intersection1ReceiverData,
222 sender, intersection1SenderData, (intersections.front() - 1.) *
TS);
224 enterRange((intersections.front() - 1.) *
TS, intersection1ReceiverData,
233 intersectionReceiverData.
position = oldReceiverPosition + receiverDelta * intersections.front();
235 intersectionSenderData.
position = oldSenderPosition + senderDelta * intersections.front();
236 enterRange((intersections.front() - 1.) *
TS, intersectionReceiverData,
238 intersectionReceiverData.
position = oldReceiverPosition + receiverDelta * intersections.back();
239 intersectionSenderData.
position = oldSenderPosition + senderDelta * intersections.back();
240 leaveRange(receiver, intersectionReceiverData,
241 sender, intersectionSenderData, (intersections.back() - 1.) *
TS);
243 WRITE_WARNING(
"The vehicle '" + sender.
getID() +
"' cannot be in the range of vehicle '" + receiver.
getID() +
"', leave, and enter it in one step.");
247 WRITE_WARNING(
"Nope, a circle cannot be crossed more often than twice by a line.");
256 std::map<std::string, SeenDevice*>& currentlySeen) {
259 currentlySeen[senderID] =
sd;
260 addRecognitionPoint(
SIMTIME, receiverState, senderState,
sd);
268 std::map<std::string, SeenDevice*>::iterator i = receiverInfo.
currentlySeen.find(senderInfo.
getID());
270 addRecognitionPoint(
SIMTIME + tOffset, receiverState, senderState, i->second);
273 ConstMSEdgeVector::const_iterator begin = receiverInfo.
route.begin() + i->second->meetingBegin.observerState.routePos;
274 ConstMSEdgeVector::const_iterator end = receiverInfo.
route.begin() + receiverState.
routePos + 1;
275 i->second->receiverRoute = toString<const MSEdge>(begin, end);
276 begin = senderInfo.
route.begin() + i->second->meetingBegin.seenState.routePos;
278 i->second->senderRoute = toString<const MSEdge>(begin, end);
279 receiverInfo.
seen[senderInfo.
getID()].push_back(i->second);
295 return delaySlots + backoff;
299 return 2048 - phaseOffset + delaySlots + backoff;
303 if (2 * 2048 - phaseOffset + backoff < 4096) {
304 return 2 * 2048 - phaseOffset + delaySlots + backoff;
307 return 2 * 2048 - phaseOffset + delaySlots + backoff;
309 return 2 * 2048 + delaySlots + backoff;
317 if (senderDevice->
nextView == -1.) {
320 if (tEnd > senderDevice->
nextView) {
333 for (std::map<std::string, std::vector<SeenDevice*> >::const_iterator j = seen.begin(); j != seen.end(); ++j) {
334 const std::vector<SeenDevice*>& sts = (*j).second;
335 for (std::vector<SeenDevice*>::const_iterator k = sts.begin(); k != sts.end(); ++k) {
339 os.
writeAttr(
"tBeg", (*k)->meetingBegin.t)
346 os.
writeAttr(
"tEnd", (*k)->meetingEnd->t)
351 .
writeAttr(
"observerRoute", (*k)->receiverRoute).
writeAttr(
"seenRoute", (*k)->senderRoute);
352 for (std::vector<MeetingPoint*>::iterator l = (*k)->recognitionPoints.begin(); l != (*k)->recognitionPoints.end(); ++l) {
354 .
writeAttr(
"observerPos", (*l)->observerState.position).
writeAttr(
"observerSpeed", (*l)->observerState.speed)
355 .
writeAttr(
"observerLaneID", (*l)->observerState.laneID).
writeAttr(
"observerLanePos", (*l)->observerState.lanePos)
356 .
writeAttr(
"seenPos", (*l)->seenState.position).
writeAttr(
"seenSpeed", (*l)->seenState.speed)
357 .
writeAttr(
"seenLaneID", (*l)->seenState.laneID).
writeAttr(
"seenLanePos", (*l)->seenState.lanePos)
359 if (!allRecognitions) {
406 WRITE_WARNING(
"btreceiver: Can not update position of vehicle '" + veh.
getID() +
"' which is not on the road.");
422 WRITE_WARNING(
"btreceiver: Can not update position of vehicle '" + veh.
getID() +
"' which is not on the road.");
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
Representation of a vehicle or person.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived senders.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
#define WRITE_WARNING(msg)
Representation of a lane in the micro simulation.
static double inquiryDelaySlots(const int backoffLimit)
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Moves (the known) vehicle from running to arrived vehicles' list.
SUMOTime execute(SUMOTime currentTime)
Performs the update.
double ymin() const
Returns minimum y-coordinate.
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane=0)
Adds the vehicle to running vehicles if it (re-) enters the network.
Static storage of an output device and its base (abstract) implementation.
double lastView
Last recognition point.
Class representing a single seen device.
static std::map< std::string, VehicleInformation * > sVehicles
The list of arrived receivers.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
Allows to store the object; used as context while traveling the rtree in TraCI.
virtual const std::string & getID() const =0
Get the vehicle's ID.
double nextView
Next possible recognition point.
static bool myWasInitialised
Whether the bt-system was already initialised.
double lanePos
The position at the lane of the vehicle.
Representation of a vehicle.
double xmax() const
Returns maximum x-coordinate.
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.
int getRoutePosition() const
return index of edge within route
int routePos
The position in the route of the vehicle.
Position position
The position of the vehicle.
static std::mt19937 sRecognitionRNG
A random number generator used to determine whether the opposite was recognized.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
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.
std::string laneID
The lane the vehicle was at.
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.
double xmin() const
Returns minimum x-coordinate.
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
MSDevice_BTreceiver(SUMOVehicle &holder, const std::string &id)
Constructor.
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
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.
A class that stores a 2D geometrical boundary.
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
A point in 2D or 3D with translation and scaling methods.
double speed
The speed of the vehicle.
A storage for options typed value containers)
void enterRange(double atOffset, const MSDevice_BTsender::VehicleState &receiverState, const std::string &senderID, const MSDevice_BTsender::VehicleState &senderState, std::map< std::string, SeenDevice * > ¤tlySeen)
Informs the receiver about a sender entering it's radius.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
void addRecognitionPoint(const double tEnd, const MSDevice_BTsender::VehicleState &receiverState, const MSDevice_BTsender::VehicleState &senderState, SeenDevice *senderDevice) const
Adds a point of recognition.
Holds the information about exact positions/speeds/time of the begin/end of a meeting.
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.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
const MSLane * getLane() const
Returns the lane the reminder works on.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
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.
~MSDevice_BTreceiver()
Destructor.
A global update performer.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
The base class for microscopic and mesoscopic vehicles.
A RT-tree for efficient storing of SUMO's Named objects.
Boundary & grow(double by)
extends the boundary by the given amount
BTreceiverUpdate()
Constructor.
void updateVisibility(VehicleInformation &receiver, MSDevice_BTsender::VehicleInformation &sender)
Rechecks the visibility for a given receiver/sender pair.
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
virtual double getPositionOnLane() const =0
Get the vehicle's position along the lane.
~BTreceiverUpdate()
Destructor.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
static double myRange
The range of the device.
const std::string & getID() const
Returns the id.
Notification
Definition of a vehicle state.
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
A single movement state of the vehicle.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
std::vector< MeetingPoint * > recognitionPoints
List of recognition points.
static double myOffTime
The offtime of the device.
virtual double getSpeed() const =0
Returns the vehicle's current speed.
void writeOutput(const std::string &id, const std::map< std::string, std::vector< SeenDevice * > > &seen, bool allRecognitions)
Writes the output.
double ymax() const
Returns maximum y-coordinate.
Representation of a vehicle in the micro simulation.
Abstract in-vehicle device.