当前位置: 首页>>代码示例>>C++>>正文


C++ SUMOVehicle::getCurrentRouteEdge方法代码示例

本文整理汇总了C++中SUMOVehicle::getCurrentRouteEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ SUMOVehicle::getCurrentRouteEdge方法的具体用法?C++ SUMOVehicle::getCurrentRouteEdge怎么用?C++ SUMOVehicle::getCurrentRouteEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SUMOVehicle的用法示例。


在下文中一共展示了SUMOVehicle::getCurrentRouteEdge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

bool
MSRailSignal::hasLinkConflict(int index) const {
#ifdef DEBUG_SIGNALSTATE_PRIORITY
    //if (DEBUG_COND) std::cout << SIMTIME << " railSignal=" << getID() << " index=" << index << " hasLinkConflict...\n";
#endif
    MSLink* currentLink = myLinks[index][0];
    double foeMaxSpeed = -1;
    double foeMinDist = std::numeric_limits<double>::max();
    SUMOTime foeMinETA = std::numeric_limits<SUMOTime>::max();
    long long foeMinNumericalID = std::numeric_limits<long long>::max(); // tie braker

    // check for vehicles that enter the (unconditional) conflict area and
    // resolve conflict according to priority
    std::vector<int> checkRouteConflict;
    const auto& cLinks = myConflictLinks[index];
    for (int clIndex = 0; clIndex < (int)cLinks.size(); ++clIndex) {
        if (myRouteConflictLanes[index][clIndex].size() > 0) {
            // record links where the conditional conflict area may be occupied
            checkRouteConflict.push_back(clIndex);
        }
        const MSLink* link = cLinks[clIndex];
        if (link->getApproaching().size() > 0) {
            const MSTrafficLightLogic* foeTLL = link->getTLLogic();
            assert(foeTLL != nullptr);
            const MSRailSignal* foeRS = dynamic_cast<const MSRailSignal*>(foeTLL);
            if (foeRS != nullptr) {
                if (foeRS->conflictLaneOccupied(link->getTLIndex())) {
#ifdef DEBUG_SIGNALSTATE_PRIORITY
                    if (DEBUG_COND) std::cout << SIMTIME << " railSignal=" << getID() << " index=" << index
                                                  << " foeLink " << link->getViaLaneOrLane()->getID() << " (ignored)\n";
#endif
                    continue;
                }
            } else if (link->getState() == LINKSTATE_TL_RED) {
                // ignore foe vehicles waiting at a regular traffic light
                continue;
            }
        }
        for (auto apprIt : link->getApproaching()) {
            MSLink::ApproachingVehicleInformation info = apprIt.second;
            foeMaxSpeed = MAX2(apprIt.first->getSpeed(), foeMaxSpeed);
            foeMinDist = MIN2(info.dist, foeMinDist);
            if (info.willPass) {
                foeMinETA = MIN2(info.arrivalTime, foeMinETA);
            }
            foeMinNumericalID = MIN2(foeMinNumericalID, apprIt.first->getNumericalID());
        }
    }
    SUMOVehicle* closest = nullptr;
    if (foeMaxSpeed >= 0 || checkRouteConflict.size() > 0) {
        // check against vehicles approaching this link
        double maxSpeed = -1;
        double minDist = std::numeric_limits<double>::max();
        SUMOTime minETA = std::numeric_limits<SUMOTime>::max();
        long long minNumericalID = std::numeric_limits<long long>::max(); // tie braker
        for (auto apprIt : currentLink->getApproaching()) {
            MSLink::ApproachingVehicleInformation info = apprIt.second;
            maxSpeed = MAX2(apprIt.first->getSpeed(), maxSpeed);
            if (info.dist < minDist) {
                minDist = info.dist;
                closest = const_cast<SUMOVehicle*>(apprIt.first);
            }
            if (info.willPass) {
                minETA = MIN2(info.arrivalTime, minETA);
            }
            minNumericalID = MIN2(minNumericalID, apprIt.first->getNumericalID());
        }
#ifdef DEBUG_SIGNALSTATE_PRIORITY
        if (DEBUG_COND) std::cout << SIMTIME << " railSignal=" << getID() << " index=" << index
                                      << " fms=" << foeMaxSpeed << " ms=" << maxSpeed
                                      << " fmd=" << foeMinDist << " md=" << minDist
                                      << " fmE=" << foeMinETA << " mE=" << minETA
                                      << " fmI=" << foeMinNumericalID << " mI=" << minNumericalID
                                      << "\n";
#endif
        if (foeMinETA < minETA) {
            return true;
        } else if (foeMinETA == minETA) {
            if (foeMaxSpeed > maxSpeed) {
                return true;
            } else if (foeMaxSpeed == maxSpeed) {
                if (foeMinDist < minDist) {
                    return true;
                } else if (foeMinDist == minDist) {
                    if (foeMinNumericalID < minNumericalID) {
                        return true;
                    }
                }
            }
        }
#ifdef DEBUG_SIGNALSTATE_PRIORITY
        //if (DEBUG_COND) std::cout << SIMTIME << " railSignal=" << getID() << " index=" << index << " closestVeh=" << Named::getIDSecure(closest) << " routeFoes " << toString(routeFoes) << "\n";
#endif
        if (closest != nullptr) {
            for (int clIndex : checkRouteConflict) {
                const MSEdge& firstBidi = myRouteConflictLanes[index][clIndex].front()->getEdge();
                const MSEdge* first = firstBidi.getBidiEdge();
                assert(first != nullptr);
                if (std::find(closest->getCurrentRouteEdge(), closest->getRoute().end(), first) != closest->getRoute().end()) {
                    // vehicle wants to drive passt this conflict link
//.........这里部分代码省略.........
开发者ID:behrisch,项目名称:sumo,代码行数:101,代码来源:MSRailSignal.cpp


注:本文中的SUMOVehicle::getCurrentRouteEdge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。