47 #ifdef CHECK_MEMORY_LEAKS
49 #endif // CHECK_MEMORY_LEAKS
71 oc.
addDescription(
"device.btreceiver.range",
"Communication",
"The range of the bt receiver");
74 oc.
addDescription(
"device.btreceiver.all-recognitions",
"Communication",
"Whether all recognition point shall be written");
83 into.push_back(device);
103 (*i).second->amOnNet =
false;
104 (*i).second->haveArrived =
true;
107 (*i).second->amOnNet =
false;
108 (*i).second->haveArrived =
true;
124 rt.
Insert(cmin, cmax, vi);
129 bool allRecognitions = oc.
getBool(
"device.btreceiver.all-recognitions");
130 bool haveOutput = oc.
isSet(
"bt-output");
139 Position egoP1(egoP2.
x() - sin(angle)*dist, egoP2.
y() + cos(angle)*dist);
148 std::set<std::string> surroundingVehicles;
150 rt.
Search(cmin, cmax, sv);
153 for (std::set<std::string>::const_iterator j = surroundingVehicles.begin(); j != surroundingVehicles.end(); ++j) {
154 if ((*i).first == *j) {
164 writeOutput((*i).first, vi->
seen, allRecognitions);
171 (*i).second->updates.clear();
172 (*i).second->updates.push_back(last);
179 if ((*i).second->haveArrived) {
184 (*i).second->updates.clear();
185 (*i).second->updates.push_back(last);
197 std::vector<SUMOReal> intersections;
214 Position otherP1(otherPosition.
x() - sin(angle)*dist, otherPosition.
y() + cos(angle)*dist);
215 Position otherD = otherP2 - otherP1;
216 otherP2 = otherP1 - receiverD + otherD;
219 switch (intersections.size()) {
224 enterRange(0., receiverPos, receiver.
updates.back().speed, receiver.
updates.back().laneID, receiver.
updates.back().lanePos,
239 Position intersection1Other = otherP1 + otherD * intersections.front();
240 Position intersection1Ego = receiverStartPos + receiverD * intersections.front();
243 sender.
getID(), intersection1Other, sender.
updates.back().speed, sender.
updates.back().laneID, sender.
updates.back().lanePos, (intersections.front() - 1.) *
TS);
245 enterRange((intersections.front() - 1.) *
TS, intersection1Ego, receiver.
updates.back().speed, receiver.
updates.back().laneID, receiver.
updates.back().lanePos,
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,
257 Position intersection2Other = otherP1 + otherD * intersections[1];
258 Position intersection2Ego = receiverStartPos + receiverD * intersections[1];
260 sender.
getID(), intersection2Other, sender.
updates.back().speed, sender.
updates.back().laneID, sender.
updates.back().lanePos, (intersections.back() - 1.) *
TS);
262 WRITE_WARNING(
"Nope, a vehicle cannot be in the range, leave, and enter it in one step.");
266 WRITE_WARNING(
"Nope, a circle cannot be crossed more often than twice by a line.");
275 const std::string& otherID,
const Position& otherPos,
SUMOReal otherSpeed,
const std::string& otherLaneID,
SUMOReal otherLanePos,
276 std::map<std::string, SeenDevice*>& currentlySeen) {
279 currentlySeen[otherID] = sd;
281 otherPos, otherSpeed, otherLaneID, otherLanePos, sd);
288 const std::string& otherID,
const Position& otherPos,
SUMOReal otherSpeed,
const std::string& otherLaneID,
SUMOReal otherLanePos,
290 std::map<std::string, SeenDevice*>::iterator i = currentlySeen.find(otherID);
293 otherPos, otherSpeed, otherLaneID, otherLanePos, (*i).second);
296 (*i).second->meetingEnd = mp;
297 if (seen.find(otherID) == seen.end()) {
298 seen[otherID] = std::vector<SeenDevice*>();
300 seen[otherID].push_back((*i).second);
301 currentlySeen.erase(i);
313 MeetingPoint* mp =
new MeetingPoint(tEnd, thisPos, thisSpeed, thisLaneID, thisLanePos, otherPos, otherSpeed, otherLaneID, otherLanePos);
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) {
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);
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) {
339 .
writeAttr(
"observerPos", (*l)->observerPos).
writeAttr(
"observerSpeed", (*l)->observerSpeed)
340 .
writeAttr(
"observerLaneID", (*l)->observerLaneID).
writeAttr(
"observerLanePos", (*l)->observerLanePos)
342 .
writeAttr(
"seenLaneID", (*l)->seenLaneID).
writeAttr(
"seenLanePos", (*l)->seenLanePos)
344 if (!allRecognitions) {
387 WRITE_WARNING(
"btreceiver: Can not update position of a vehicle that is not within the road network (" + veh.
getID() +
").");
391 MSNet::getInstance()->getCurrentTimeStep(), newSpeed, static_cast<MSVehicle&>(veh).getAngle(), static_cast<MSVehicle&>(veh).getPosition(), static_cast<MSVehicle&>(veh).
getLane()->
getID(), newPos
403 WRITE_WARNING(
"btreceiver: Can not update position of a vehicle that is not within the road network (" + veh.
getID() +
").");