public static void main(String[] args) throws Exception { new RaceMain(); // Race Settings.PILOT.setTravelSpeed(Settings.PILOT.getMaxTravelSpeed() * 0.70); Settings.PILOT.setRotateSpeed(Settings.PILOT.getMaxRotateSpeed() / 4); Motor.A.setSpeed(Motor.A.getMaxSpeed() / 5); new SensorHeadCalibrate(); Settings.motorAAngle = Settings.SENSOR_RIGHT; Settings.atStart = false; new LightCalibrate(); Behavior b1 = new RaceFollowWall(13); Behavior b2 = new Race(); Behavior b4 = new ReadCodes(); Behavior b3 = new RaceDrive(); Behavior b5 = new SensorHeadPosition(); Behavior b6 = new MotorAStall(); Behavior[] bArray = {b1, b2, b4, b3, b5, b6}; CustomArbitrator arbitrator = new CustomArbitrator(bArray); Thread t = new Thread(arbitrator); t.start(); }
/** The robot moves along the Wall and turns to the right, if the wall is too far away. */ @Override public void action() { suppressed = false; Settings.motorAAngle = Settings.SENSOR_RIGHT; while (!suppressed && !((Settings.TOUCH_L.isPressed() || Settings.TOUCH_R.isPressed())) && Settings.LIGHT.getLightValue() < 80) { if (sonic.getDistance() > (distanceToWall + 10)) { pilot.arc(-15, -90, true); } else if (sonic.getDistance() <= distanceToWall) { pilot.arc(40, 20, true); } else if (sonic.getDistance() > distanceToWall) { pilot.arc(-60, -20, true); } } if (Settings.LIGHT.getLightValue() >= 80) { pilot.stop(); System.out.println("LINE Detected"); Settings.afterSlider = true; Settings.motorAAngle = Settings.SENSOR_FRONT; Settings.PILOT.setTravelSpeed(Settings.PILOT.getMaxTravelSpeed() * 0.15); } }