Java Code Examples for edu.wpi.first.wpilibj.smartdashboard.SmartDashboard

The following are top voted examples for showing how to use edu.wpi.first.wpilibj.smartdashboard.SmartDashboard. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Spartonics-Code   File: Robot.java   Source Code and License 6 votes vote down vote up
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
@Override
public void robotInit() {
	chassis = new Chassis();
	intake = new Intake();
	wheelintake = new wheelIntake();

	oi = new OI();
	chooser.addDefault("Default Auto", new DriveWithJoystick());
	// chooser.addObject("My Auto", new MyAutoCommand());
	SmartDashboard.putData("Auto mode", chooser);
	
	chassis.publishToSmartDashboard();
	

}
 
Example 2
Project: Spartonics-Code   File: Robot.java   Source Code and License 6 votes vote down vote up
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
public void robotInit() {


	chooser = new SendableChooser<Command>();
	chassis = new Chassis();
	intake = new Intake();
	winch = new Winch();
//	shooter = new Shooter();
	
	oi = new OI();
	imu = new ADIS16448_IMU(ADIS16448_IMU.Axis.kX);
	pdp = new PowerDistributionPanel();
	
	chooser.addDefault("Drive Straight", new DriveStraight(73, 0.5));
	//chooser.addObject("Left Gear Curve", new LeftGearCurve());
	chooser.addObject("Left Gear Turn", new LeftGearTurn());
	//chooser.addObject("Right Gear Curve", new RightGearCurve());
	chooser.addObject("Right Gear Turn", new RightGearTurn());
	chooser.addObject("Middle Gear", new StraightGear());
	chooser.addObject("Turn in place", new TurnDegrees(60, .2));
	SmartDashboard.putData("Autonomous Chooser", chooser);
}
 
Example 3
Project: Steamworks2017Robot   File: Vision.java   Source Code and License 6 votes vote down vote up
@Override
public void sendDataToSmartDashboard() {
  // phone handles vision data for us
  SmartDashboard.putBoolean("LED_On", isLedRingOn());

  boolean gearLiftPhone = false;
  boolean boilerPhone = false;
  ConnectionInfo[] connections = NetworkTablesJNI.getConnections();
  for (ConnectionInfo connInfo : connections) {
    if (System.currentTimeMillis() - connInfo.last_update < 100) {
      if (connInfo.remote_id.equals("Android_GEAR_LIFT")) {
        gearLiftPhone = true;
      } else if (connInfo.remote_id.equals("Android_BOILER")) {
        boilerPhone = true;
      }
    }
  }

  SmartDashboard.putBoolean("VisionGearLift", gearLiftPhone);
  SmartDashboard.putBoolean("VisionGearLift_data", isGearVisionDataValid());
  SmartDashboard.putBoolean("VisionBoiler", boilerPhone);
  SmartDashboard.putBoolean("VisionBoiler_data", isBoilerVisionDataValid());
}
 
Example 4
Project: STEAMworks   File: DriveTrain.java   Source Code and License 6 votes vote down vote up
@Override
public void log() {
	SmartDashboard.putNumber("DriveTrain: distance", getDistance());
	SmartDashboard.putNumber("DriveTrain: left distance", leftEncoder.getDistance());
	SmartDashboard.putNumber("DriveTrain: left velocity", leftEncoder.getRate());
	SmartDashboard.putNumber("DriveTrain: right distance", rightEncoder.getDistance());
	SmartDashboard.putNumber("DriveTrain: right velocity", rightEncoder.getRate());
	SmartDashboard.putNumber("DriveTrain: front right current", frontRight.getOutputCurrent());
	SmartDashboard.putNumber("DriveTrain: front right current pdp", Robot.pdp.getCurrent(12));
	SmartDashboard.putNumber("DriveTrain: front left  current", frontLeft.getOutputCurrent());
	SmartDashboard.putNumber("DriveTrain: front left  current pdp", Robot.pdp.getCurrent(10));
	SmartDashboard.putNumber("DriveTrain: back  right current", backRight.getOutputCurrent());
	SmartDashboard.putNumber("DriveTrain: back  right current pdp", Robot.pdp.getCurrent(13));
	SmartDashboard.putNumber("DriveTrain: back  left  current", backLeft.getOutputCurrent());
	SmartDashboard.putNumber("DriveTrain: back  left  current pdp", Robot.pdp.getCurrent(11));
}
 
Example 5
Project: Steamworks2017Robot   File: Shooter.java   Source Code and License 6 votes vote down vote up
/**
 * Sends shooter data to smart dashboard.
 */
public void sendDataToSmartDashboard() {
  if (RobotMap.IS_ROADKILL) {
    return;
  }
  SmartDashboard.putNumber("Shooter_Master_Talon_Power",
      shooterMaster.getOutputCurrent() * shooterMaster.getOutputVoltage());
  SmartDashboard.putNumber("Shooter_Slave_Talon_Power",
      shooterSlave.getOutputCurrent() * shooterSlave.getOutputVoltage());
  SmartDashboard.putNumber("Shooter_RPM_Requested", requestedRpm);
  SmartDashboard.putNumber("Shooter_RPM_Real", getShooterRpm());
  SmartDashboard.putNumber("Shooter_PID_error", shooterMaster.getClosedLoopError());
  
  SmartDashboard.putBoolean("Shooter_Fault", shooterFault);
  SmartDashboard.putBoolean("Shooter_Master_Ok", shooterMaster.getFaultHardwareFailure() == 0);
  SmartDashboard.putBoolean("Shooter_Master_Temp_Ok",
      shooterMaster.getStickyFaultOverTemp() == 0);
  SmartDashboard.putBoolean("Shooter_Slave_Ok", shooterSlave.getFaultHardwareFailure() == 0);
  SmartDashboard.putBoolean("Shooter_Slave_Temp_Ok", shooterSlave.getStickyFaultOverTemp() == 0);
  
  SmartDashboard.putBoolean("Shooter_Master_Present", shooterMaster.isAlive());
  SmartDashboard.putBoolean("Shooter_Slave_Present", shooterSlave.isAlive());
}
 
Example 6
Project: Robot_2017   File: AutonAimGear.java   Source Code and License 6 votes vote down vote up
protected void execute() {
 	//figure out how close is "close enough" because it's unlikely we'll ever get to 2.5 on the dot.  Figure this out through testing
 	
 	Robot.driveTrain.setTankDriveCommand(.6, .6);
 /*	if (Robot.pixyCamera.transaction(sendBuffer, sendBuffer.length, buffer, 1))
 	{
 		pixyValue = buffer[0]  & 0xFF;
 	} */
 	SmartDashboard.putNumber("pixyXAutonAimGear", Robot.pixyValue);
 	if ((int) Robot.pixyValue > 128 && (int) Robot.pixyValue != 255) //132
 			{
 		Robot.driveTrain.setTankDriveCommand(.3, .6);
 		SmartDashboard.putString("PixyImage", "turning right");
 	}
 	else if ((int) Robot.pixyValue < 126){
Robot.driveTrain.setTankDriveCommand(.6, .3);
SmartDashboard.putString("PixyImage", "turning left");//123
 	}
 	else if (Robot.pixyValue == 255)
 		SmartDashboard.putString("PixyImage", "no image");
 
 }
 
Example 7
Project: Steamworks2017Robot   File: DriveTrain.java   Source Code and License 6 votes vote down vote up
/**
 * Shifts the gearboxes up or down.
 * 
 * @param shiftType whether to shift up or down
 */
public void shift(ShiftType shiftType) {
  logger.info(String.format("Shifting, type=%s, shifter state=%s", shiftType.toString(),
      shiftingSolenoid.get().toString()));
  if (pcmPresent) {
    if (shiftType == ShiftType.TOGGLE) {
      if (shiftingSolenoid.get() == DoubleSolenoid.Value.kReverse) {
        shiftingSolenoid.set(DoubleSolenoid.Value.kForward);
        SmartDashboard.putBoolean("Drive_Shift", true);
      } else {
        shiftingSolenoid.set(DoubleSolenoid.Value.kReverse);
        SmartDashboard.putBoolean("Drive_Shift", false);
      }
    } else if (shiftType == ShiftType.UP) {
      shiftingSolenoid.set(DoubleSolenoid.Value.kForward);
      SmartDashboard.putBoolean("Drive_Shift", true);
    } else {
      shiftingSolenoid.set(DoubleSolenoid.Value.kReverse);
      SmartDashboard.putBoolean("Drive_Shift", false);
    }
  }
}
 
Example 8
Project: Robot_2017   File: Robot.java   Source Code and License 6 votes vote down vote up
public void robotPeriodic() {
	SmartDashboard.putNumber("Pixy X value", pixyValue  );
    //SmartDashboard.putBoolean("IsIngesting", isIngesting);
 
    SmartDashboard.putNumber("Right Encoder", DriveEncoders.getRawRightValue());
    SmartDashboard.putNumber("Left Encoder", DriveEncoders.getRawLeftValue());
    SmartDashboard.putNumber("Encoder Differences", DriveEncoders.getRawEncDifference());
    
    SmartDashboard.putNumber("Accelerometer", NavX.ahrs.getWorldLinearAccelY());
    SmartDashboard.putBoolean("IMU_TP_Connected", NavX.ahrs.isConnected());
    SmartDashboard.putNumber("IMU_Yaw", NavX.ahrs.getYaw());
         
    SmartDashboard.putNumber("Left Encoder Value: ", RobotMap.driveTrainLeftFront.getEncPosition());
    SmartDashboard.putNumber("Right Encoder Value: ", RobotMap.driveTrainRightFront.getEncPosition());
    //SmartDashboard.putNumber("Compressor", RobotMap.compressor.getCompressorCurrent());	
    SmartDashboard.putNumber("Left Trigger: ", Robot.lTrigger);
    SmartDashboard.putNumber("Right Trigger: ", Robot.rTrigger);
    //SmartDashboard.putBoolean("Door Status", doorsOpen);
    SmartDashboard.putNumber("camera", Robot.camera);

}
 
Example 9
Project: StormRobotics2017   File: Turn.java   Source Code and License 6 votes vote down vote up
protected void execute() {
	System.err.println("Execute turn");
	Robot.driveTrain.tankDrive(-_leftSpeed, _rightSpeed);//negative sign for turning
	SmartDashboard.putNumber("distance traveled",
			Math.max(Robot.driveTrain.getLeftDistance(), Robot.driveTrain.getRightDistance()));
	SmartDashboard.putNumber("Distance", _distanceL);

	// theoretically, this should print out current velocity of both wheels
	SmartDashboard.putNumber("LeftEncVelocity", Robot.driveTrain.getLeftSpeedEnc());
	SmartDashboard.putNumber("RightEncVelocity", Robot.driveTrain.getRightSpeedEnc());

	SmartDashboard.putNumber("LeftSpeed", Robot.driveTrain.getLeftSpeed());
	SmartDashboard.putNumber("RightSpeed", Robot.driveTrain.getRightSpeed());		
	
	if (Math.abs(Robot.driveTrain.getLeftDistance()) >= Math.abs(_distanceL)) {
		System.err.println("Done left!");
		_leftSpeed = 0;
	}
	if (Math.abs(Robot.driveTrain.getRightDistance()) >= Math.abs(_distanceR)) {
		System.err.println("Done right!");
		_rightSpeed = 0;
	}

}
 
Example 10
Project: BBLIB   File: bbShuffle.java   Source Code and License 6 votes vote down vote up
public static bbShuffle getInstance()
{
	if (bs == null)
	{
		bs = new bbShuffle();
		if(bs == null)
		{
			SmartDashboard.putBoolean("BS Exists?", false);
			System.out.println("bbShuffle can't make itself. Fix it pls");
			return null;
		}
		SmartDashboard.putBoolean("BS Exists?", true);
		System.out.println("bbShuffle created itself");
		return bs;
	}
	SmartDashboard.putBoolean("BS Exists?", true);
	return bs;
}
 
Example 11
Project: SteamWorks   File: OI.java   Source Code and License 6 votes vote down vote up
public OI() {
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS

    logitech = new Joystick(0);
    
    shooterbutton = new JoystickButton(logitech, 1);
    shooterbutton.whileHeld(new shoot());


    // SmartDashboard Buttons
    SmartDashboard.putData("Autonomous Command", new AutonomousCommand());
    SmartDashboard.putData("shoot", new shoot());

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    shootBackwardsButton = new JoystickButton(logitech, 2);
    shootBackwardsButton.whileHeld(new ShootReverse());

    LiftUPButton = new JoystickButton(logitech, 3);
    LiftReservseButton = new JoystickButton(logitech, 4);

    LiftUPButton.whileHeld(new LiftUP());
    LiftReservseButton.whileHeld(new LiftReverse());
}
 
Example 12
Project: Practice_Robot_Code   File: OI.java   Source Code and License 6 votes vote down vote up
public OI() {
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS

    xBoxController = new Joystick(0);
    
    aButton = new JoystickButton(xBoxController, 1);
    bButton = new JoystickButton(xBoxController, 2);
    xButton = new JoystickButton(xBoxController, 3);
    aButton.whenPressed(new RelayOn());
    //b button operated by default command only?
    bButton.whenPressed(new AllForward());
    xButton.whenPressed(new MotorPositionCheck());
    

    // SmartDashboard Buttons
    SmartDashboard.putData("Autonomous Command", new AutonomousCommand());
    SmartDashboard.putData("RelayOn", new RelayOn());
    SmartDashboard.putData("AllForward", new AllForward());
    SmartDashboard.putData("MotorPositionCheck", new MotorPositionCheck());
    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
 
Example 13
Project: Steamworks2017Robot   File: Robot.java   Source Code and License 6 votes vote down vote up
@Override
public void robotPeriodic() {
  try {
    // measure total cycle time, time we take during robotPeriodic, and WPIlib overhead
    final long start = System.nanoTime();
    logger.trace("robotPeriodic()");
    Scheduler.getInstance().run();

    long currentNanos = System.nanoTime();
    
    if (currentNanos - nanosAtLastUpdate > RobotMap.SMARTDASHBOARD_UPDATE_RATE * 1000000000) {
      allSubsystems.forEach(this::tryToSendDataToSmartDashboard);
      nanosAtLastUpdate = currentNanos;
    }
    
    SmartDashboard.putNumber("cycleMillis", (currentNanos - prevNanos) / 1000000.0);
    SmartDashboard.putNumber("ourTime", (currentNanos - start) / 1000000.0);
    prevNanos = currentNanos;
  } catch (Throwable ex) {
    logger.error("robotPeriodic error", ex);
    ex.printStackTrace();
  }
}
 
Example 14
Project: Spartonics-Code   File: Robot.java   Source Code and License 5 votes vote down vote up
public void publishToSmartDashboard(){
	chassis.publishToSmartDashboard();
	winch.publishToSmartDashboard();
	//shooter.publishToSmartDashboard();
	intake.publishToSmartDashboard();
	SmartDashboard.putNumber("Robot Angle", imu.getAngleX()/4);
    imu.updateTable();
	
}
 
Example 15
Project: Spartonics-Code   File: Robot.java   Source Code and License 5 votes vote down vote up
public void disabledPeriodic() {
	Scheduler.getInstance().run();
	
	SmartDashboard.putString("Selected Auto", chooser.getSelected().getName());
	publishToSmartDashboard();
	//SmartDashboard.putString("Selected Autonomous", chooser.getSelected().getName());
	
}
 
Example 16
Project: BBLIB   File: bbShuffle.java   Source Code and License 5 votes vote down vote up
public static void stri(String label, String data, boolean log)
{
	SmartDashboard.putString(label, data);
	if(log)
	{
		BulldogLogger.getInstance().log(label, data);
	}
}
 
Example 17
Project: Steamworks2017Robot   File: Feeder.java   Source Code and License 5 votes vote down vote up
/**
 * Sends diagnostics to SmartDashboard.
 */
public void sendDataToSmartDashboard() {
  SmartDashboard.putBoolean("Feeder_Present", feederTalon != null && feederTalon.isAlive());
  if (feederTalon != null) {
    SmartDashboard.putNumber("Feeder_Power",
        feederTalon.getOutputCurrent() * feederTalon.getOutputVoltage());
    
    SmartDashboard.putBoolean("Feeder_Ok", feederTalon.getFaultHardwareFailure() == 0);
    SmartDashboard.putBoolean("Feeder_Temp_Ok", feederTalon.getStickyFaultOverTemp() == 0);
  }
}
 
Example 18
Project: 2017-emmet   File: Robot.java   Source Code and License 5 votes vote down vote up
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
// @Override
public void robotInit() {
	
	System.out.println("1");
	
	RobotMap.init();
	
	drivetrain = new Drivetrain();
	climber = new Climber();
	// fuel = new Fuel();
	gear = new Gear();
	
	oi = new OI();
	
	// initializes camera server
	server = CameraServer.getInstance();
	cameraInit();
	
	// initializes auto chooser
	autoChooser = new SendableChooser();
	autoChooser.addDefault("Middle Hook", new AutoMiddleHook());
	autoChooser.addObject("Loading Station Hook", new AutoLeftHook());
	autoChooser.addObject("Boiler Side Hook", new AutoRightHook());
	SmartDashboard.putData("Auto mode", autoChooser);
	// auto delay
	SmartDashboard.putNumber("Auto delay", 0);
	
	// resets all sensors
	resetAllSensors();
}
 
Example 19
Project: FRC6414program   File: Shooter.java   Source Code and License 5 votes vote down vote up
public Shooter() {
    super();
    System.out.println("shooter sub system init");
    threadInit(() -> {
        SmartDashboard.putNumber("shooter l speed:", leftShooter.get());
        SmartDashboard.putNumber("shooter r speed:", rightShooter.get());
        SmartDashboard.putNumber("shooter set @", ((-Robot.oi.getThrottle() + 1) / 2) * 0.7 + 0.3);
    });
}
 
Example 20
Project: steamworks-java   File: DriveToPeg.java   Source Code and License 5 votes vote down vote up
public DriveToPeg(){		
	double distance = .2;
	
	requires(Robot.driveBase);
	double kP = -.4;
	double kI = 1;
	double kD = 5;
	
	pid = new PIDController(kP, kI, kD, new PIDSource() {
		PIDSourceType m_sourceType = PIDSourceType.kDisplacement;

		@Override
		public double pidGet() {
			return Robot.driveBase.getDistanceAhead();
		}

		@Override
		public void setPIDSourceType(PIDSourceType pidSource) {
			m_sourceType = pidSource;
		}

		@Override
		public PIDSourceType getPIDSourceType() {
			return m_sourceType;
		}
	}, new PIDOutput() {
		@Override
		public void pidWrite(double d) {
			Robot.driveBase.driveForward(d);
			System.out.println(d);
		}
	});
	pid.setAbsoluteTolerance(0.01);
	pid.setSetpoint(distance);
	pid.setOutputRange(0, .35);
	
	SmartDashboard.putData("driveToPeg", pid);
}
 
Example 21
Project: FRC6414program   File: USensor.java   Source Code and License 5 votes vote down vote up
public USensor() {
    leftPulse = new DigitalOutput(RobotMap.LEFT_PULSE);
    left = new Counter(RobotMap.LEFT_ECHO);
    left.setMaxPeriod(1);
    left.setSemiPeriodMode(true);
    left.reset();

    rightPulse = new DigitalOutput(RobotMap.RIGHT_PULSE);
    right = new Counter(RobotMap.RIGHT_ECHO);
    right.setMaxPeriod(1);
    right.setSemiPeriodMode(true);
    right.reset();

    threadInit(() -> {
        leftPulse.pulse(RobotMap.US_PULSE);
        rightPulse.pulse(RobotMap.US_PULSE);

        do {
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        } while (left.get() < 2 || right.get() < 2);

        leftDistant = left.getPeriod() * 0.5 * RobotMap.SPEED_OF_SOUND;
        rightDistant = right.getPeriod() * 0.5 * RobotMap.SPEED_OF_SOUND;

        SmartDashboard.putNumber("left dis", leftDistant);
        SmartDashboard.putNumber("right dis", rightDistant);

        left.reset();
        right.reset();
    });
}
 
Example 22
Project: KrunchieBot   File: Robot.java   Source Code and License 5 votes vote down vote up
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
@Override
public void robotInit() {
	oi = new OI();
	chooser.addDefault("Default Auto", new ExampleCommand());
	// chooser.addObject("My Auto", new MyAutoCommand());
	SmartDashboard.putData("Auto mode", chooser);
}
 
Example 23
Project: frc-2017   File: Robot.java   Source Code and License 5 votes vote down vote up
/**
 * This function is run when the robot is first started up and should be used for any initialization code.
 */
@Override
public void robotInit() {
	drive = new Drive();
	gearManipulator = new GearManipulator();
	intake = new Intake();
	shooter = new Shooter();
	storage = new Storage();
	climber = new Climber();
	elevator = new Elevator();
	vision = new Vision();
	visionProcessing = new LiveUsbCamera();
	oi = new OI();
	Robot.gearManipulator.gearManipulatorUp();
	chooser.addDefault("Center Gear Auto", new CenterGearAutonomous());
	chooser.addObject("Base Line Autonomous", new BaseLineAutonomous());
	chooser.addObject("Boiler side Blue auto", new BoilerSideBlueAuto());
	chooser.addObject("Boiler side Red auto", new BoilerSideRedAuto());
	chooser.addObject("Do Nothing Autonomous", null);

	double speed = Preferences.getInstance().getDouble(RobotMap.centerGearAutoSpeed, 0);
	double distance = Preferences.getInstance().getDouble(RobotMap.centerGearAutoDistance, 0);

	SmartDashboard.putData("Auto Mode", chooser);
	// xboxLeftTrigger.whileActive(new ClimberTriggerOn());
	xboxRightTrigger.whileActive(new RunShooter());

	visionProcessing.runUsbCamera();
}
 
Example 24
Project: CMonster2017   File: Robot.java   Source Code and License 5 votes vote down vote up
/**
 * This function is called periodically during test mode
 */
public void testPeriodic() {
	LiveWindow.run();
	Robot.driveBase.EnableDriveBase();
	Robot.driveBase.DriveAutonomous();
	SmartDashboard.putNumber("AV Distance", RobotMap.AverageDistance);
}
 
Example 25
Project: Steamworks2017Robot   File: PdpSubsystem.java   Source Code and License 5 votes vote down vote up
@Override
public void sendDataToSmartDashboard() {
  if (pdp != null) {
    SmartDashboard.putNumber("Temperature", pdp.getTemperature());
    //SmartDashboard.putNumber("TotalPower", pdp.getTotalPower());

    // in the past, this has tended to screw up the CAN bus
    // for (int i = 0; i < 16; i++) {
    // SmartDashboard.putNumber("Current_" + i, pdp.getCurrent(i));
    // }
  }
}
 
Example 26
Project: FIRSTSteamworks2017   File: Robot.java   Source Code and License 5 votes vote down vote up
public void robotPeriodic(){
	lights.set(1);
	SmartDashboard.putBoolean("Pressurized", !compressor.getPressureSwitchValue());
	SmartDashboard.putBoolean("PressureCharging", compressor.enabled());
	SmartDashboard.putBoolean("PressureControlled", compressor.getClosedLoopControl());
	SmartDashboard.putNumber("PressureCurrent", compressor.getCompressorCurrent());
}
 
Example 27
Project: FRC-2017-Command   File: ResetWinch.java   Source Code and License 5 votes vote down vote up
/**
 * Stop rotating the winch
 */
@Override
protected void end() {
    Robot.winch.off();
    logger.info("Winch reset");
    SmartDashboard.putBoolean("Winch Ready", true);

}
 
Example 28
Project: VikingRobot   File: Shoot.java   Source Code and License 5 votes vote down vote up
@Override
protected void execute() {
    double targetSpeed = .5* 1500;
    Robot.shooter.setSetpoint(targetSpeed);
    SmartDashboard.putNumber("Setpoint Set",targetSpeed);
    Robot.shooter.agitate();


}
 
Example 29
Project: 2017-Steamworks   File: DriveDistanceAccelY.java   Source Code and License 5 votes vote down vote up
protected void initialize() {
	// Reset for delta displacement
	Robot.driveTrain.resetAccel();
	
	Robot.driveTrain.enableAccelPIDY();
	Robot.driveTrain.setTargetDistanceY(SmartDashboard.getNumber("distanceDeltaY", 0));
}
 
Example 30
Project: STEAMworks   File: VisionTest.java   Source Code and License 5 votes vote down vote up
@Override
public void log() {
	double cx = centerX;
	SmartDashboard.putNumber("Vision: Center Value", cx);
	SmartDashboard.putNumber("Vision: Target Distance", targetDistance);
	SmartDashboard.putNumber("Vision: Target Azimuth", targetAzimuth);
	SmartDashboard.putNumber("Vision: Target X Offset", targetOffsetX);
	SmartDashboard.putBoolean("Vision: Target Detected", targetDetected);
}
 
Example 31
Project: 2017-Steamworks   File: DriveDistanceAccelX.java   Source Code and License 5 votes vote down vote up
protected void initialize() {
	// Reset for delta displacement
	Robot.driveTrain.resetAccel();
	
	Robot.driveTrain.enableAccelPIDX();
	Robot.driveTrain.setTargetDistanceX(SmartDashboard.getNumber("distanceDeltaX", 0));
}
 
Example 32
Project: El-Jefe-2017   File: ClawSet.java   Source Code and License 5 votes vote down vote up
protected void execute(){
	if(raise && !ignoreUp){
		clawLift.clawRaise(1);
	}
	else if(!raise && !ignoreDown){
		clawLift.clawRaise(-1);
	}
	SmartDashboard.putBoolean("raise", raise);
	SmartDashboard.putBoolean("ignoreUp", ignoreUp);
	SmartDashboard.putBoolean("ignoreDown", ignoreDown);
	SmartDashboard.putBoolean("up", clawLift.getLimitTop());
	SmartDashboard.putBoolean("down", clawLift.getLimitBottom());
}
 
Example 33
Project: 2017   File: SmartDashboardPIDTunerDevice.java   Source Code and License 5 votes vote down vote up
public void update ()
{
    double P = SmartDashboard.getNumber("DB/Slider 0", 0.0);
    double I = SmartDashboard.getNumber("DB/Slider 1", 0.0);
    double D = SmartDashboard.getNumber("DB/Slider 2", 0.0);
    double setPoint = SmartDashboard.getNumber("DB/Slider 3", 0.0);
    this.tuner.setP(P);
    this.tuner.setI(I);
    this.tuner.setD(D);
    this.tuner.setSetpoint(setPoint);
}
 
Example 34
Project: Steamworks2017Robot   File: GearManipulator.java   Source Code and License 5 votes vote down vote up
/**
 * Sends all diagnostics.
 */
public void sendDataToSmartDashboard() {
  SmartDashboard.putString("Gear_Mechanism_Position", position.toString());
  
  SmartDashboard.putNumber("Light_Spoke_Down", lsSpokeDown.getAverageVoltage());
  SmartDashboard.putNumber("Light_Wedge_Down", lsWedgeDown.getAverageVoltage());
  SmartDashboard.putString("Gear_Orientation", getGearOrientation().toString());
  SmartDashboard.putBoolean("Pressure_Plate", isPressurePlatePressed());
}
 
Example 35
Project: FRC-5800-Stronghold   File: CommandReadSensors.java   Source Code and License 5 votes vote down vote up
protected void execute() {		
	//Put any code here needed to handle readings from sensors.
	SmartDashboard.putNumber("Gyro", sensors.gyro.getAngle());
			
	SmartDashboard.putNumber("Drive Encoder L", sensors.driveEncoderL.get());
	SmartDashboard.putNumber("Drive Encoder R", sensors.driveEncoderR.get());
}
 
Example 36
Project: 2017-Steamworks   File: RotateToAngle.java   Source Code and License 5 votes vote down vote up
protected void initialize() {
	Robot.driveTrain.enableGyroPID();
	// Angle from SmartDash, default is the robots current angle
	double targetAngle = SmartDashboard.getNumber("targetAngle", Robot.driveTrain.getCurrentBoundedAngle());
	System.out.println(targetAngle);
	Robot.driveTrain.setTargetAngle(targetAngle);
}
 
Example 37
Project: DriveStraightBot   File: Drivetrain.java   Source Code and License 5 votes vote down vote up
public void startDrivingStraight(double speed) {
	controller.setPID(
			SmartDashboard.getNumber("kP", 0.0),
			SmartDashboard.getNumber("kI", 0.0),
			SmartDashboard.getNumber("kD", 0.0)
			);
	autoMoveSpeed = speed;
	if (!controller.isEnabled()) {
		gyro.reset();
		controller.reset();
		controller.enable();
	}
}
 
Example 38
Project: 2017-emmet   File: Robot.java   Source Code and License 5 votes vote down vote up
public void updateSensorDisplay() {
	// SENSORS \\
	SmartDashboard.putNumber("Drive Encoder", Robot.drivetrain.getEncoderPosition());
	SmartDashboard.putNumber("Gyro", Robot.drivetrain.getGyroBearing());
	SmartDashboard.putNumber("Gear Encoder", Robot.gear.getEncoderPosition());
	
}
 
Example 39
Project: 2017-emmet   File: Robot.java   Source Code and License 5 votes vote down vote up
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
public void robotInit() {
	RobotMap.init();
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    driveTrain = new DriveTrain();
    pDP = new PDP();
    intake = new Intake();
    climber = new Climber();
    shooter = new Shooter();

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    // OI must be constructed after subsystems. If the OI creates Commands
    //(which it very likely will), subsystems are not guaranteed to be
    // constructed yet. Thus, their requires() statements may grab null
    // pointers. Bad news. Don't move it.
    oi = new OI();
    
    // initializes networktable
    table = NetworkTable.getTable("HookContoursReport");
    
    // sets up camera switcher
    server = CameraServer.getInstance();
    server.startAutomaticCapture(0);
    // cameraInit();
    
    // set up sendable chooser for autonomous
    autoChooser = new SendableChooser();
    autoChooser.addDefault("Middle Hook", new AUTOMiddleHook());
    autoChooser.addObject("Left Hook", new AUTOLeftHook());
    autoChooser.addObject("RightHook", new AUTORightHook());
    SmartDashboard.putData("Auto Chooser", autoChooser);
    
    	
    // instantiate the command used for the autonomous period
    
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS
    

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS
}
 
Example 40
Project: StormRobotics2017   File: AutoDrive.java   Source Code and License 5 votes vote down vote up
@Override
protected boolean isFinished() {

	if (Math.abs(Robot.driveTrain.getLeftDistance()) >= Math.abs(_distanceL) && 
			Math.abs(Robot.driveTrain.getRightDistance()) >= Math.abs(_distanceR)) {
		table.putBoolean("Forward", false);
		System.err.println("Done drive forward!");
		Robot.driveTrain.percentVbusControl();
		Robot.driveTrain.tankDrive(0, 0);
		_leftSpeed = 0;
		_rightSpeed = 0;
		SmartDashboard.putNumber("LeftEncVelocity", Robot.driveTrain.getLeftSpeedEnc());
		SmartDashboard.putNumber("RightEncVelocity", Robot.driveTrain.getRightSpeedEnc());

		SmartDashboard.putNumber("LeftSpeed", Robot.driveTrain.getLeftSpeed());
		SmartDashboard.putNumber("RightSpeed", Robot.driveTrain.getRightSpeed());		
		table.putNumber("_leftSpeed", _leftSpeed);
		table.putNumber("_rightSpeed", _rightSpeed);
		table.putNumber("_distanceLimitLeft", _distanceL);
		table.putNumber("_distanceLimitRight", _distanceR);
		table.putNumber("_encoderDistanceLeft", Robot.driveTrain.getLeftDistance());
		table.putNumber("_encoderDistanceRight", Robot.driveTrain.getRightDistance());
		return true;
	} else {
		return false;
	}

}
 
Example 41
Project: STEAMworks   File: DoubleUltrasonic.java   Source Code and License 5 votes vote down vote up
@Override
public void log() {
	SmartDashboard.putNumber("Ultrasonic: Left Avg Volt", ultrasonicLeft.getAverageVoltage());
	SmartDashboard.putNumber("Ultrasonic: Right Avg Volt", ultrasonicRight.getAverageVoltage());
	SmartDashboard.putNumber("Ultrasonic: Left Distance", getDistanceLeft());
	SmartDashboard.putNumber("Ultrasonic: Right Distance", getDistanceRight());
}
 
Example 42
Project: StormRobotics2017   File: DFDSpeed.java   Source Code and License 5 votes vote down vote up
@Override
protected boolean isFinished() {

	if (Math.abs(Robot.driveTrain.getLeftDistance()) >= Math.abs(_distanceL) || 
			Math.abs(Robot.driveTrain.getRightDistance()) >= Math.abs(_distanceR)) {
		table.putBoolean("Forward", false);
		System.err.println("Done drive forward!");
		//Robot.driveTrain.percentVbusControl();
		Robot.driveTrain.tankDrive(0, 0);
		_leftSpeed = 0;
		_rightSpeed = 0;
		SmartDashboard.putNumber("LeftEncVelocity", Robot.driveTrain.getLeftSpeedEnc());
		SmartDashboard.putNumber("RightEncVelocity", Robot.driveTrain.getRightSpeedEnc());

		SmartDashboard.putNumber("LeftSpeed", Robot.driveTrain.getLeftSpeed());
		SmartDashboard.putNumber("RightSpeed", Robot.driveTrain.getRightSpeed());		
		table.putNumber("_leftSpeed", _leftSpeed);
		table.putNumber("_rightSpeed", _rightSpeed);
		table.putNumber("_distanceLimitLeft", _distanceL);
		table.putNumber("_distanceLimitRight", _distanceR);
		table.putNumber("_encoderDistanceLeft", Robot.driveTrain.getLeftDistance());
		table.putNumber("_encoderDistanceRight", Robot.driveTrain.getRightDistance());
		return true;
	} else {
		return false;
	}

}
 
Example 43
Project: 2017-Steamworks   File: GetStatus.java   Source Code and License 5 votes vote down vote up
protected void execute() {
	SmartDashboard.putNumber("GyroAngle", Robot.driveTrain.getCurrentRawAngle());
	SmartDashboard.putNumber("BoundedGyroAngle", Robot.driveTrain.getCurrentBoundedAngle());
	
	try {
		if (Robot.gearLoader.isSensorPresent()) {
			SmartDashboard.putNumber("Gear - ActualPosition", Robot.gearLoader.getPulseWidthPosition());
		}

	} catch (Exception e) {
		System.out.println("Error with gear subsystem: " + e.getMessage());
	}
}
 
Example 44
Project: StormRobotics2017   File: Robot.java   Source Code and License 5 votes vote down vote up
public void sendSensorData() {
		SmartDashboard.putNumber("Right Encoder", driveTrain.getRightDistance());
		SmartDashboard.putNumber("Left Encoder", driveTrain.getLeftDistance());
		SmartDashboard.putNumber("LeftEncVelocity", Robot.driveTrain.getLeftSpeedEnc());
		SmartDashboard.putNumber("RightEncVelocity", Robot.driveTrain.getRightSpeedEnc());
		SmartDashboard.putNumber("LeftSpeed", Robot.driveTrain.getLeftSpeed());
		SmartDashboard.putNumber("RightSpeed", Robot.driveTrain.getRightSpeed());
		SmartDashboard.putNumber("ShootFire Amount Turned", Robot.shoot.getShootFireDistance());
		SmartDashboard.putNumber("ShootFire EncVelocity", Robot.shoot.getShootFireSpeedEnc());
		SmartDashboard.putNumber("ShootFire EncPosition", Robot.shoot.getShootFireDistance());
		SmartDashboard.putNumber("Intake", Robot.oi.getIntake());
		SmartDashboard.putString("ShootFire Speed Control", Robot.shoot.getShootFireMode());
		SmartDashboard.putBoolean("ShootFire is PID?", Robot.shoot.isShootFirePID());
		SmartDashboard.putBoolean("getHighGear", Robot.gear.getHighGear());
		SmartDashboard.putBoolean("haltGear", Robot.gear.getHaltGear());
		SmartDashboard.putBoolean("Is HalfOne?", Robot.driveTrain.getHalfOne());
		SmartDashboard.putBoolean("Is HalfTwo?", Robot.driveTrain.getHalfTwo());
		SmartDashboard.putBoolean("Right Encoder Movement", Robot.driveTrain.encoderEnabledRight());
		SmartDashboard.putBoolean("Left Encoder Movement", Robot.driveTrain.encoderEnabledLeft());
		//pidf
		
		
		
		SmartDashboard.putNumber("GyroAngle", Robot.driveTrain.getGyroAngle());
		// SmartDashboard.putBoolean("PTO On", Robot.driveTrain.getPTO());
		SmartDashboard.putString("DriveTrain control mode", Robot.driveTrain.getDriveTrainControlMode());
		SmartDashboard.putBoolean("DriveTrain is PID?", Robot.driveTrain.isDriveTrainPID());
		SmartDashboard.putNumber("DriveTrain PID: LP", Robot.driveTrain.getLvalueP());
		SmartDashboard.putNumber("DriveTrain PID: LI", Robot.driveTrain.getLvalueI());
		SmartDashboard.putNumber("DriveTrain PID: LD", Robot.driveTrain.getLvalueD());
//		SmartDashboard.putNumber("DriveTrain PID: F", Robot.driveTrain.getValueF());
		
		
	}
 
Example 45
Project: wall-bounce   File: Robot.java   Source Code and License 5 votes vote down vote up
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
@Override
public void robotInit() {
	oi = new OI();
	chooser.addDefault("Default Auto", new ExampleCommand());
	// chooser.addObject("My Auto", new MyAutoCommand());
	SmartDashboard.putData("Auto mode", chooser);
}
 
Example 46
Project: FRC6706_JAVA2017   File: Robot.java   Source Code and License 5 votes vote down vote up
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
@Override
public void robotInit() {
	oi = new OI();
	autoChooser = new SendableChooser<Command>();
	autoChooser.addDefault("My Auto 1", new MyAutoCommand1());
	//autoChooser.addObject("My Auto 2", new MyAutoCommand2());
	//autoChooser.addObject("My Auto 3", new GyroDriveCommand(0.6, 0.6));
	SmartDashboard.putData("Auto mode", autoChooser);
}
 
Example 47
Project: Steamworks2017Robot   File: ManualControlWithTriggerCommand.java   Source Code and License 5 votes vote down vote up
protected void execute() {
  double value = Robot.operatorInterface.xboxController.getTriggerAxis(Hand.kRight)
      - Robot.operatorInterface.xboxController.getTriggerAxis(Hand.kLeft);
  //SmartDashboard.putNumber("ManualControl_value", value);
  switch (type) {
    case DRIVE_THROTTLE:
      Robot.driveTrain.rawThrottleTurnDrive(value, 0);
      break;
    case DRIVE_TURN:
      Robot.driveTrain.rawThrottleTurnDrive(0, value);
      break;
    case SHOOTER_RPM:
      Robot.shooter.setShooterPercentVBus(value);
      break;
    case INTAKE:
      Robot.intake.setIntakeRaw(value);
      break;
    case FEEDER:
      Robot.feeder.setFeeder(value);
      break;
    case GEAR_SERVO:
      Robot.gearManipulator.setServoRaw(SmartDashboard.getNumber("ManualControl_value", 0));
      break;
    case STIRRER_SERVO:
      Robot.stirrer.setStirrer(value);
      break;        
    default:
      break;
  }
}
 
Example 48
Project: RobotCode2018   File: DashboardData.java   Source Code and License 5 votes vote down vote up
private static void updateNavX()
{
    SmartDashboard.putNumber("NavX: Yaw", Robot.NAVX.getYaw());
    SmartDashboard.putNumber("NavX: X Displacement", Robot.NAVX.getDisplacementX());
    SmartDashboard.putNumber("NavX: Y Displacement", Robot.NAVX.getDisplacementY());
    SmartDashboard.putNumber("NavX: Z Displacement", Robot.NAVX.getDisplacementZ());
}
 
Example 49
Project: FRC-6416-frc2017   File: Robot.java   Source Code and License 5 votes vote down vote up
public void robotInit() {
/*UsbCamera camera = CameraServer.getInstance().startAutomaticCapture(); 
camera.setResolution(320,500);*/
	

/*
visionThread = new VisionThread(camera, new GripPipeline(), pipeline -> {
       if (!pipeline.filterContoursOutput().isEmpty()) {
           Rect r = Imgproc.boundingRect(pipeline.filterContoursOutput().get(0));
            
           synchronized (imgLock) {
               centerX = r.x + (r.width / 2);
               centerY = r.y + (r.height / 2);
              
               centerOrjin = -1.centerX 1-1.centerY);
               
               --|--
               
               
           }
       }
   });
   visionThread.start();
   */
   chooser.addDefault("Default Auto", defaultAuto);
chooser.addObject("My Auto", customAuto);
SmartDashboard.putData("Auto choices", chooser);		
}
 
Example 50
Project: Steamworks2017Robot   File: Robot.java   Source Code and License 5 votes vote down vote up
/**
 * This function is called periodically during operator control.
 */
@Override
public void teleopPeriodic() {
  try {
    SmartDashboard.putNumber("wpilibOverhead", (System.nanoTime() - prevNanos) / 1000000.0);
    logger.trace("teleopPeriodic()");
    vision.setVisionEnabled(true);
  } catch (Throwable ex) {
    logger.error("teleopPeriodic error", ex);
    ex.printStackTrace();
  }
}
 
Example 51
Project: Steamworks2017Robot   File: Intake.java   Source Code and License 5 votes vote down vote up
/**
 * Sends intake data to SmartDashboard.
 */
public void sendDataToSmartDashboard() {
  SmartDashboard.putBoolean("Intake_Present", intakeTalon != null && intakeTalon.isAlive());
  if (intakeTalon != null) {
    SmartDashboard.putNumber("Intake_Power",
        intakeTalon.getOutputCurrent() * intakeTalon.getOutputVoltage());
    SmartDashboard.putBoolean("Intake_On", intakeOn);
    
    SmartDashboard.putBoolean("Intake_Ok", intakeTalon.getFaultHardwareFailure() == 0);
    SmartDashboard.putBoolean("Intake_Temp_Ok", intakeTalon.getStickyFaultOverTemp() == 0);
  }
}
 
Example 52
Project: 2017-Steamworks   File: VisionPerpendicularAlignGear.java   Source Code and License 5 votes vote down vote up
protected void execute() {
	// Uses gyroPID to keep the target centered in the cameras view while
	// the robot strafes around the target so it is perpendicular (when the
	// areas of the two targets are equal)
	Robot.driveTrain.setTargetAngle(
			Robot.driveTrain.getCurrentBoundedAngle() + (Robot.vision.getGearTargetCenter() * 19.82));
	SmartDashboard.putNumber("TranslationWithTrackingGear", -Robot.vision.getGearTranslationPID());
	Robot.driveTrain.moveWithGyroPID(-Robot.vision.getGearTranslationPID(), Robot.oi.getTranslateY());
}
 
Example 53
Project: 2017-Steamworks   File: DriveGyroAssisted.java   Source Code and License 4 votes vote down vote up
protected void initialize() {
	Robot.driveTrain.enableGyroPID();
	Robot.driveTrain.setTargetAngle(SmartDashboard.getNumber("targetAngle", 0));
}
 
Example 54
Project: Spartonics-Code   File: FollowProfile.java   Source Code and License 4 votes vote down vote up
protected void execute() {
	SmartDashboard.putNumber("Left Profile Error", Robot.chassis.convertVelocityTicksToInchesPerSecond(Robot.chassis.getLeftEncoderCount())/10.0 - Robot.chassis.getLeftFollower().getSegment().position);
	SmartDashboard.putNumber("Right Profile Error", Robot.chassis.convertVelocityTicksToInchesPerSecond(Robot.chassis.getRightEncoderCount())/10.0 - Robot.chassis.getRightFollower().getSegment().position);

}
 
Example 55
Project: Spartonics-Code   File: Winch.java   Source Code and License 4 votes vote down vote up
public void publishToSmartDashboard(){
	SmartDashboard.putNumber("Winch Current", this.getCurrent());
}
 
Example 56
Project: Spartonics-Code   File: Intake.java   Source Code and License 4 votes vote down vote up
public void publishToSmartDashboard(){
	SmartDashboard.putNumber("Intake Amps", Robot.pdp.getCurrent(5));
}
 
Example 57
Project: Prototype-2017   File: DashboardUpdater.java   Source Code and License 4 votes vote down vote up
public synchronized void onLoop() {
    mDrive.outputToSmartDashboard();
    SmartDashboard.putNumber("Average Voltage:", mVoltage.getAverageVoltage());
    SmartDashboard.putNumber("Current Voltage:", DriverStation.getInstance().getBatteryVoltage());
}
 
Example 58
Project: FRC-2017-Public   File: SubsystemLooper.java   Source Code and License 4 votes vote down vote up
public void outputToSmartDashboard() {
	SmartDashboard.putNumber("looper_dt", mDt);
}
 
Example 59
Project: 2017-Steamworks   File: GearWheelRun.java   Source Code and License 4 votes vote down vote up
protected void execute() {
	//Robot.gearLoader.setGearWheelTalon(PVBUS);
	Robot.gearLoader.setGearWheelTalon(SmartDashboard.getNumber("GearWheelTalonFwd", 0.4));
}
 
Example 60
Project: FRC6414program   File: Stirrer.java   Source Code and License 4 votes vote down vote up
public Stirrer() {
    super();
    System.out.println("Mix sub system init");
    threadInit(() -> SmartDashboard.putNumber("Stirrer speed:", mixer.get()));
}