Java Code Examples for edu.wpi.first.wpilibj.livewindow.LiveWindow

The following are top voted examples for showing how to use edu.wpi.first.wpilibj.livewindow.LiveWindow. 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: FRCStronghold2016   File: CustomGyro.java   View source code 7 votes vote down vote up
/**
 * Initialize the gyro. Calibration is handled by calibrate().
 */
public void initGyro() {
  result = new AccumulatorResult();

  m_voltsPerDegreePerSecond = kDefaultVoltsPerDegreePerSecond;
  m_analog.setAverageBits(kAverageBits);
  m_analog.setOversampleBits(kOversampleBits);
  double sampleRate = kSamplesPerSecond * (1 << (kAverageBits + kOversampleBits));
  AnalogInput.setGlobalSampleRate(sampleRate);
  Timer.delay(0.1);

  setDeadband(0.0);

  setPIDSourceType(PIDSourceType.kDisplacement);

  UsageReporting.report(tResourceType.kResourceType_Gyro, m_analog.getChannel());
  LiveWindow.addSensor("AnalogGyro", m_analog.getChannel(), this);
}
 
Example 2
Project: 2017-emmet   File: RobotMap.java   View source code 6 votes vote down vote up
public static void init() {
	driveTrainCIMRearLeft = new CANTalon(2); // rear left motor
	driveTrainCIMFrontLeft = new CANTalon(12); // 
	driveTrainCIMRearRight = new CANTalon(1);
	driveTrainCIMFrontRight = new CANTalon(11);
	driveTrainRobotDrive41 = new RobotDrive(driveTrainCIMRearLeft, driveTrainCIMFrontLeft, 
			driveTrainCIMRearRight, driveTrainCIMFrontRight);
	climberClimber = new CANTalon(3);
    c1 = new Talon(5);
    pDPPowerDistributionPanel1 = new PowerDistributionPanel(0);
    gyro = new ADXRS450_Gyro(Port.kOnboardCS0);
    c2 = new Talon(6);
    ultra = new AnalogInput(0);
    
    LiveWindow.addSensor("PDP", "PowerDistributionPanel 1", pDPPowerDistributionPanel1);
    LiveWindow.addSensor("Ultra", "Ultra", ultra);
   //  LiveWindow.addActuator("Intake", "Intake", intakeIntake);
    LiveWindow.addActuator("Climber", "Climber", climberClimber);
    LiveWindow.addActuator("RearLeft (2)", "Drivetrain", driveTrainCIMRearLeft);
    LiveWindow.addActuator("FrontLeft (12)", "Drivetrain", driveTrainCIMFrontLeft);
    LiveWindow.addActuator("RearRight (1)", "Drivetrain", driveTrainCIMRearRight);
    LiveWindow.addActuator("FrontRight (11)", "Drivetrain", driveTrainCIMFrontRight);
    LiveWindow.addActuator("Drive Train", "Gyro", gyro);
    // LiveWindow.addActuator("Shooter", "Shooter", shooter1);
}
 
Example 3
Project: STEAMworks   File: AutoDriveDistance.java   View source code 6 votes vote down vote up
/**
* 
* @param distance target distance in inches
* @param timeOut time out in milliseconds
*/
  public AutoDriveDistance(double distance, long timeOut) {
      requires(Robot.driveTrain);
      //requires(Robot.ultrasonics);
      requires(Robot.navx);

      targetDistance = distance;
      timeMax = timeOut;

      turnController = new PIDController(kP, kI, kD, Robot.driveTrain, new MyPidOutput());
      //turnController.setInputRange(-180, 180);
      turnController.setOutputRange(-maxOutputRange, maxOutputRange);
      turnController.setAbsoluteTolerance(kToleranceDistance);
      turnController.setContinuous(true);
      
      /* Add the PID Controller to the Test-mode dashboard, allowing manual  */
      /* tuning of the Turn Controller's P, I and D coefficients.            */
      /* Typically, only the P value needs to be modified.                   */
      LiveWindow.addSensor("DriveSystem", "RotateController", turnController);
  }
 
Example 4
Project: STEAMworks   File: AutoSteerDriveToPeg.java   View source code 6 votes vote down vote up
private AutoSteerDriveToPeg() {
    requires(Robot.driveTrain);
    //requires(Robot.ultrasonics);
    //requires(Robot.visionTest);
    requires(Robot.navx);
    
    turnController = new PIDController(kP, kI, kD, Robot.navx.getAHRS(), new MyPidOutput());
    turnController.setInputRange(-maxAbsSetpoint, maxAbsSetpoint);
    turnController.setOutputRange(-maxOutputRange, maxOutputRange);
    turnController.setAbsoluteTolerance(kToleranceDegrees);
    turnController.setContinuous(true);
    
    /* Add the PID Controller to the Test-mode dashboard, allowing manual  */
    /* tuning of the Turn Controller's P, I and D coefficients.            */
    /* Typically, only the P value needs to be modified.                   */
    LiveWindow.addSensor("DriveSystem", "RotateController", turnController);
}
 
Example 5
Project: STEAMworks   File: AutoTurnByVision.java   View source code 6 votes vote down vote up
/**
* 
* @param speed forward speed is positive volts
*/
  public AutoTurnByVision(double speed) {
      requires(Robot.driveTrain);
      //requires(Robot.ultrasonics);
      requires(Robot.visionTest);
      requires(Robot.navx);

      forwardSpeed = -speed;
      turnController = new PIDController(kP, kI, kD, Robot.navx.getAHRS()/*Robot.visionTest*/, new MyPidOutput());
      turnController.setInputRange(-180, 180);
      turnController.setOutputRange(-maxOutputRange, maxOutputRange);
      turnController.setAbsoluteTolerance(kToleranceDegrees);
      turnController.setContinuous(true); // TODO is this what we want???
      
      /* Add the PID Controller to the Test-mode dashboard, allowing manual  */
      /* tuning of the Turn Controller's P, I and D coefficients.            */
      /* Typically, only the P value needs to be modified.                   */
      LiveWindow.addSensor("DriveSystem", "RotateController", turnController);
  }
 
Example 6
Project: FRC-2017-Public   File: ADXRS453_Gyro.java   View source code 6 votes vote down vote up
/**
 * Constructor.
 *
 * @param port
 *            (the SPI port that the gyro is connected to)
 */
public ADXRS453_Gyro(SPI.Port port) {
    m_spi = new SPI(port);
    m_spi.setClockRate(3000000);
    m_spi.setMSBFirst();
    m_spi.setSampleDataOnRising();
    m_spi.setClockActiveHigh();
    m_spi.setChipSelectActiveLow();

    /** Validate the part ID */
    if ((readRegister(kPIDRegister) & 0xff00) != 0x5200) {
        m_spi.free();
        m_spi = null;
        DriverStation.reportError("Could not find ADXRS453 gyro on SPI port " + port.value, false);
        return;
    }

    m_spi.initAccumulator(kSamplePeriod, 0x20000000, 4, 0x0c00000E, 0x04000000, 10, 16, true, true);

    calibrate();

    LiveWindow.addSensor("ADXRS453_Gyro", port.value, this);
}
 
Example 7
Project: FRC-Robotics-2016-Team-2262   File: Robot.java   View source code 6 votes vote down vote up
/**
 * This function is called periodically during test mode
 */
public void testPeriodic() {
	LiveWindow.run();
	encoder.reset(); 
	imu.calibrate();
	
	
	
	SmartDashboard.putNumber("Joystick X Axis", drive.joystick.getX());
	SmartDashboard.putNumber("Joystick Y Axis", drive.joystick.getY());

	// drive.turnRight(-1*.2);

	// drive.turnRight(.2);

	/*
	 * drive.frontLeft.set(.2); drive.rearLeft.set(.2);
	 * drive.frontRight.set(-1 * .2); drive.rearRight.set(-1 * .2);
	 * SmartDashboard.putNumber("Front Left CAN", drive.frontLeft.get());
	 * SmartDashboard.putNumber("Rear Left CAN", drive.rearLeft.get());
	 * SmartDashboard.putNumber("Front Right CAN", drive.frontRight.get());
	 * SmartDashboard.putNumber("Rear Right CAN", drive.rearRight.get());
	 */
}
 
Example 8
Project: FB2016   File: BallGetter.java   View source code 6 votes vote down vote up
public BallGetter() {
		
		super(1.005, 0, 0);
//		super(1.75, 0.04, 2.5);

		MAX_SPEED = getPreferencesDouble(RobotMap.PREF_BALL_GETTER_MAX_SPEED, 0.65);
		MIN_VALUE = getPreferencesDouble(RobotMap.PREF_BALL_GETTER_MIN_VALUE, .75);
		MAX_VALUE = getPreferencesDouble(RobotMap.PREF_BALL_GETTER_MAX_VAUE, 2.2);
		MAXGET_SPEED = getPreferencesDouble(RobotMap.PREF_BALL_GETTER_MAXGET_SPEED, 0.75);
		PARK_VALUE = getPreferencesDouble(RobotMap.PREF_BALL_GETTER_PARK_VALUE, .9);
		SIDE_SPEED = MAXGET_SPEED * 0.5;
		
		getPIDController().setInputRange(MIN_VALUE, MAX_VALUE);
		getPIDController().setAbsoluteTolerance(0.01);
		getPIDController().setToleranceBuffer(8);
		setSetpoint(2.1);
//		Robot.ballGetter.ballGetterPosition = 1;
		getPIDController().enable();
		LiveWindow.addActuator("BallGetter", "PIDSubsystem Controller", getPIDController());
		LiveWindow.addSensor("BallGetter", "current", RobotMap.ballGetterAngleMotor);
	}
 
Example 9
Project: FB2016   File: DefenseBuster.java   View source code 6 votes vote down vote up
public DefenseBuster() {
		super(0.5, 0, 0);
//		super(1.50, 0.03, 5.0);

		MAX_SPEED = getPreferencesDouble(RobotMap.PREF_DEFENSE_BUSTER_MAX_SPEED, 0.8);
		MIN_VALUE = getPreferencesDouble(RobotMap.PREF_DEFENSE_BUSTER_MIN_VALUE, 2.5);
		MAX_VALUE = getPreferencesDouble(RobotMap.PREF_DEFENSE_BUSTER_MAX_VALUE, 3.9);
		PARK_VALUE = getPreferencesDouble(RobotMap.PREF_DEFENSE_BUSTER_PARK_VALUE, 2.1);

		softFuse = new SoftFuse(angleMotor, 40, 1, 2);
		
		getPIDController().setInputRange(MIN_VALUE, MAX_VALUE);
		getPIDController().setAbsoluteTolerance(0.01);
		getPIDController().setToleranceBuffer(8);
		setSetpoint(PARK_VALUE);
		softFuse.positionFuse(angleMotor.getOutputCurrent());

		getPIDController().enable();
		LiveWindow.addActuator("DefenseBuster", "PIDSubsystem Controller", getPIDController());
	}
 
Example 10
Project: snobot-2017   File: Jaguar.java   View source code 6 votes vote down vote up
/**
 * Constructor.
 *
 * @param channel The PWM channel that the Jaguar is attached to. 0-9 are on-board, 10-19 are on
 *                the MXP port
 */
public Jaguar(final int channel) {
  super(channel);

  /*
   * Input profile defined by Luminary Micro.
   *
   * Full reverse ranges from 0.671325ms to 0.6972211ms Proportional reverse
   * ranges from 0.6972211ms to 1.4482078ms Neutral ranges from 1.4482078ms to
   * 1.5517922ms Proportional forward ranges from 1.5517922ms to 2.3027789ms
   * Full forward ranges from 2.3027789ms to 2.328675ms
   */
  setBounds(2.31, 1.55, 1.507, 1.454, .697);
  setPeriodMultiplier(PeriodMultiplier.k1X);
  setSpeed(0.0);
  setZeroLatch();

  HAL.report(tResourceType.kResourceType_Jaguar, getChannel());
  LiveWindow.addActuator("Jaguar", getChannel(), this);
}
 
Example 11
Project: snobot-2017   File: ADXRS450_Gyro.java   View source code 6 votes vote down vote up
/**
 * Constructor.
 *
 * @param port The SPI port that the gyro is connected to
 */
public ADXRS450_Gyro(SPI.Port port) {
  m_spi = new SPI(port);
  m_spi.setClockRate(3000000);
  m_spi.setMSBFirst();
  m_spi.setSampleDataOnRising();
  m_spi.setClockActiveHigh();
  m_spi.setChipSelectActiveLow();

  // Validate the part ID
  if ((readRegister(kPIDRegister) & 0xff00) != 0x5200) {
    m_spi.free();
    m_spi = null;
    DriverStation.reportError("could not find ADXRS450 gyro on SPI port " + port.value,
        false);
    return;
  }

  m_spi.initAccumulator(kSamplePeriod, 0x20000000, 4, 0x0c00000e, 0x04000000, 10, 16,
      true, true);

  calibrate();

  HAL.report(tResourceType.kResourceType_ADXRS450, port.value);
  LiveWindow.addSensor("ADXRS450_Gyro", port.value, this);
}
 
Example 12
Project: snobot-2017   File: Ultrasonic.java   View source code 6 votes vote down vote up
/**
 * Initialize the Ultrasonic Sensor. This is the common code that initializes the ultrasonic
 * sensor given that there are two digital I/O channels allocated. If the system was running in
 * automatic mode (round robin) when the new sensor is added, it is stopped, the sensor is added,
 * then automatic mode is restored.
 */
private synchronized void initialize() {
  if (m_task == null) {
    m_task = new UltrasonicChecker();
  }
  final boolean originalMode = m_automaticEnabled;
  setAutomaticMode(false); // kill task when adding a new sensor
  m_nextSensor = m_firstSensor;
  m_firstSensor = this;

  m_counter = new Counter(m_echoChannel); // set up counter for this
  // sensor
  m_counter.setMaxPeriod(1.0);
  m_counter.setSemiPeriodMode(true);
  m_counter.reset();
  m_enabled = true; // make it available for round robin scheduling
  setAutomaticMode(originalMode);

  m_instances++;
  HAL.report(tResourceType.kResourceType_Ultrasonic, m_instances);
  LiveWindow.addSensor("Ultrasonic", m_echoChannel.getChannel(), this);
}
 
Example 13
Project: Frc2016FirstStronghold   File: ADXRS450_Gyro.java   View source code 6 votes vote down vote up
/**
 * Constructor.
 *
 * @param port The SPI port that the gyro is connected to
 */
public ADXRS450_Gyro(SPI.Port port) {
  m_spi = new SPI(port);
  m_spi.setClockRate(3000000);
  m_spi.setMSBFirst();
  m_spi.setSampleDataOnRising();
  m_spi.setClockActiveHigh();
  m_spi.setChipSelectActiveLow();

  // Validate the part ID
  if ((readRegister(kPIDRegister) & 0xff00) != 0x5200) {
    m_spi.free();
    m_spi = null;
    DriverStation.reportError("could not find ADXRS450 gyro on SPI port " + port.getValue(), false);
    return;
  }

  m_spi.initAccumulator(kSamplePeriod, 0x20000000, 4, 0x0c000000, 0x04000000,
      10, 16, true, true);

  calibrate();

  UsageReporting.report(tResourceType.kResourceType_ADXRS450, port.getValue());
  LiveWindow.addSensor("ADXRS450_Gyro", port.getValue(), this);
}
 
Example 14
Project: Frc2016FirstStronghold   File: AnalogOutput.java   View source code 6 votes vote down vote up
/**
 * Construct an analog output on a specified MXP channel.
 *
 * @param channel The channel number to represent.
 */
public AnalogOutput(final int channel) {
  m_channel = channel;

  if (!AnalogJNI.checkAnalogOutputChannel(channel)) {
    throw new AllocationException("Analog output channel " + m_channel
        + " cannot be allocated. Channel is not present.");
  }
  try {
    channels.allocate(channel);
  } catch (CheckedAllocationException e) {
    throw new AllocationException("Analog output channel " + m_channel + " is already allocated");
  }

  long port_pointer = AnalogJNI.getPort((byte) channel);
  m_port = AnalogJNI.initializeAnalogOutputPort(port_pointer);

  LiveWindow.addSensor("AnalogOutput", channel, this);
  UsageReporting.report(tResourceType.kResourceType_AnalogOutput, channel);
}
 
Example 15
Project: Frc2016FirstStronghold   File: Ultrasonic.java   View source code 6 votes vote down vote up
/**
 * Initialize the Ultrasonic Sensor. This is the common code that initializes
 * the ultrasonic sensor given that there are two digital I/O channels
 * allocated. If the system was running in automatic mode (round robin) when
 * the new sensor is added, it is stopped, the sensor is added, then automatic
 * mode is restored.
 */
private synchronized void initialize() {
  if (m_task == null) {
    m_task = new UltrasonicChecker();
  }
  boolean originalMode = m_automaticEnabled;
  setAutomaticMode(false); // kill task when adding a new sensor
  m_nextSensor = m_firstSensor;
  m_firstSensor = this;

  m_counter = new Counter(m_echoChannel); // set up counter for this
  // sensor
  m_counter.setMaxPeriod(1.0);
  m_counter.setSemiPeriodMode(true);
  m_counter.reset();
  m_enabled = true; // make it available for round robin scheduling
  setAutomaticMode(originalMode);

  m_instances++;
  UsageReporting.report(tResourceType.kResourceType_Ultrasonic, m_instances);
  LiveWindow.addSensor("Ultrasonic", m_echoChannel.getChannel(), this);
}
 
Example 16
Project: Frc2016FirstStronghold   File: AnalogGyro.java   View source code 6 votes vote down vote up
/**
 * Initialize the gyro. Calibration is handled by calibrate().
 */
public void initGyro() {
  result = new AccumulatorResult();

  m_voltsPerDegreePerSecond = kDefaultVoltsPerDegreePerSecond;
  m_analog.setAverageBits(kAverageBits);
  m_analog.setOversampleBits(kOversampleBits);
  double sampleRate = kSamplesPerSecond * (1 << (kAverageBits + kOversampleBits));
  AnalogInput.setGlobalSampleRate(sampleRate);
  Timer.delay(0.1);

  setDeadband(0.0);

  setPIDSourceType(PIDSourceType.kDisplacement);

  UsageReporting.report(tResourceType.kResourceType_Gyro, m_analog.getChannel());
  LiveWindow.addSensor("AnalogGyro", m_analog.getChannel(), this);
}
 
Example 17
Project: Frc2016FirstStronghold   File: Solenoid.java   View source code 6 votes vote down vote up
/**
 * Common function to implement constructor behavior.
 */
private synchronized void initSolenoid() {
  checkSolenoidModule(m_moduleNumber);
  checkSolenoidChannel(m_channel);

  try {
    m_allocated.allocate(m_moduleNumber * kSolenoidChannels + m_channel);
  } catch (CheckedAllocationException e) {
    throw new AllocationException("Solenoid channel " + m_channel + " on module "
      + m_moduleNumber + " is already allocated");
  }

  long port = SolenoidJNI.getPortWithModule((byte) m_moduleNumber, (byte) m_channel);
  m_solenoid_port = SolenoidJNI.initializeSolenoidPort(port);

  LiveWindow.addActuator("Solenoid", m_moduleNumber, m_channel, this);
  UsageReporting.report(tResourceType.kResourceType_Solenoid, m_channel, m_moduleNumber);
}
 
Example 18
Project: Frc2016FirstStronghold   File: Relay.java   View source code 6 votes vote down vote up
/**
 * Common relay initialization method. This code is common to all Relay
 * constructors and initializes the relay and reserves all resources that need
 * to be locked. Initially the relay is set to both lines at 0v.
 */
private void initRelay() {
  SensorBase.checkRelayChannel(m_channel);
  try {
    if (m_direction == Direction.kBoth || m_direction == Direction.kForward) {
      relayChannels.allocate(m_channel * 2);
      UsageReporting.report(tResourceType.kResourceType_Relay, m_channel);
    }
    if (m_direction == Direction.kBoth || m_direction == Direction.kReverse) {
      relayChannels.allocate(m_channel * 2 + 1);
      UsageReporting.report(tResourceType.kResourceType_Relay, m_channel + 128);
    }
  } catch (CheckedAllocationException e) {
    throw new AllocationException("Relay channel " + m_channel + " is already allocated");
  }

  m_port = DIOJNI.initializeDigitalPort(DIOJNI.getPort((byte) m_channel));

  m_safetyHelper = new MotorSafetyHelper(this);
  m_safetyHelper.setSafetyEnabled(false);

  LiveWindow.addActuator("Relay", m_channel, this);
}
 
Example 19
Project: Frc2016FirstStronghold   File: AnalogInput.java   View source code 6 votes vote down vote up
/**
 * Construct an analog channel.
 *
 * @param channel The channel number to represent. 0-3 are on-board 4-7 are on
 *        the MXP port.
 */
public AnalogInput(final int channel) {
  m_channel = channel;

  if (!AnalogJNI.checkAnalogInputChannel(channel)) {
    throw new AllocationException("Analog input channel " + m_channel
        + " cannot be allocated. Channel is not present.");
  }
  try {
    channels.allocate(channel);
  } catch (CheckedAllocationException e) {
    throw new AllocationException("Analog input channel " + m_channel + " is already allocated");
  }

  long port_pointer = AnalogJNI.getPort((byte) channel);
  m_port = AnalogJNI.initializeAnalogInputPort(port_pointer);

  LiveWindow.addSensor("AnalogInput", channel, this);
  UsageReporting.report(tResourceType.kResourceType_AnalogChannel, channel);
}
 
Example 20
Project: Frc2016FirstStronghold   File: CANTalon.java   View source code 6 votes vote down vote up
/**
 * Constructor for the CANTalon device.
 * @param deviceNumber The CAN ID of the Talon SRX
 * @param controlPeriodMs The period in ms to send the CAN control frame.
 *                        Period is bounded to [1ms,95ms].
 */
public CANTalon(int deviceNumber, int controlPeriodMs) {
  m_deviceNumber = deviceNumber;
  /* bound period to be within [1 ms,95 ms] */
  m_handle = CanTalonJNI.new_CanTalonSRX(deviceNumber, controlPeriodMs);
  m_safetyHelper = new MotorSafetyHelper(this);
  m_controlEnabled = true;
  m_profile = 0;
  m_setPoint = 0;
  m_codesPerRev = 0;
  m_numPotTurns = 0;
  m_feedbackDevice = FeedbackDevice.QuadEncoder;
  setProfile(m_profile);
  applyControlMode(TalonControlMode.PercentVbus);
  LiveWindow.addActuator("CANTalon", m_deviceNumber, this);
}
 
Example 21
Project: Frc2017FirstSteamWorks   File: FrcTest.java   View source code 6 votes vote down vote up
@Override
public void runPeriodic(double elapsedTime)
{
    switch (test)
    {
        case SENSORS_TEST:
            //
            // Allow TeleOp to run so we can control the robot in sensors test mode.
            //
            super.runPeriodic(elapsedTime);
            doSensorsTest();
            break;

        case DRIVE_MOTORS_TEST:
            doDriveMotorsTest();
            break;

        case LIVE_WINDOW:
            LiveWindow.run();
            break;

        default:
            break;
    }
}
 
Example 22
Project: Robot_2017   File: RobotMap.java   View source code 5 votes vote down vote up
public static void init() {
      // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
  	compressor = new Compressor();
  	
      driveTrainLeftFront = new CANTalon(1);
      LiveWindow.addActuator("DriveTrain", "LeftFront", driveTrainLeftFront);
      driveTrainRightFront = new CANTalon(3);
      LiveWindow.addActuator("DriveTrain", "RightFront", driveTrainRightFront);
      driveTrainLeftRear = new CANTalon(2);
      driveTrainLeftRear.changeControlMode(TalonControlMode.Follower);
      driveTrainLeftRear.set(driveTrainLeftFront.getDeviceID());
      LiveWindow.addActuator("DriveTrain", "LeftRear", driveTrainLeftRear);
      driveTrainRightRear = new CANTalon(4);
      driveTrainRightRear.changeControlMode(TalonControlMode.Follower);
      driveTrainRightRear.set(driveTrainRightFront.getDeviceID());
      driveTrainRightRear.reverseOutput(false);
      LiveWindow.addActuator("DriveTrain", "RightRear", driveTrainRightRear);
      
      driveTrainLeftFront.setInverted(true);
      driveTrainRightFront.setInverted(true);
      driveTrainLeftRear.setInverted(true);
      driveTrainRightRear.setInverted(true);
      
      driveTrainRobotDrive41 = new RobotDrive(driveTrainRightFront, driveTrainLeftFront);
driveTrainRobotDrive41.setSafetyEnabled(true);
driveTrainRobotDrive41.setExpiration(0.1);
driveTrainRobotDrive41.setSensitivity(0.5);
driveTrainRobotDrive41.setMaxOutput(1.0);
      
      climbMotor = new CANTalon(5);
      LiveWindow.addActuator("Climbing", "Motor", climbMotor);
      
      lightsLightEnable = new Relay(0);
      LiveWindow.addActuator("Lights", "LightEnable", lightsLightEnable);
      
      gearIntakeRamp = new DoubleSolenoid(1, 0);
      LiveWindow.addActuator("GearIntake", "IntakeRamp", gearIntakeRamp);

      // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
  }
 
Example 23
Project: Robot_2017   File: Shooter.java   View source code 5 votes vote down vote up
public Shooter() {
	super();
	shooterFeeder = new CANTalon(8);
    LiveWindow.addActuator("Shooter", "Feeder", shooterFeeder);
    shooterFeeder.enableBrakeMode(false);
    
    shooterShootMotor = new CANTalon(7);
    LiveWindow.addActuator("Shooter", "ShootMotor", shooterShootMotor);
    shooterShootMotor.enableBrakeMode(false);
       /* choose the sensor */
    shooterShootMotor.setFeedbackDevice(FeedbackDevice.QuadEncoder);
    shooterShootMotor.reverseSensor(true);
    shooterShootMotor.configEncoderCodesPerRev(PulsesPerRevolution); // if using FeedbackDevice.QuadEncoder

       /* set the peak and nominal outputs, 12V means full */
    shooterShootMotor.configNominalOutputVoltage(+0.0f, -0.0f);
    shooterShootMotor.configPeakOutputVoltage(+12.0f, -12.0f);
       
       /* set closed loop gains in slot0 */
    shooterShootMotor.setProfile(0);
    shooterShootMotor.setF(pidF);
       shooterShootMotor.setP(pidP);	
       
       //only change I and D to smooth out control
       shooterShootMotor.setI(0); 
       shooterShootMotor.setD(0);
    
    shooterAgitator = new CANTalon(10);
    LiveWindow.addActuator("Shooter", "Agitator", shooterAgitator);
    shooterAgitator.enableBrakeMode(false);
}
 
Example 24
Project: Robot_2017   File: GearScore.java   View source code 5 votes vote down vote up
public GearScore() {
	super();
	
    gearScorePusher = new DoubleSolenoid(3, 4);
    LiveWindow.addActuator("GearScore", "Pusher", gearScorePusher);

    gearScoreDoor = new DoubleSolenoid(6, 5);
    LiveWindow.addActuator("GearScore", "Door", gearScoreDoor);
}
 
Example 25
Project: Robot_2017   File: BallIntake.java   View source code 5 votes vote down vote up
public BallIntake() {
	super();
	ballIntakeMotor = new CANTalon(9);
    LiveWindow.addActuator("BallIntake", "Intake", ballIntakeMotor);
    ballIntakeMotor.enableBrakeMode(false);
    
}
 
Example 26
Project: SteamWorks   File: RobotMap.java   View source code 5 votes vote down vote up
public static void init() {
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    driveTrainLeftFront = new Victor(0);
    LiveWindow.addActuator("DriveTrain", "LeftFront", (Victor) driveTrainLeftFront);
    
    driveTrainLeftRear = new Victor(1);
    LiveWindow.addActuator("DriveTrain", "LeftRear", (Victor) driveTrainLeftRear);
    
    driveTrainRightFront = new Victor(2);
    LiveWindow.addActuator("DriveTrain", "RightFront", (Victor) driveTrainRightFront);
    
    driveTrainRightRear = new Victor(3);
    LiveWindow.addActuator("DriveTrain", "RightRear", (Victor) driveTrainRightRear);
    
    driveTrainRobotDrive = new RobotDrive(driveTrainLeftFront, driveTrainLeftRear,
          driveTrainRightFront, driveTrainRightRear);
    
    driveTrainRobotDrive.setSafetyEnabled(false);
    driveTrainRobotDrive.setExpiration(0.1);
    driveTrainRobotDrive.setSensitivity(1.0);
    driveTrainRobotDrive.setMaxOutput(1.0);

    shootershooterTalon = new CANTalon(0);
    LiveWindow.addActuator("Shooter", "shooterTalon", shootershooterTalon);
    

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    // set this up
    gyro = new ADXRS450_Gyro();
}
 
Example 27
Project: Practice_Robot_Code   File: RobotMap.java   View source code 5 votes vote down vote up
public static void init() {
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    motorRelayMotorRelay1 = new Relay(0);
    LiveWindow.addActuator("MotorRelay", "MotorRelay1", motorRelayMotorRelay1);

    lFront = new CANTalon(1);
    LiveWindow.addActuator("Wheels", "Speed Controller 1", (CANTalon) lFront);
    
    rFront = new CANTalon(3);
    LiveWindow.addActuator("Wheels", "Speed Controller 2", (CANTalon) rFront);
    
    lRear = new CANTalon(2);
    LiveWindow.addActuator("Wheels", "Speed Controller 3", (CANTalon) lRear);
    
    rRear = new CANTalon(4);
    LiveWindow.addActuator("Wheels", "Speed Controller 4", (CANTalon) rRear);
    
    driveSystem = new RobotDrive(lFront, lRear,
          rFront, rRear);
    
    driveSystem.setSafetyEnabled(true);
    driveSystem.setExpiration(0.1);
    driveSystem.setSensitivity(0.5);
    driveSystem.setMaxOutput(1.0);
    
    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
 
Example 28
Project: Steamworks2017Robot   File: Robot.java   View source code 5 votes vote down vote up
/**
 * This function is called periodically during test mode.
 */
@Override
public void testPeriodic() {
  try {
    logger.trace("testPeriodic()");
    LiveWindow.run();
    vision.setVisionEnabled(true);
  } catch (Throwable ex) {
    logger.error("testPeriodic error", ex);
    ex.printStackTrace();
  }
}
 
Example 29
Project: GearBot   File: RobotMap.java   View source code 5 votes vote down vote up
public static void init() {
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    leftSideLeftPaddle = new Spark(0);
    LiveWindow.addActuator("LeftSide", "LeftPaddle", (Spark) leftSideLeftPaddle);
    
    leftSideLeftOut = new DigitalInput(0);
    LiveWindow.addSensor("LeftSide", "LeftOut", leftSideLeftOut);
    
    leftSideLeftIn = new DigitalInput(2);
    LiveWindow.addSensor("LeftSide", "LeftIn", leftSideLeftIn);
    
    rightSideRightPaddle = new Spark(1);
    LiveWindow.addActuator("RightSide", "RightPaddle", (Spark) rightSideRightPaddle);
    
    rightSideRightOut = new DigitalInput(1);
    LiveWindow.addSensor("RightSide", "RightOut", rightSideRightOut);
    
    rightSideRightIn = new DigitalInput(3);
    LiveWindow.addSensor("RightSide", "RightIn", rightSideRightIn);
    
    gearGate = new Spark(2);
    LiveWindow.addActuator("Gear", "Gate", (Spark) gearGate);
    
    gearGearIsIn = new DigitalInput(4);
    LiveWindow.addSensor("Gear", "GearIsIn", gearGearIsIn);
    

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
 
Example 30
Project: RobotCode2018   File: WPI_TalonSRXF.java   View source code 5 votes vote down vote up
/**
 * Constructor
 */
public WPI_TalonSRXF(int deviceNumber)
{
    super(deviceNumber);
    HAL.report(66, deviceNumber + 1);
    m_description = "Talon SRX " + deviceNumber;
    /* prep motor safety */
    m_safetyHelper = new MotorSafetyHelper(this);
    m_safetyHelper.setExpiration(0.0);
    m_safetyHelper.setSafetyEnabled(false);

    LiveWindow.add(this);
    setName("Talon SRX ", deviceNumber);
}
 
Example 31
Project: VikingRobot   File: Rotate.java   View source code 5 votes vote down vote up
public Rotate(double degrees) {
    super(.0125,.008,.2);
    requires(Robot.drivebase);
    getPIDController().setAbsoluteTolerance(1);
    getPIDController().setOutputRange(-.8,.8);
    setSetpoint(degrees);
    LiveWindow.addActuator("Drivebase", "RotateRelative PID Controller", getPIDController());
}
 
Example 32
Project: CMonster2017   File: DistancePID.java   View source code 5 votes vote down vote up
public DistancePID() {  
	
	super("DistancePID", 0.14, 0.0, 0.01);  //calls the parent constructor with arguments P,I,D
	//working PIDs: 0.24, 0, 0
	
	setAbsoluteTolerance(0.2);       // more parameters
	getPIDController().setContinuous(false);
	setInputRange(-10,  10);
    setOutputRange(-0.25, 0.25); //1/5 speed
    
    LiveWindow.addActuator("DistancePID", "DistancePID", getPIDController());
}
 
Example 33
Project: CMonster2017   File: HeadingPID.java   View source code 5 votes vote down vote up
public HeadingPID() {  
	super("HeadingPID", 0.06, 0.0, 0.0);  //calls the parent constructor with arguments P,I,D
	//keep P term at 0.06!!!!
	
	setAbsoluteTolerance(0.5);          // more parameters
	getPIDController().setContinuous(false);
	setInputRange(-180.0,  180.0);
    setOutputRange(-0.25, 0.25);
    
    LiveWindow.addActuator("HeadingPID", "HeadingPID", getPIDController());
}
 
Example 34
Project: CMonster2017   File: Robot.java   View source code 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 35
Project: 2017SteamBot2   File: DriveToAngle.java   View source code 5 votes vote down vote up
public DriveToAngle(double angle, PIDSource source) {
	requires(Robot.driveTrain);
	setPoint = angle;

	Robot.driveTrain.ahrs.reset();

	controller = new PIDController(0.75, 0, 0.9, 0, source, this);
	controller.setInputRange(-180, 180);
	controller.setOutputRange(-.26, .26);
	controller.setAbsoluteTolerance(1.0);
	controller.setContinuous(true);

	LiveWindow.addActuator("DriveToAngle", "RotationController", controller);
}
 
Example 36
Project: Stronghold   File: Drivetrain.java   View source code 5 votes vote down vote up
public void initDefaultCommand() {
    setDefaultCommand(new TankDrive());
    robotDrive.setInvertedMotor(MotorType.kFrontLeft, true);
    robotDrive.setInvertedMotor(MotorType.kRearLeft, true);
    LiveWindow.addActuator("Drive Motors", "fRight", fRight);
    LiveWindow.addActuator("Drive Motors", "fLeft", fLeft);
    LiveWindow.addActuator("Drive Motors", "bRight", bRight);
    LiveWindow.addActuator("Drive Motors", "bLeft", bLeft);
}
 
Example 37
Project: snobot-2017   File: ADXL362.java   View source code 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param port  The SPI port that the accelerometer is connected to
 * @param range The range (+ or -) that the accelerometer will measure.
 */
public ADXL362(SPI.Port port, Range range) {
  m_spi = new SPI(port);
  m_spi.setClockRate(3000000);
  m_spi.setMSBFirst();
  m_spi.setSampleDataOnFalling();
  m_spi.setClockActiveLow();
  m_spi.setChipSelectActiveLow();

  // Validate the part ID
  ByteBuffer transferBuffer = ByteBuffer.allocateDirect(3);
  transferBuffer.put(0, kRegRead);
  transferBuffer.put(1, kPartIdRegister);
  m_spi.transaction(transferBuffer, transferBuffer, 3);
  if (transferBuffer.get(2) != (byte) 0xF2) {
    m_spi.free();
    m_spi = null;
    DriverStation.reportError("could not find ADXL362 on SPI port " + port.value, false);
    return;
  }

  setRange(range);

  // Turn on the measurements
  transferBuffer.put(0, kRegWrite);
  transferBuffer.put(1, kPowerCtlRegister);
  transferBuffer.put(2, (byte) (kPowerCtl_Measure | kPowerCtl_UltraLowNoise));
  m_spi.write(transferBuffer, 3);

  HAL.report(tResourceType.kResourceType_ADXL362, port.value);
  LiveWindow.addSensor("ADXL362", port.value, this);
}
 
Example 38
Project: snobot-2017   File: AnalogOutput.java   View source code 5 votes vote down vote up
/**
 * Construct an analog output on a specified MXP channel.
 *
 * @param channel The channel number to represent.
 */
public AnalogOutput(final int channel) {
  m_channel = channel;

  SensorBase.checkAnalogOutputChannel(channel);

  final int portHandle = AnalogJNI.getPort((byte) channel);
  m_port = AnalogJNI.initializeAnalogOutputPort(portHandle);

  LiveWindow.addSensor("AnalogOutput", channel, this);
  HAL.report(tResourceType.kResourceType_AnalogOutput, channel);
}
 
Example 39
Project: snobot-2017   File: GearTooth.java   View source code 5 votes vote down vote up
/**
 * Construct a GearTooth sensor given a channel.
 *
 * @param channel            The DIO channel that the sensor is connected to. 0-9 are on-board,
 *                           10-25 are on the MXP port
 * @param directionSensitive True to enable the pulse length decoding in hardware to specify count
 *                           direction.
 */
public GearTooth(final int channel, boolean directionSensitive) {
  super(channel);
  enableDirectionSensing(directionSensitive);
  if (directionSensitive) {
    HAL.report(tResourceType.kResourceType_GearTooth, channel, 0, "D");
  } else {
    HAL.report(tResourceType.kResourceType_GearTooth, channel, 0);
  }
  LiveWindow.addSensor("GearTooth", channel, this);
}
 
Example 40
Project: snobot-2017   File: Encoder.java   View source code 5 votes vote down vote up
/**
 * Common initialization code for Encoders. This code allocates resources for Encoders and is
 * common to all constructors.
 *
 * <p>The encoder will start counting immediately.
 *
 * @param reverseDirection If true, counts down instead of up (this is all relative)
 */
private void initEncoder(boolean reverseDirection, final EncodingType type) {
  m_encoder = EncoderJNI.initializeEncoder(m_aSource.getPortHandleForRouting(),
      m_aSource.getAnalogTriggerTypeForRouting(), m_bSource.getPortHandleForRouting(),
      m_bSource.getAnalogTriggerTypeForRouting(), reverseDirection, type.value);

  m_pidSource = PIDSourceType.kDisplacement;

  HAL.report(tResourceType.kResourceType_Encoder, getFPGAIndex(), type.value);
  LiveWindow.addSensor("Encoder", m_aSource.getChannel(), this);
}