CarControl Curve::drive(FSMDriver5 *FSMDriver5, CarState &cs) { float steer = getSteer(cs); int gear = StraightLine::getGear(cs); float accel = getAccel(cs); float brake = getBrake(cs); float clutch = 0; return CarControl(accel, brake, gear, steer, clutch); }
CarControl ApproachingCurve::drive(FSMDriver5 *FSMDriver5, CarState &cs) { if(!sensorsAreUpdated) /*@todo Só atualiza na 1a vez mesmo? */ updateSensors(cs); const int focus = 0, meta = 0; const float clutch = 0; return CarControl(getAccel(cs), getBrake(cs), getGear(cs), cs.getAngle(), clutch, focus, meta); //Use the line below if the behavior of adjusting the car to the curve ahead is desired (not fully functional): //return CarControl(getAccel(cs), getBrake(cs), getGear(cs), getSteering(cs), clutch, focus, meta); }
string SimpleDriver::drive(string sensors) { CarState cs(sensors); CarControl nextVector = CarControl(0.0f, 0.0f, cs.getGear(), 0.0f, 0.0f); if (automatedControl == NULL) { Keyboard_Update(&nextVector); log->push_back(pair<CarState, CarControl>(cs, nextVector)); } else { this->automatedControl->generateVector(&cs, &nextVector); } return nextVector.toString(); }
CarControl Stuck::drive(FSMDriver5 *fsmdriver5, CarState &cs) { ++elapsedTicks; trackInitialPos = getInitialPos(cs); if(notStuckAnymore(cs.getTrackPos(), cs.getAngle()) || hasBeenStuckLongEnough()){ elapsedTicks = 0; slowSpeedTicks = 0; trackInitialPos = 0; } const float accel = 1, brake = 0, clutch = 0; const int gear = -1, focus = 0, meta = 0; float steer = getSteer(trackInitialPos, cs); return CarControl(accel, brake, gear, steer, clutch, focus, meta); }
CarControl Stuck::drive(CarState &cs) { ++elapsed_ticks; track_initial_pos = getInitialPos(cs); if(notStuckAnymore(cs) || hasBeenStuckLongEnough()) { elapsed_ticks = 0; slow_speed_ticks = 0; track_initial_pos = 0; } int gear = get_gear(cs); float accel = get_accel(cs); float brake = get_brake(cs); float clutch = get_clutch(cs); const int focus = 0, meta = 0; float steer = auxSteer(track_initial_pos, cs); return CarControl(accel, brake, gear, steer, clutch, focus, meta); }