Ejemplo n.º 1
0
SUMOTime
MSLaneSpeedTrigger::processCommand(bool move2next, SUMOTime currentTime) {
    UNUSED_PARAMETER(currentTime);
    std::vector<MSLane*>::iterator i;
    const SUMOReal speed = getCurrentSpeed();
    for (i = myDestLanes.begin(); i != myDestLanes.end(); ++i) {
#ifdef HAVE_INTERNAL
        if (MSGlobals::gUseMesoSim) {
            MESegment* first = MSGlobals::gMesoNet->getSegmentForEdge((*i)->getEdge());
            while (first != 0) {
                first->setSpeed(speed, currentTime, -1);
                first = first->getNextSegment();
            }
            continue;
        }
#endif
        (*i)->setMaxSpeed(speed);
    }
    if (!move2next) {
        // changed from the gui
        return 0;
    }
    if (myCurrentEntry != myLoadedSpeeds.end()) {
        ++myCurrentEntry;
    }
    if (myCurrentEntry != myLoadedSpeeds.end()) {
        return ((*myCurrentEntry).first) - ((*(myCurrentEntry - 1)).first);
    } else {
        return 0;
    }
}
Ejemplo n.º 2
0
void displaySpeed(){
	int a,b,c,d;

	double currSpeed = getCurrentSpeed();
	double averSpeed = getAverageSpeed();
	//current speed in left most
	if(currSpeed >= 100){
		// only allow display two digits, display 99
		a = 9;
		b = 9;
	}else if(currSpeed > 10 ){
		// no decimal pt
		a = currSpeed / 10;
		setDecimalAnode0(false);
		b = (currSpeed - a * 10);
	}else{
		//1 digit + decimal
		a = currSpeed;
		setDecimalAnode0(true);
		b = (currSpeed * 10 ) - (a * 10);
	}

	if(averSpeed >= 100){
		// only allow display two digits, display 99
		c = 9;
		d = 9;
	}else if(averSpeed > 10 ){
		// no decimal pt
		c = averSpeed / 10;
		setDecimalAnode2(false);
		d = (averSpeed - c * 10);
	} else{
		//1 digit + decimal
		c = averSpeed;
		setDecimalAnode2(true);
		d = (averSpeed * 10 ) - (c * 10);
	}

	displayNumbers(a,b,c,d);
}
Ejemplo n.º 3
0
etatLocomotion CLocomotion::getCurrentState()
{
    etatLocomotion pos;
    pos = {getCurrentX(),getCurrentY(),getCurrentTheta(),getCurrentSpeed()};
    return pos;
}
Ejemplo n.º 4
0
static void printGpsInfo(void) {
    scheduleMsg(&logging, "GPS RX %s", hwPortname(boardConfiguration->gps_rx_pin));
    scheduleMsg(&logging, "GPS TX %s", hwPortname(boardConfiguration->gps_tx_pin));

    scheduleMsg(&logging, "m=%d,e=%d: vehicle speed = %f\r\n", gpsMesagesCount, uartErrors, getCurrentSpeed());

    float sec = currentTimeMillis() / 1000.0;
    scheduleMsg(&logging, "communication speed: %f", gpsMesagesCount / sec);

    print("GPS latitude = %f\r\n", GPSdata.latitude);
    print("GPS longitude = %f\r\n", GPSdata.longitude);
}
Ejemplo n.º 5
0
void
GUILaneSpeedTrigger::drawGL(const GUIVisualizationSettings& s) const {
    glPushName(getGlID());
    glPushMatrix();
    glTranslated(0, 0, getType());
    for (size_t i = 0; i < myFGPositions.size(); ++i) {
        const Position& pos = myFGPositions[i];
        SUMOReal rot = myFGRotations[i];
        glPushMatrix();
        glScaled(s.addExaggeration, s.addExaggeration, 1);
        glTranslated(pos.x(), pos.y(), 0);
        glRotated(rot, 0, 0, 1);
        glTranslated(0, -1.5, 0);

        int noPoints = 9;
        if (s.scale > 25) {
            noPoints = (int)(9.0 + s.scale / 10.0);
            if (noPoints > 36) {
                noPoints = 36;
            }
        }
        glColor3d(1, 0, 0);
        GLHelper::drawFilledCircle((SUMOReal) 1.3, noPoints);
        if (s.scale >= 5) {
            glTranslated(0, 0, .1);
            glColor3d(0, 0, 0);
            GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints);
            // draw the speed string
            // not if scale to low
            // compute
            SUMOReal value = (SUMOReal) getCurrentSpeed();
            if (myShowAsKMH) {
                value *= 3.6f;
                if (((int) value + 1) % 10 == 0) {
                    value = (SUMOReal)(((int) value + 1) / 10 * 10);
                }
            }
            if (value != myLastValue) {
                myLastValue = value;
                myLastValueString = toString<SUMOReal>(myLastValue);
                size_t idx = myLastValueString.find('.');
                if (idx != std::string::npos) {
                    if (idx > myLastValueString.length()) {
                        idx = myLastValueString.length();
                    }
                    myLastValueString = myLastValueString.substr(0, idx);
                }
            }
            //draw
            glColor3d(1, 1, 0);
            glTranslated(0, 0, .1);
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
            pfSetPosition(0, 0);
            pfSetScale(1.2f);
            SUMOReal w = pfdkGetStringWidth(myLastValueString.c_str());
            glRotated(180, 0, 1, 0);
            glTranslated(-w / 2., 0.3, 0);
            pfDrawString(myLastValueString.c_str());
        }
        glPopMatrix();
    }
    glPopMatrix();
    drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
    glPopName();
}
Ejemplo n.º 6
0
 double Motor::getSpeed()
 {
   return getCurrentSpeed();
 }