Ejemplo n.º 1
0
Boundary
GUIPerson::getCenteringBoundary() const {
    Boundary b;
    // ensure that the vehicle is drawn, otherwise myPositionInVehicle will not be updated
    b.add(getPosition());
    b.grow(MAX2(getVehicleType().getWidth(), getVehicleType().getLength()));
    return b;
}
Ejemplo n.º 2
0
SUMOReal
MSBaseVehicle::getImpatience() const {
    return MAX2((SUMOReal)0, MIN2((SUMOReal)1, getVehicleType().getImpatience() +
                                  (MSGlobals::gTimeToGridlock > 0 ? (SUMOReal)getWaitingTime() / MSGlobals::gTimeToGridlock : 0)));
//    Alternavite to avoid time to teleport effect on the simulation. No effect if time to teleport is -1
//    return MAX2((SUMOReal)0, MIN2((SUMOReal)1, getVehicleType().getImpatience()));
}
Ejemplo n.º 3
0
void
GUIPerson::drawAction_drawAsImage(const GUIVisualizationSettings& s) const {
    const std::string& file = getVehicleType().getImgFile();
    if (file != "") {
        if (getVehicleType().getGuiShape() == SVS_PEDESTRIAN) {
            glRotated(RAD2DEG(getAngle() + PI / 2.), 0, 0, 1);
        }
        int textureID = GUITexturesHelper::getTextureID(file);
        if (textureID > 0) {
            const SUMOReal exaggeration = s.personSize.getExaggeration(s);
            const SUMOReal halfLength = getVehicleType().getLength() / 2.0 * exaggeration;
            const SUMOReal halfWidth = getVehicleType().getWidth() / 2.0 * exaggeration;
            GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, -halfLength, halfWidth, halfLength);
        }
    } else {
        // fallback if no image is defined
        drawAction_drawAsPoly(s);
    }
}
Ejemplo n.º 4
0
bool
GUIPerson::setFunctionalColor(int activeScheme) const {
    switch (activeScheme) {
        case 0: {
            if (getParameter().wasSet(VEHPARS_COLOR_SET)) {
                GLHelper::setColor(getParameter().color);
                return true;
            }
            if (getVehicleType().wasSet(VTYPEPARS_COLOR_SET)) {
                GLHelper::setColor(getVehicleType().getColor());
                return true;
            }
            return false;
        }
        case 2: {
            if (getParameter().wasSet(VEHPARS_COLOR_SET)) {
                GLHelper::setColor(getParameter().color);
                return true;
            }
            return false;
        }
        case 3: {
            if (getVehicleType().wasSet(VTYPEPARS_COLOR_SET)) {
                GLHelper::setColor(getVehicleType().getColor());
                return true;
            }
            return false;
        }
        case 8: { // color by angle
            SUMOReal hue = GeomHelper::naviDegree(getAngle());
            GLHelper::setColor(RGBColor::fromHSV(hue, 1., 1.));
            return true;
        }
        case 9: { // color randomly (by pointer)
            const SUMOReal hue = (long)this % 360; // [0-360]
            const SUMOReal sat = (((long)this / 360) % 67) / 100.0 + 0.33; // [0.33-1]
            GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
            return true;
        }
        default:
            return false;
    }
}
Ejemplo n.º 5
0
inline void
GUIVehicle::drawAction_drawVehicleBrakeLight(double length, bool onlyOne) const {
    if (!signalSet(MSVehicle::VEH_SIGNAL_BRAKELIGHT)) {
        return;
    }
    glColor3f(1.f, .2f, 0);
    glPushMatrix();
    if (onlyOne) {
        glTranslated(0, length, -0.1);
        GLHelper::drawFilledCircle(.5, 6);
    } else {
        glTranslated(-getVehicleType().getWidth() * 0.5, length, -0.1);
        GLHelper::drawFilledCircle(.5, 6);
        glPopMatrix();
        glPushMatrix();
        glTranslated(getVehicleType().getWidth() * 0.5, length, -0.1);
        GLHelper::drawFilledCircle(.5, 6);
    }
    glPopMatrix();
}
Ejemplo n.º 6
0
void
GUIPerson::drawAction_drawAsTriangle(const GUIVisualizationSettings& /* s */) const {
    // draw triangle pointing forward
    glRotated(RAD2DEG(getAngle() + PI / 2.), 0, 0, 1);
    glScaled(getVehicleType().getLength(), getVehicleType().getWidth(), 1);
    glBegin(GL_TRIANGLES);
    glVertex2d(0., 0.);
    glVertex2d(1, -0.5);
    glVertex2d(1, 0.5);
    glEnd();
    // draw a smaller triangle to indicate facing
    GLHelper::setColor(GLHelper::getColor().changedBrightness(-64));
    glTranslated(0, 0, .045);
    glBegin(GL_TRIANGLES);
    glVertex2d(0., 0.);
    glVertex2d(0.5, -0.25);
    glVertex2d(0.5, 0.25);
    glEnd();
    glTranslated(0, 0, -.045);
}
Ejemplo n.º 7
0
void
GUIPerson::drawAction_drawAsPoly(const GUIVisualizationSettings& /* s */) const {
    // draw pedestrian shape
    glRotated(GeomHelper::naviDegree(getAngle()) - 180, 0, 0, -1);
    glScaled(getVehicleType().getLength(), getVehicleType().getWidth(), 1);
    RGBColor lighter = GLHelper::getColor().changedBrightness(51);
    glTranslated(0, 0, .045);
    // head
    glScaled(1, 0.5, 1.);
    GLHelper::drawFilledCircle(0.5);
    // nose
    glBegin(GL_TRIANGLES);
    glVertex2d(0.0, -0.2);
    glVertex2d(0.0, 0.2);
    glVertex2d(-0.6, 0.0);
    glEnd();
    glTranslated(0, 0, -.045);
    // body
    glScaled(0.9, 2.0, 1);
    glTranslated(0, 0, .04);
    GLHelper::setColor(lighter);
    GLHelper::drawFilledCircle(0.5);
    glTranslated(0, 0, -.04);
}
Ejemplo n.º 8
0
void
GUIVehicle::drawAction_drawVehicleBlinker(double length) const {
    if (!signalSet(MSVehicle::VEH_SIGNAL_BLINKER_RIGHT | MSVehicle::VEH_SIGNAL_BLINKER_LEFT | MSVehicle::VEH_SIGNAL_BLINKER_EMERGENCY)) {
        return;
    }
    const double offset = MAX2(.5 * getVehicleType().getWidth(), .4);
    if (signalSet(MSVehicle::VEH_SIGNAL_BLINKER_RIGHT)) {
        drawAction_drawBlinker(-offset, length);
    }
    if (signalSet(MSVehicle::VEH_SIGNAL_BLINKER_LEFT)) {
        drawAction_drawBlinker(offset, length);;
    }
    if (signalSet(MSVehicle::VEH_SIGNAL_BLINKER_EMERGENCY)) {
        drawAction_drawBlinker(-offset, length);
        drawAction_drawBlinker(offset, length);
    }
}
Ejemplo n.º 9
0
int SetupWizard::nextId() const
{
    switch (currentId()) {
        case PAGE_START:
            if(canAutoUpdate()) {
                return PAGE_UPDATE;
            } else {
                return PAGE_CONTROLLER;
            }
        case PAGE_UPDATE:
            return PAGE_CONTROLLER;
        case PAGE_CONTROLLER: {
            switch(getControllerType())
            {
                case CONTROLLER_CC:
                case CONTROLLER_CC3D:
                    return PAGE_INPUT;
                case CONTROLLER_REVO:
                case CONTROLLER_PIPX:
                default:
                    return PAGE_NOTYETIMPLEMENTED;
            }
        }
        case PAGE_VEHICLES: {
            switch(getVehicleType())
            {
                case VEHICLE_MULTI:
                    return PAGE_MULTI;
                case VEHICLE_FIXEDWING:
                    return PAGE_FIXEDWING;
                case VEHICLE_HELI:
                    return PAGE_HELI;
                case VEHICLE_SURFACE:
                    return PAGE_SURFACE;
                default:
                    return PAGE_NOTYETIMPLEMENTED;
            }
        }
        case PAGE_MULTI:
            return PAGE_OUTPUT;
        case PAGE_INPUT:
            if(isRestartNeeded()) {
                saveHardwareSettings();
                return PAGE_REBOOT;
            }
            else {
                return PAGE_VEHICLES;
            }
        case PAGE_REBOOT:
            return PAGE_VEHICLES;
        case PAGE_OUTPUT:
            return PAGE_SUMMARY;
        case PAGE_LEVELLING:
            return PAGE_CALIBRATION;
        case PAGE_CALIBRATION:
            return PAGE_SAVE;
        case PAGE_SUMMARY:
            return PAGE_LEVELLING;
        case PAGE_SAVE:
            return PAGE_END;
        case PAGE_NOTYETIMPLEMENTED:
            return PAGE_END;
        default:
            return -1;
    }
}
Ejemplo n.º 10
0
QString SetupWizard::getSummaryText()
{
    QString summary = "";
    summary.append("<b>").append(tr("Controller type: ")).append("</b>");
    switch(getControllerType())
    {
        case CONTROLLER_CC:
            summary.append(tr("OpenPilot CopterControl"));
            break;
        case CONTROLLER_CC3D:
            summary.append(tr("OpenPilot CopterControl 3D"));
            break;
        case CONTROLLER_REVO:
            summary.append(tr("OpenPilot Revolution"));
            break;
        case CONTROLLER_PIPX:
            summary.append(tr("OpenPilot PipX Radio Modem"));
            break;
        default:
            summary.append(tr("Unknown"));
            break;
    }

    summary.append("<br>");
    summary.append("<b>").append(tr("Vehicle type: ")).append("</b>");
    switch (getVehicleType())
    {
        case VEHICLE_MULTI:
            summary.append(tr("Multirotor"));

            summary.append("<br>");
            summary.append("<b>").append(tr("Vehicle sub type: ")).append("</b>");
            switch (getVehicleSubType())
            {
                case SetupWizard::MULTI_ROTOR_TRI_Y:
                    summary.append(tr("Tricopter"));
                    break;
                case SetupWizard::MULTI_ROTOR_QUAD_X:
                    summary.append(tr("Quadcopter X"));
                    break;
                case SetupWizard::MULTI_ROTOR_QUAD_PLUS:
                    summary.append(tr("Quadcopter +"));
                    break;
                case SetupWizard::MULTI_ROTOR_HEXA:
                    summary.append(tr("Hexacopter"));
                    break;
                case SetupWizard::MULTI_ROTOR_HEXA_COAX_Y:
                    summary.append(tr("Hexacopter Coax (Y6)"));
                    break;
                case SetupWizard::MULTI_ROTOR_HEXA_H:
                    summary.append(tr("Hexacopter X"));
                    break;
                case SetupWizard::MULTI_ROTOR_OCTO:
                    summary.append(tr("Octocopter"));
                    break;
                case SetupWizard::MULTI_ROTOR_OCTO_COAX_X:
                    summary.append(tr("Octocopter Coax X"));
                    break;
                case SetupWizard::MULTI_ROTOR_OCTO_COAX_PLUS:
                    summary.append(tr("Octocopter Coax +"));
                    break;
                case SetupWizard::MULTI_ROTOR_OCTO_V:
                    summary.append(tr("Octocopter V"));
                    break;
                default:
                    summary.append(tr("Unknown"));
                    break;
            }

            break;
        case VEHICLE_FIXEDWING:
            summary.append(tr("Fixed wing"));
            break;
        case VEHICLE_HELI:
            summary.append(tr("Helicopter"));
            break;
        case VEHICLE_SURFACE:
            summary.append(tr("Surface vehicle"));
            break;
        default:
            summary.append(tr("Unknown"));
    }

    summary.append("<br>");
    summary.append("<b>").append(tr("Input type: ")).append("</b>");
    switch (getInputType())
    {
        case INPUT_PWM:
            summary.append(tr("PWM (One cable per channel)"));
            break;
        case INPUT_PPM:
            summary.append(tr("PPM (One cable for all channels)"));
            break;
        case INPUT_SBUS:
            summary.append(tr("Futaba S.Bus"));
            break;
        case INPUT_DSM2:
            summary.append(tr("Spektrum satellite (DSM2)"));
            break;
        case INPUT_DSMX10:
            summary.append(tr("Spektrum satellite (DSMX10BIT)"));
            break;
        case INPUT_DSMX11:
            summary.append(tr("Spektrum satellite (DSMX11BIT)"));
            break;
        default:
            summary.append(tr("Unknown"));
    }

    summary.append("<br>");
    summary.append("<b>").append(tr("ESC type: ")).append("</b>");
    switch (getESCType())
    {
        case ESC_LEGACY:
            summary.append(tr("Legacy ESC (50 Hz)"));
            break;
        case ESC_RAPID:
            summary.append(tr("Rapid ESC (400 Hz)"));
            break;
        default:
            summary.append(tr("Unknown"));
    }

    /*
    summary.append("<br>");
    summary.append("<b>").append(tr("Reboot required: ")).append("</b>");
    summary.append(isRestartNeeded() ? tr("<font color='red'>Yes</font>") : tr("<font color='green'>No</font>"));
    */
    return summary;
}
Ejemplo n.º 11
0
void
GUIVehicle::selectBlockingFoes() const {
    double dist = myLane->getLength() - getPositionOnLane();
#ifdef DEBUG_FOES
    std::cout << SIMTIME << " selectBlockingFoes veh=" << getID() << " dist=" << dist << " numLinks=" << myLFLinkLanes.size() << "\n";
#endif
    for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
        const DriveProcessItem& dpi = *i;
        if (dpi.myLink == nullptr) {
            /// XXX if the vehicle intends to stop on an intersection, there could be a relevant exitLink (see #4299)
            continue;
        }
        std::vector<const SUMOVehicle*> blockingFoes;
        std::vector<const MSPerson*> blockingPersons;
#ifdef DEBUG_FOES
        std::cout << "   foeLink=" << dpi.myLink->getViaLaneOrLane()->getID() << "\n";
        const bool isOpen =
#endif
            dpi.myLink->opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(), getVehicleType().getLength(),
                               getImpatience(), getCarFollowModel().getMaxDecel(), getWaitingTime(), getLateralPositionOnLane(), &blockingFoes);
#ifdef DEBUG_FOES
        if (!isOpen) {
            std::cout << "     closed due to:\n";
            for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
                std::cout << "   " << (*it)->getID() << "\n";
            }
        }
#endif
        if (getLaneChangeModel().getShadowLane() != nullptr) {
            MSLink* parallelLink = dpi.myLink->getParallelLink(getLaneChangeModel().getShadowDirection());
            if (parallelLink != nullptr) {
                const double shadowLatPos = getLateralPositionOnLane() - getLaneChangeModel().getShadowDirection() * 0.5 * (
                                                myLane->getWidth() + getLaneChangeModel().getShadowLane()->getWidth());
#ifdef DEBUG_FOES
                const bool isShadowOpen =
#endif
                    parallelLink->opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
                                         getVehicleType().getLength(), getImpatience(),
                                         getCarFollowModel().getMaxDecel(),
                                         getWaitingTime(), shadowLatPos, &blockingFoes);
#ifdef DEBUG_FOES
                if (!isShadowOpen) {
                    std::cout <<  "    foes at shadow link=" << parallelLink->getViaLaneOrLane()->getID() << ":\n";
                    for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
                        std::cout << "   " << (*it)->getID() << "\n";
                    }
                }
#endif
            }
        }
        for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
            gSelected.select(static_cast<const GUIVehicle*>(*it)->getGlID());
        }
#ifdef DEBUG_FOES
        gDebugFlag1 = true;
#endif
        const MSLink::LinkLeaders linkLeaders = (dpi.myLink)->getLeaderInfo(this, dist, &blockingPersons);
#ifdef DEBUG_FOES
        gDebugFlag1 = false;
#endif
        for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
            // the vehicle to enter the junction first has priority
            const GUIVehicle* leader = dynamic_cast<const GUIVehicle*>(it->vehAndGap.first);
            if (leader != nullptr) {
                if (isLeader(dpi.myLink, leader)) {
                    gSelected.select(leader->getGlID());
#ifdef DEBUG_FOES
                    std::cout << "      linkLeader=" << leader->getID() << "\n";
#endif
                }
            } else {
                for (std::vector<const MSPerson*>::iterator it_p = blockingPersons.begin(); it_p != blockingPersons.end(); ++it_p) {
                    const GUIPerson* foe = dynamic_cast<const GUIPerson*>(*it_p);
                    if (foe != nullptr) {
                        gSelected.select(foe->getGlID());
                        //std::cout << SIMTIME << " veh=" << getID() << " is blocked on link " << dpi.myLink->getRespondIndex() << " to " << dpi.myLink->getViaLaneOrLane()->getID() << " by pedestrian. dist=" << it->second << "\n";
                    }
                }
            }
        }
        dist += dpi.myLink->getViaLaneOrLane()->getLength();
    }
}
Ejemplo n.º 12
0
void
GUIVehicle::drawAction_drawCarriageClass(const GUIVisualizationSettings& s, bool asImage) const {
    RGBColor current = GLHelper::getColor();
    RGBColor darker = current.changedBrightness(-51);
    const double exaggeration = s.vehicleSize.getExaggeration(s, this);
    const double totalLength = getVType().getLength();
    double upscaleLength = exaggeration;
    if (exaggeration > 1 && totalLength > 5) {
        // reduce the length/width ratio because this is not usefull at high zoom
        upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(totalLength - 5)) / totalLength);
    }
    const double locomotiveLength = getVehicleType().getParameter().locomotiveLength * upscaleLength;
    if (exaggeration == 0) {
        return;
    }
    const double defaultLength = getVehicleType().getParameter().carriageLength * upscaleLength;
    const double carriageGap = getVehicleType().getParameter().carriageGap * upscaleLength;
    const double length = totalLength * upscaleLength;
    const double halfWidth = getVehicleType().getWidth() / 2.0 * exaggeration;
    glPopMatrix(); // undo initial translation and rotation
    const double xCornerCut = 0.3 * exaggeration;
    const double yCornerCut = 0.4 * exaggeration;
    // round to closest integer
    const int numCarriages = MAX2(1, 1 + (int)((length - locomotiveLength) / (defaultLength + carriageGap) + 0.5));
    assert(numCarriages > 0);
    double carriageLengthWithGap = length / numCarriages;
    double carriageLength = carriageLengthWithGap - carriageGap;
    double firstCarriageLength = carriageLength;
    if (defaultLength != locomotiveLength && numCarriages > 1) {
        firstCarriageLength = locomotiveLength;
        carriageLengthWithGap = (length - locomotiveLength) / (numCarriages - 1);
        carriageLength = carriageLengthWithGap - carriageGap;
    }
    const int firstPassengerCarriage = defaultLength == locomotiveLength || numCarriages == 1 ? 0 : 1;
    const int totalSeats = getVType().getPersonCapacity() + getVType().getContainerCapacity();
    const int seatsPerCarriage = (int)ceil(totalSeats / (numCarriages - firstPassengerCarriage));
    // lane on which the carriage front is situated
    MSLane* lane = myLane;
    int routeIndex = getRoutePosition();
    // lane on which the carriage back is situated
    MSLane* backLane = myLane;
    int backRouteIndex = routeIndex;
    // offsets of front and back
    double carriageOffset = myState.pos();
    double carriageBackOffset = myState.pos() - firstCarriageLength;
    // handle seats
    int requiredSeats = getNumPassengers() + getNumContainers();
    if (requiredSeats > 0) {
        mySeatPositions.clear();
    }
    Position front, back;
    double angle = 0.;
    // draw individual carriages
    double curCLength = firstCarriageLength;
    //std::cout << SIMTIME << " veh=" << getID() << " curCLength=" << curCLength << " loc=" << locomotiveLength << " car=" << carriageLength << " tlen=" << totalLength << " len=" << length << "\n";
    for (int i = 0; i < numCarriages; ++i) {
        if (i > 0) {
            curCLength = carriageLength;
        }
        while (carriageOffset < 0) {
            MSLane* prev = getPreviousLane(lane, routeIndex);
            if (prev != lane) {
                carriageOffset += prev->getLength();
            } else {
                // no lane available for drawing.
                carriageOffset = 0;
            }
            lane = prev;
        }
        while (carriageBackOffset < 0) {
            MSLane* prev = getPreviousLane(backLane, backRouteIndex);
            if (prev != backLane) {
                carriageBackOffset += prev->getLength();
            } else {
                // no lane available for drawing.
                carriageBackOffset = 0;
            }
            backLane = prev;
        }
        front = lane->geometryPositionAtOffset(carriageOffset);
        back = backLane->geometryPositionAtOffset(carriageBackOffset);
        if (front == back) {
            // no place for drawing available
            continue;
        }
        const double drawnCarriageLength = front.distanceTo2D(back);
        angle = atan2((front.x() - back.x()), (back.y() - front.y())) * (double) 180.0 / (double) M_PI;
        if (i >= firstPassengerCarriage) {
            computeSeats(front, back, seatsPerCarriage, exaggeration, requiredSeats);
        }
        glPushMatrix();
        glTranslated(front.x(), front.y(), getType());
        glRotated(angle, 0, 0, 1);
        if (!asImage || !GUIBaseVehicleHelper::drawAction_drawVehicleAsImage(s, getVType().getImgFile(), this, getVType().getWidth(), curCLength)) {
            switch (getVType().getGuiShape()) {
                case SVS_TRUCK_SEMITRAILER:
                case SVS_TRUCK_1TRAILER:
                    if (i == 0) {
                        GUIBaseVehicleHelper::drawAction_drawVehicleAsPoly(s, getVType().getGuiShape(), getVType().getWidth() * exaggeration, curCLength, i);
                    } else {
                        GLHelper::setColor(current);
                        GLHelper::drawBoxLine(Position(0, 0), 180, curCLength, halfWidth);
                    }
                    break;
                default: {
                    if (i == 0) {
                        GLHelper::setColor(darker);
                    } else {
                        GLHelper::setColor(current);
                    }
                    // generic rail carriage
                    glBegin(GL_TRIANGLE_FAN);
                    glVertex2d(-halfWidth + xCornerCut, 0);
                    glVertex2d(-halfWidth, yCornerCut);
                    glVertex2d(-halfWidth, drawnCarriageLength - yCornerCut);
                    glVertex2d(-halfWidth + xCornerCut, drawnCarriageLength);
                    glVertex2d(halfWidth - xCornerCut, drawnCarriageLength);
                    glVertex2d(halfWidth, drawnCarriageLength - yCornerCut);
                    glVertex2d(halfWidth, yCornerCut);
                    glVertex2d(halfWidth - xCornerCut, 0);
                    glEnd();
                }
            }
        }
        glPopMatrix();
        carriageOffset -= (curCLength + carriageGap);
        carriageBackOffset -= carriageLengthWithGap;
    }
    if (getVType().getGuiShape() == SVS_RAIL_CAR) {
        glPushMatrix();
        glTranslated(front.x(), front.y(), getType());
        glRotated(angle, 0, 0, 1);
        drawAction_drawVehicleBlinker(curCLength);
        drawAction_drawVehicleBrakeLight(curCLength);
        glPopMatrix();
    }
    // restore matrix
    glPushMatrix();
    front = getPosition();
    glTranslated(front.x(), front.y(), getType());
    const double degAngle = RAD2DEG(getAngle() + M_PI / 2.);
    glRotated(degAngle, 0, 0, 1);
    glScaled(exaggeration, upscaleLength, 1);
    if (mySeatPositions.size() == 0) {
        mySeatPositions.push_back(back);
    }
}
Ejemplo n.º 13
0
void
GUIVehicle::drawAction_drawLinkItems(const GUIVisualizationSettings& s) const {
    glTranslated(0, 0, getType() + .2); // draw on top of cars
    for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
        if ((*i).myLink == nullptr) {
            continue;
        }
        MSLink* link = (*i).myLink;
        MSLane* via = link->getViaLaneOrLane();
        if (via != nullptr) {
            Position p = via->getShape()[0];
            if ((*i).mySetRequest) {
                glColor3d(0, .8, 0);
            } else {
                glColor3d(.8, 0, 0);
            }
            const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
                                           (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(), getVehicleType().getLength());
            drawLinkItem(p, (*i).myArrivalTime, leaveTime, s.vehicleName.size / s.scale);
            // the time slot that ego vehicle uses when checking opened may
            // differ from the one it requests in setApproaching
            MSLink::ApproachingVehicleInformation avi = (*i).myLink->getApproaching(this);
            assert(avi.arrivalTime == (*i).myArrivalTime && avi.leavingTime == leaveTime);
            UNUSED_PARAMETER(avi); // only used for assertion
        }
    }
    glTranslated(0, 0, getType() - .2); // draw on top of cars
}
Ejemplo n.º 14
0
int SetupWizard::nextId() const
{
    switch (currentId()) {
    case PAGE_START:
        if (canAutoUpdate()) {
            return PAGE_UPDATE;
        } else {
            return PAGE_CONTROLLER;
        }
    case PAGE_UPDATE:
        return PAGE_CONTROLLER;

    case PAGE_CONTROLLER:
    {
        switch (getControllerType()) {
        case CONTROLLER_CC:
        case CONTROLLER_CC3D:
        case CONTROLLER_REVO:
        case CONTROLLER_DISCOVERYF4:
            return PAGE_INPUT;

        case CONTROLLER_NANO:
            if (isRestartNeeded()) {
                reboot();
            }
            return PAGE_INPUT;

        case CONTROLLER_OPLINK:
        default:
            return PAGE_NOTYETIMPLEMENTED;
        }
    }
    case PAGE_VEHICLES:
    {
        switch (getVehicleType()) {
        case VEHICLE_MULTI:
            return PAGE_MULTI;

        case VEHICLE_FIXEDWING:
            return PAGE_FIXEDWING;

        case VEHICLE_HELI:
            return PAGE_HELI;

        case VEHICLE_SURFACE:
            return PAGE_SURFACE;

        default:
            return PAGE_NOTYETIMPLEMENTED;
        }
    }
    case PAGE_MULTI:
        return PAGE_ESC;

    case PAGE_FIXEDWING:
    case PAGE_SURFACE:
        if (getVehicleSubType() == GROUNDVEHICLE_DIFFERENTIAL) {
            return PAGE_ESC;
        } else {
            return PAGE_SERVO;
        }

    case PAGE_INPUT:
        if (isRestartNeeded()) {
            saveHardwareSettings();
            reboot();
        }
        return PAGE_VEHICLES;

    case PAGE_ESC:
        if (getVehicleSubType() == MULTI_ROTOR_TRI_Y) {
            return PAGE_SERVO;
        } else {
            switch (getControllerType()) {
            case CONTROLLER_REVO:
            case CONTROLLER_NANO:
                return PAGE_GPS;

            default:
                return PAGE_SUMMARY;
            }
        }

    case PAGE_SERVO:
    {
        switch (getControllerType()) {
        case CONTROLLER_REVO:
        case CONTROLLER_NANO:
            return PAGE_GPS;

        default:
            return PAGE_SUMMARY;
        }
    }

    case PAGE_BIAS_CALIBRATION:
        if (getVehicleType() == VEHICLE_MULTI) {
            return PAGE_ESC_CALIBRATION;
        } else {
            return PAGE_OUTPUT_CALIBRATION;
        }

    case PAGE_ESC_CALIBRATION:
        return PAGE_OUTPUT_CALIBRATION;

    case PAGE_OUTPUT_CALIBRATION:
        return PAGE_AIRFRAME_INITIAL_TUNING;

    case PAGE_AIRFRAME_INITIAL_TUNING:
        return PAGE_SAVE;

    case PAGE_GPS:
        switch (getVehicleType()) {
        case VEHICLE_FIXEDWING:
            if (getGpsType() != GPS_DISABLED) {
                return PAGE_AIRSPEED;
            } else {
                return PAGE_SUMMARY;
            }
        default:
            return PAGE_SUMMARY;
        }

    case PAGE_AIRSPEED:
        return PAGE_SUMMARY;

    case PAGE_SUMMARY:
    {
        switch (getControllerType()) {
        case CONTROLLER_CC:
        case CONTROLLER_CC3D:
        case CONTROLLER_REVO:
        case CONTROLLER_NANO:
        case CONTROLLER_DISCOVERYF4:
            switch (getVehicleType()) {
            case VEHICLE_FIXEDWING:
                return PAGE_OUTPUT_CALIBRATION;

            default:
                return PAGE_BIAS_CALIBRATION;
            }
        default:
            return PAGE_NOTYETIMPLEMENTED;
        }
    }
    case PAGE_SAVE:
        return PAGE_END;

    case PAGE_NOTYETIMPLEMENTED:
        return PAGE_END;

    default:
        return -1;
    }
}
Ejemplo n.º 15
0
QString SetupWizard::getSummaryText()
{
    QString summary = "";

    summary.append("<b>").append(tr("Controller type: ")).append("</b>");
    switch (getControllerType()) {
    case CONTROLLER_CC:
        summary.append(tr("OpenPilot CopterControl"));
        break;
    case CONTROLLER_CC3D:
        summary.append(tr("OpenPilot CopterControl 3D"));
        break;
    case CONTROLLER_REVO:
        summary.append(tr("OpenPilot Revolution"));
        break;
    case CONTROLLER_NANO:
        summary.append(tr("OpenPilot Nano"));
        break;
    case CONTROLLER_OPLINK:
        summary.append(tr("OpenPilot OPLink Radio Modem"));
        break;
    case CONTROLLER_DISCOVERYF4:
        summary.append(tr("OpenPilot DiscoveryF4 Development Board"));
        break;
    default:
        summary.append(tr("Unknown"));
        break;
    }

    summary.append("<br>");
    summary.append("<b>").append(tr("Vehicle type: ")).append("</b>");
    switch (getVehicleType()) {
    case VEHICLE_MULTI:
        summary.append(tr("Multirotor"));

        summary.append("<br>");
        summary.append("<b>").append(tr("Vehicle sub type: ")).append("</b>");
        switch (getVehicleSubType()) {
        case SetupWizard::MULTI_ROTOR_TRI_Y:
            summary.append(tr("Tricopter"));
            break;
        case SetupWizard::MULTI_ROTOR_QUAD_X:
            summary.append(tr("Quadcopter X"));
            break;
        case SetupWizard::MULTI_ROTOR_QUAD_PLUS:
            summary.append(tr("Quadcopter +"));
            break;
        case SetupWizard::MULTI_ROTOR_HEXA:
            summary.append(tr("Hexacopter"));
            break;
        case SetupWizard::MULTI_ROTOR_HEXA_COAX_Y:
            summary.append(tr("Hexacopter Coax (Y6)"));
            break;
        case SetupWizard::MULTI_ROTOR_HEXA_H:
            summary.append(tr("Hexacopter H"));
            break;
        case SetupWizard::MULTI_ROTOR_HEXA_X:
            summary.append(tr("Hexacopter X"));
            break;
        case SetupWizard::MULTI_ROTOR_OCTO:
            summary.append(tr("Octocopter"));
            break;
        case SetupWizard::MULTI_ROTOR_OCTO_COAX_X:
            summary.append(tr("Octocopter Coax X"));
            break;
        case SetupWizard::MULTI_ROTOR_OCTO_COAX_PLUS:
            summary.append(tr("Octocopter Coax +"));
            break;
        case SetupWizard::MULTI_ROTOR_OCTO_V:
            summary.append(tr("Octocopter V"));
            break;
        default:
            summary.append(tr("Unknown"));
            break;
        }

        break;
    case VEHICLE_FIXEDWING:
        summary.append(tr("Fixed wing"));

        summary.append("<br>");
        summary.append("<b>").append(tr("Vehicle sub type: ")).append("</b>");
        switch (getVehicleSubType()) {
        case SetupWizard::FIXED_WING_DUAL_AILERON:
            summary.append(tr("Dual Aileron"));
            break;
        case SetupWizard::FIXED_WING_AILERON:
            summary.append(tr("Aileron"));
            break;
        case SetupWizard::FIXED_WING_ELEVON:
            summary.append(tr("Elevon"));
            break;
        default:
            summary.append(tr("Unknown"));
            break;
        }

        break;
    case VEHICLE_HELI:
        summary.append(tr("Helicopter"));
        break;
    case VEHICLE_SURFACE:
        summary.append(tr("Surface vehicle"));

        summary.append("<br>");
        summary.append("<b>").append(tr("Vehicle sub type: ")).append("</b>");
        switch (getVehicleSubType()) {
        case SetupWizard::GROUNDVEHICLE_CAR:
            summary.append(tr("Car"));
            break;
        case SetupWizard::GROUNDVEHICLE_DIFFERENTIAL:
            summary.append(tr("Tank"));
            break;
        case SetupWizard::GROUNDVEHICLE_MOTORCYCLE:
            summary.append(tr("Motorcycle"));
            break;
        default:
            summary.append(tr("Unknown"));
            break;
        }

        break;
    default:
        summary.append(tr("Unknown"));
    }

    summary.append("<br>");
    summary.append("<b>").append(tr("Input type: ")).append("</b>");
    switch (getInputType()) {
    case INPUT_PWM:
        summary.append(tr("PWM (One cable per channel)"));
        break;
    case INPUT_PPM:
        summary.append(tr("PPM (One cable for all channels)"));
        break;
    case INPUT_SBUS:
        summary.append(tr("Futaba S.Bus"));
        break;
    case INPUT_DSM:
        summary.append(tr("Spektrum Satellite"));
        break;
    default:
        summary.append(tr("Unknown"));
    }

    summary.append("<br>");
    summary.append("<b>").append(tr("Speed Controller (ESC) type: ")).append("</b>");
    switch (getEscType()) {
    case ESC_STANDARD:
        summary.append(tr("Standard ESC (%1 Hz)").arg(VehicleConfigurationHelper::LEGACY_ESC_FREQUENCY));
        break;
    case ESC_RAPID:
        summary.append(tr("Rapid ESC (%1 Hz)").arg(VehicleConfigurationHelper::RAPID_ESC_FREQUENCY));
        break;
    case ESC_SYNCHED:
        summary.append(tr("Synched ESC"));
        break;
    case ESC_ONESHOT:
        summary.append(tr("Oneshot ESC"));
        break;
    default:
        summary.append(tr("Unknown"));
    }

    // If Tricopter show tail servo speed
    if (getVehicleSubType() == MULTI_ROTOR_TRI_Y || getVehicleType() == VEHICLE_FIXEDWING
        || getVehicleSubType() == GROUNDVEHICLE_MOTORCYCLE || getVehicleSubType() == GROUNDVEHICLE_CAR) {
        summary.append("<br>");
        summary.append("<b>").append(tr("Servo type: ")).append("</b>");
        switch (getServoType()) {
        case SERVO_ANALOG:
            summary.append(tr("Analog Servos (50 Hz)"));
            break;
        case SERVO_DIGITAL:
            summary.append(tr("Digital Servos (333 Hz)"));
            break;
        default:
            summary.append(tr("Unknown"));
        }
    }

    // Show GPS Type
    if (getControllerType() == CONTROLLER_REVO || getControllerType() == CONTROLLER_NANO) {
        summary.append("<br>");
        summary.append("<b>").append(tr("GPS type: ")).append("</b>");
        switch (getGpsType()) {
        case GPS_PLATINUM:
            summary.append(tr("OpenPilot Platinum"));
            break;
        case GPS_UBX:
            summary.append(tr("OpenPilot v8 or Generic UBLOX GPS"));
            break;
        case GPS_NMEA:
            summary.append(tr("Generic NMEA GPS"));
            break;
        default:
            summary.append(tr("None"));
        }
    }

    // Show Airspeed sensor type
    if ((getControllerType() == CONTROLLER_REVO || getControllerType() == CONTROLLER_NANO) && getVehicleType() == VEHICLE_FIXEDWING) {
        summary.append("<br>");
        summary.append("<b>").append(tr("Airspeed Sensor: ")).append("</b>");
        switch (getAirspeedType()) {
        case AIRSPEED_ESTIMATE:
            summary.append(tr("Software Estimated"));
            break;
        case AIRSPEED_EAGLETREE:
            summary.append(tr("EagleTree on Flexi-Port"));
            break;
        case AIRSPEED_MS4525:
            summary.append(tr("MS4525 based on Flexi-Port"));
            break;
        default:
            summary.append(tr("Unknown"));
        }
    }
    return summary;
}