/** * This function is run when the robot is first started up and should be * used for any initialization code. */ public void robotInit() { // instantiate the command used for the autonomous period autonomousCommand = new AutonomousGroup(); // Initialize all subsystems CommandBase.init(); // Ouput program info to system log. System.out.println("+---------------------------------------------+"); System.out.println("| Team "+teamNo+" - Software Version: "+versionNo+" |"); System.out.println("+---------------------------------------------+"); // Output program info to driver station. DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser1, 1, "Team: "+teamNo+" - Software Version: "+versionNo); DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser2, 2, "Robot initialized."); DriverStationLCD.getInstance().updateLCD(); }
/** * */ public DriveTrain() { super("DriveTrain"); FLeftMotor = new Victor(RobotMap.FLeftMotorPWM); FRightMotor = new Victor(RobotMap.FRightMotorPWM); BLeftMotor = new Victor(RobotMap.BLeftMotorPWM); BRightMotor = new Victor(RobotMap.BRightMotorPWM); //MLeftMotor = new Victor(RobotMap.MLeftMotorPWM); //MRightMotor = new Victor(RobotMap.MRightMotorPWM); drive = new RobotDrive(FLeftMotor, BLeftMotor, FRightMotor, BRightMotor); //drive.setInvertedMotor(RobotDrive.MotorType.kFrontRight, true); //drive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, true); GShiftSolDown = new Solenoid(RobotMap.DriveTrainLowGearSolenoid); GShiftSolUp = new Solenoid(RobotMap.DriveTrainHighGearSolenoid); display = DriverStationLCD.getInstance(); }
/** * This method is run when the robot is first powered on. */ public void robotInit() { //initialize compressor compressor = new Compressor(RobotMap.pressureSwitch.getInt(), RobotMap.compressorRelay.getInt()); // Initialize all subsystems CommandBase.init(); //Initialize auto mode chooser autoSelectInit(); //create thread to write dashboard variables printer = new ConsolePrinter(200); printer.startThread(); //init message box on driverstation lcd = DriverStationLCD.getInstance(); //Console Message so we know robot finished loading System.out.println("****Robot Done Loading****"); }
/** * This method is run repeatedly while the robot is disabled. */ public void disabledPeriodic() { //get auto selection from dashboard and write it to lcd autonomousCommand = (AutoCommandGroup) autoChooser.getSelected(); lcd.println(DriverStationLCD.Line.kUser2, 1, autonomousCommand.getName()); lcd.updateLCD(); //Kill all active commands Scheduler.getInstance().removeAll(); Scheduler.getInstance().disable(); //Check to see if the gyro is drifting, if it is re-initialize it. gyroReinit(); //set arduino lights setArduinoAutonomousStatuses(); }
public static void printToDash(int line, String str) { DriverStationLCD dsLCD = DriverStationLCD.getInstance(); dsLCD.clear(); switch (line) { case 1: dsLCD.println(DriverStationLCD.Line.kUser1, 1, str); break; case 2: dsLCD.println(DriverStationLCD.Line.kUser2, 1, str); break; case 3: dsLCD.println(DriverStationLCD.Line.kUser3, 1, str); break; case 4: dsLCD.println(DriverStationLCD.Line.kUser4, 1, str); break; case 5: dsLCD.println(DriverStationLCD.Line.kUser5, 1, str); break; case 6: dsLCD.println(DriverStationLCD.Line.kUser6, 1, str); break; } dsLCD.updateLCD(); }
private void printToDash(int line, String str) { DriverStationLCD dsLCD = DriverStationLCD.getInstance(); switch (line) { case 1: dsLCD.println(DriverStationLCD.Line.kUser1, 1, str); break; case 2: dsLCD.println(DriverStationLCD.Line.kUser2, 1, str); break; case 3: dsLCD.println(DriverStationLCD.Line.kUser3, 1, str); break; case 4: dsLCD.println(DriverStationLCD.Line.kUser4, 1, str); break; case 5: dsLCD.println(DriverStationLCD.Line.kUser5, 1, str); break; case 6: dsLCD.println(DriverStationLCD.Line.kUser6, 1, str); break; } dsLCD.updateLCD(); }
private static void dsPrintln(String data) { dsBuffer.addElement(data); dsBuffer.removeElementAt(0); dash.println(DriverStationLCD.Line.kUser1, 1, (String) dsBuffer.elementAt(5)); dash.println(DriverStationLCD.Line.kUser6, 1, (String) dsBuffer.elementAt(4)); dash.println(DriverStationLCD.Line.kUser5, 1, (String) dsBuffer.elementAt(3)); dash.println(DriverStationLCD.Line.kUser4, 1, (String) dsBuffer.elementAt(2)); dash.println(DriverStationLCD.Line.kUser3, 1, (String) dsBuffer.elementAt(1)); dash.println(DriverStationLCD.Line.kUser2, 1, (String) dsBuffer.elementAt(0)); dash.updateLCD(); }
public ControlMode getControlMode() { if (controlMode.value == ControlMode.arcadeDrive.value) { DriverStationComm.printMessage(DriverStationLCD.Line.kUser1, 1, "Control mode: Arcade 2 Joystick"); } else if (controlMode.value == ControlMode.tankDrive.value) { DriverStationComm.printMessage(DriverStationLCD.Line.kUser1, 1, "Control mode: Tank"); } else { DriverStationComm.printMessage(DriverStationLCD.Line.kUser1, 1, "Control mode: Arcade 1 Joystick"); } return controlMode; }
/** * Very messy method. Shouldn't be that hard to figure out though. Read * through it carefully. :P */ public static void controlAutoAim() { if (toggleFeed == false) { if (autoAimButton.get() == true) { Angle.setAngle(Vision.calculateAngle()); AutoCenter.lineUpTarget(); } else if (autoAngleButton.get() == true) { Angle.setAngle(2.00); } //Angle Control code below is for testing, calibrating, and manual shooting if problems arise. else if (raiseAngleButton.get() == true) { Angle.angleUp(); } else if (lowerAngleButton.get() == true) { Angle.angleDown(); LCD.println(DriverStationLCD.Line.kUser4, 1, "lowering angleeee"); } else { Angle.angleStop(); } } else { //If toggleFeed is now true and climbButton is not pressed, go to feeder angle Angle.setAngle(feederAngle); //Feeder Angle (Approximately) } }
/** * This code might require a bit of operator control. If the robot is moving * too fast, it will over shoot and start oscillating. Operator must know * when to let go of the button. Following should be self-explanatory. Join * the build team if you do not understand. */ public static void lineUpTarget() { if (Vision.centerOfGravity() < largeMaxLeftBound) { DriveTrain.rotateDrive(largeTurningRightSpeed); LCD.println(DriverStationLCD.Line.kUser1, 1, "...Turning Left..."); } else if (Vision.centerOfGravity() > largeMaxRightBound) { DriveTrain.rotateDrive(largeTurningLeftSpeed); LCD.println(DriverStationLCD.Line.kUser1, 1, "...Turning Right..."); } else { if (Vision.centerOfGravity() < smallMaxLeftBound) { //Space between the last dot is to check that the loop is working correctly. DriveTrain.rotateDrive(smallTurningRightSpeed); LCD.println(DriverStationLCD.Line.kUser1, 1, "...Turning Left.. ."); } else if (Vision.centerOfGravity() > smallMaxRightBound) { DriveTrain.rotateDrive(smallTurningLeftSpeed); LCD.println(DriverStationLCD.Line.kUser1, 1, "...Turning Right.. ."); } else { DriveTrain.tankDrive(0, 0); LCD.println(DriverStationLCD.Line.kUser1, 1, "<Centered on Target>"); } } }
/** * Display a line of text without scrolling. Max 21 characters / line. * <p/> * @param ln Which line to print in * @param msg What message to display */ public void sayNOCLEAR(int ln, String msg) { if (msg == null) { msg = "null message passed"; } // DriverStationLCD.kLineLength=21 // Add 21 spaces to clear the rest of the line msg += " "; // If the given message is too long, truncate it if (msg.length() > 21) { msg = msg.substring(0, 21); } switch (ln) { case (1): output.println(DriverStationLCD.Line.kUser1, 1, msg); break; case (2): output.println(DriverStationLCD.Line.kUser2, 1, msg); break; case (3): output.println(DriverStationLCD.Line.kUser3, 1, msg); break; case (4): output.println(DriverStationLCD.Line.kUser4, 1, msg); break; case (5): output.println(DriverStationLCD.Line.kUser5, 1, msg); break; case (6): output.println(DriverStationLCD.Line.kUser6, 1, msg); break; } // Show the message output.updateLCD(); }
public void autonomousInit() { // schedule the autonomous command (example) //autonomousCommand.start(); // Ouput status info to driver station. DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser3, 2, "Started Autonomous."); }
public void teleopInit() { // This makes sure that the autonomous stops running when // teleop starts running. If you want the autonomous to // continue until interrupted by another command, remove // this line or comment it out. autonomousCommand.cancel(); // Output status info to driver station. DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser3, 2, "Started Tele-op."); }
/** * This function is called periodically during test mode */ public void testPeriodic() { LiveWindow.run(); // Output status info to driver station. DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser3, 2, "Started Test Mode."); }
/** * Log to Driver Station LCD. * * @param ln The line number from 1 to 6. * @param col The column - either 1 or 2. * @param text The line to send. */ public static void log(int ln, int col, String text) { Line line = lines[ln - 1]; int pos = col == 1 ? 1 : (DriverStationLCD.kLineLength / 2); text = text.trim();//.substring(0, (DriverStationLCD.kLineLength / 2) - 1); // Constrain clearLine(ln); ds.println(line, pos, text); update(); }
public static void clearLine(int line) { String pad = ""; for (int i = 0; i < DriverStationLCD.kLineLength; i++) { pad += " "; } ds.println(lines[line - 1], 1, pad); update(); }
public static void clear() { String pad = ""; for (int i = 0; i < DriverStationLCD.kLineLength; i++) { pad += " "; } for (int i = 0; i < 6; i++) { ds.println(lines[i], 1, pad); } update(); }
/** * * @param line which line to print the message on * @param msg the message to be sent */ public static void display(int line, String msg) { DriverStationLCD.Line l; switch (line) { case 1: /* kMain6 is depreciated - use kUser1 for top of the screen */ l = DriverStationLCD.Line.kUser1; break; case 2: l = DriverStationLCD.Line.kUser2; break; case 3: l = DriverStationLCD.Line.kUser3; break; case 4: l = DriverStationLCD.Line.kUser4; break; case 5: l = DriverStationLCD.Line.kUser5; break; case 6: l = DriverStationLCD.Line.kUser6; break; default: l = DriverStationLCD.Line.kUser2; break; } DriverStationLCD.getInstance().println(l, 1, msg); DriverStationLCD.getInstance().updateLCD(); }
/** * */ public Pass() { super("Pass"); launcher = AeronauticalFacilitation.getLauncher(); requires(launcher); display = DriverStationLCD.getInstance(); // Use requires() here to declare subsystem dependencies // eg. requires(chassis); }
protected void initialize() { counter++; delayTimer = RobotMap.ShooterDelayTimer; delayTimer.start(); display.println(DriverStationLCD.Line.kUser2, 1, "Pass command " + counter + " "); display.updateLCD(); }
/** * */ public Launch() { super("Launch"); launcher = AeronauticalFacilitation.getLauncher(); requires(launcher); display = DriverStationLCD.getInstance(); //TODO: add roller = here //TODO: add requires(roller) here // Use requires() here to declare subsystem dependencies // eg. requires(chassis); }
protected void initialize() { counter++; delayTimer = RobotMap.ShooterDelayTimer; delayTimer.start(); //TODO: use roller subsystem to lower the roller. display.println(DriverStationLCD.Line.kUser2, 1, "lauch command " + counter + " "); display.updateLCD(); }
/** * */ public void robotInit() { // instantiate the command used for the autonomous period DriveTrain = new DriveTrain(); launchercontroller = new Launcher(); rollerSubsystem = new Roller(); display = DriverStationLCD.getInstance(); compressor = new Compressor(RobotMap.PressureSwitchDigitalInput, RobotMap.CompressorRelay); compressor.start(); DriveTrain.shiftHighGear(); OI.initialize(); autonomousCommand = new Autonomous(); arduino = new ArduinoConnection(); arduino.setPattern("4"); pattern = 0; driverStation = DriverStation.getInstance(); alliance = driverStation.getAlliance().value; digital1 = driverStation.getDigitalIn(1); digital2 = driverStation.getDigitalIn(2); digital3 = driverStation.getDigitalIn(3); // Initialize all subsystems. // Subsystems: a self-contained system within a larger system. CommandBase.init(); }
/** * Print a boolean message to the User Messages box. * @param line * @param startingColumn * @param booleanMessage */ public static void printMessage(DriverStationLCD.Line line, int startingColumn, boolean booleanMessage) { String message = (booleanMessage ? "True" : "False"); printMessage(line, startingColumn, message); }
/** * Print a message to the User Messages box. * @param line * @param startingColumn * @param message */ public static void printMessage(DriverStationLCD.Line line, int startingColumn, String message) { String shortenedMessage = shortenMessage(message); LCD.println(line, startingColumn, shortenedMessage); LCD.updateLCD(); }
/** * Shorten the message for the LCD. * @param message * @return */ private static String shortenMessage(String message) { if (message.length() > DriverStationLCD.kLineLength) { return message.substring(0, DriverStationLCD.kLineLength); } else { return message; } }
/** * This function is called periodically during autonomous. */ public void autonomousPeriodic() { autonomousRoutine(); printUltrasonic(); DriverStationComm.printMessage(DriverStationLCD.Line.kUser5, 1, "Auton Cycle: " + autonCycles); autonCycles++; }
public void act() { arcadeThrottleValue = driveJoystick.getRawAxis( ARCADE_MOVE_JOYSTICK_AXIS.value); arcadeTurnValue = driveJoystick.getRawAxis( ARCADE_ROTATE_JOYSTICK_AXIS.value); pickupValue = operatorJoystick.getRawAxis(TRIGGER_AXIS.value); slowButton = driveJoystick.getRawButton(SLOW_MODE_BUTTON.value); curveTurnValues(); deadZone(); if (slowButton) { //slowDriveValues(); DriverStationComm.printMessage(DriverStationLCD.Line.kUser1, 4, "Slow Mode: ON"); } else { DriverStationComm.printMessage(DriverStationLCD.Line.kUser1, 4, "Slow Mode: OFF"); } winchButton = operatorJoystick.getRawButton( SHOOT_WITH_RESET_BUTTON.value); winchMomentButton = operatorJoystick.getRawButton( SHOOT_WITHOUT_RESET_BUTTON.value); winchStopButton = operatorJoystick.getRawButton(STOP_SHOOT_BUTTON.value); driverWinchButton = driveJoystick.getRawButton( DRIVER_SHOOT_WITH_RESET_BUTTON.value); pickupUpButton = operatorJoystick.getRawButton(PICKUP_UP_BUTTON.value); pickupDownButton = operatorJoystick.getRawButton( PICKUP_DOWN_BUTTON.value); }
/** * This function is run when the robot is first started up and should be * used for any initialization code. */ public void robotInit() { System.out.println("[INFO] ****** ROBOT IS READY FOR USE ******"); // Tell programmer(s)/Console reader that the Robot is initialized // and will now call console.init(); and then run the loop when the // VM initialization is complete. console.init(); // clears LCD Driver Station. LCD = DriverStationLCD.getInstance(); LCD.clear(); }
/** * Calculates Pi :), and prints out debugging data to the SmartDashboard. */ protected void execute() { // Calculate Pi!!!! (http://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80) // This method is really slow pi4 += (piPositive ? 1.0 : -1.0) / piIndex; piPositive = !piPositive; piIndex += 2.0; pi = pi4 * 4.0; // Print out Pi to the DS LCD (not the SmartDashboard) because it can // display more digits DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser1, 1, "Pi: " + pi); DriverStationLCD.getInstance().updateLCD(); // Pi // Report misc values SmartDashboard.putNumber("Gyro Rate", RobotMap.driveSubsystemSteeringGyro.getRate()); SmartDashboard.putNumber("Gyro Angle", RobotMap.driveSubsystemSteeringGyro.getAngle()); ADXL345_I2C.AllAxes accel = RobotMap.driveSubsystemAccelerometer.getAccelerations(); SmartDashboard.putNumber("X Acceleration", accel.XAxis); SmartDashboard.putNumber("Y Acceleration", accel.YAxis); String targetState; switch (TargetTrackingCommunication.getState().value) { case TargetTrackingCommunication.State.HOT_VALUE: targetState = "Hot"; break; case TargetTrackingCommunication.State.NOT_HOT_VALUE: targetState = "Not hot"; break; default: case TargetTrackingCommunication.State.UNKNOWN_VALUE: targetState = "Unknown"; break; } SmartDashboard.putString("Goal State", targetState); SmartDashboard.putNumber("Encoder Distance", RobotMap.driveSubsystemRearRightEncoder.getDistance()); SmartDashboard.putNumber("Temperature", RobotMap.driveSubsystemSteeringGyroTemp.getTemp()); Robot.ledSubsystem.updatePattern(); }
public MessageDisplay() { driverStationLCD = DriverStationLCD.getInstance(); displayLines = new DriverStationLCD.Line[6]; displayLines[0] = DriverStationLCD.Line.kUser1; displayLines[1] = DriverStationLCD.Line.kUser2; displayLines[2] = DriverStationLCD.Line.kUser3; displayLines[3] = DriverStationLCD.Line.kUser4; displayLines[4] = DriverStationLCD.Line.kUser5; displayLines[5] = DriverStationLCD.Line.kUser6; }
/** * Print a message to the "User messages" box in the driver station. * @param message the message to be printed * @param line the line number * @param startingColumn the column to start printing to */ public static void printMessage(String message, DriverStationLCD.Line line, int startingColumn) { if (message.length() > DriverStationLCD.kLineLength) { message = shortenMessage(message); } else { message = padMessage(message); } driverStationLCD.println(line, startingColumn, message); driverStationLCD.updateLCD(); }
/** * Clears the LCD display. */ public static void clear() { display.println(DriverStationLCD.Line.kUser1, 1, PADDING); display.println(DriverStationLCD.Line.kUser2, 1, PADDING); display.println(DriverStationLCD.Line.kUser3, 1, PADDING); display.println(DriverStationLCD.Line.kUser4, 1, PADDING); display.println(DriverStationLCD.Line.kUser5, 1, PADDING); display.println(DriverStationLCD.Line.kUser6, 1, PADDING); for (int i = 0; i < 6; i++) { printed[i] = false; } queueCount = 0; }
/** * Prints text to a specific line on the LCD display * * @param line Line number from [1,6]. * @param text String to print out. If it's longer than * {@link #MAX_LINE_LENGTH} characters, it will be truncated and a marker * ({@link #TRUNCATE_MARKER}) will be added on to the end. */ public static void println(int line, String text) { if (line < 1 || line > 6) { return; } //truncate the text if it's longer than the maximum length and add a marker to indicate that it was truncated if (text.length() > MAX_LINE_LENGTH) { text = text.substring(0, MAX_LINE_LENGTH - TRUNCATE_MARKER.length()) + TRUNCATE_MARKER; } switch (line) { case 1: display.println(DriverStationLCD.Line.kUser1, 1, text); break; case 2: display.println(DriverStationLCD.Line.kUser2, 1, text); break; case 3: display.println(DriverStationLCD.Line.kUser3, 1, text); break; case 4: display.println(DriverStationLCD.Line.kUser4, 1, text); break; case 5: display.println(DriverStationLCD.Line.kUser5, 1, text); break; case 6: display.println(DriverStationLCD.Line.kUser6, 1, text); break; } }
public void println (int i, int startingColumn, String msg) { DriverStationLCD.Line l; switch(i) { case 1: l = DriverStationLCD.Line.kUser1; break; case 2: l = DriverStationLCD.Line.kUser2; break; case 3: l = DriverStationLCD.Line.kUser3; break; case 4: l = DriverStationLCD.Line.kUser4; break; case 5: l = DriverStationLCD.Line.kUser5; break; case 6: l = DriverStationLCD.Line.kUser6; break; default: l = DriverStationLCD.Line.kUser1; break; }; DriverStationLCD.getInstance().println(l, startingColumn, msg); }
public RobotTemplate() { // initialize all the objects ingest = new VictorPair(5,6); elevator = new Victor(1); shooter = new VictorPair(2,4); robotDrive = new Drive(8, 7, 10, 9); xbox = new JStick(1); joystick = new JStick(2); compressor = new Compressor(4, 3); compressor.start(); driveGearA = new Solenoid(1); driveGearB = new Solenoid(2); driveGearA.set(true); driveGearB.set(false); selectedGear = 1; leftEnc = new Encoder(6, 7, true,CounterBase.EncodingType.k2X); leftEnc.setDistancePerPulse(0.103672558); rightEnc = new Encoder(9, 10, false); rightEnc.setDistancePerPulse(0.103672558); lcd = DriverStationLCD.getInstance(); }