當前位置: 首頁>>代碼示例>>Java>>正文


Java LiveWindow.addSensor方法代碼示例

本文整理匯總了Java中edu.wpi.first.wpilibj.livewindow.LiveWindow.addSensor方法的典型用法代碼示例。如果您正苦於以下問題:Java LiveWindow.addSensor方法的具體用法?Java LiveWindow.addSensor怎麽用?Java LiveWindow.addSensor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.wpi.first.wpilibj.livewindow.LiveWindow的用法示例。


在下文中一共展示了LiveWindow.addSensor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initGyro

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:FRC4131,項目名稱:FRCStronghold2016,代碼行數:21,代碼來源:CustomGyro.java

示例2: init

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
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);
}
 
開發者ID:Team4914,項目名稱:2017-emmet,代碼行數:26,代碼來源:RobotMap.java

示例3: AutoDriveDistance

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
/**
* 
* @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);
  }
 
開發者ID:cyborgs3335,項目名稱:STEAMworks,代碼行數:25,代碼來源:AutoDriveDistance.java

示例4: AutoSteerDriveToPeg

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
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);
}
 
開發者ID:cyborgs3335,項目名稱:STEAMworks,代碼行數:18,代碼來源:AutoSteerDriveToPeg.java

示例5: AutoTurnByVision

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
/**
* 
* @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);
  }
 
開發者ID:cyborgs3335,項目名稱:STEAMworks,代碼行數:23,代碼來源:AutoTurnByVision.java

示例6: ADXRS453_Gyro

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:team8,項目名稱:FRC-2017-Public,代碼行數:29,代碼來源:ADXRS453_Gyro.java

示例7: ADXRS450_Gyro

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:31,代碼來源:ADXRS450_Gyro.java

示例8: AnalogOutput

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:trc492,項目名稱:Frc2016FirstStronghold,代碼行數:25,代碼來源:AnalogOutput.java

示例9: ADXRS450_Gyro

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:trc492,項目名稱:Frc2016FirstStronghold,代碼行數:30,代碼來源:ADXRS450_Gyro.java

示例10: AnalogInput

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:trc492,項目名稱:Frc2016FirstStronghold,代碼行數:26,代碼來源:AnalogInput.java

示例11: initialize

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:trc492,項目名稱:Frc2016FirstStronghold,代碼行數:29,代碼來源:Ultrasonic.java

示例12: BallGetter

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
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);
	}
 
開發者ID:firebears-frc,項目名稱:FB2016,代碼行數:22,代碼來源:BallGetter.java

示例13: init

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
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
}
 
開發者ID:ElectricGeorge,項目名稱:GearBot,代碼行數:30,代碼來源:RobotMap.java

示例14: init

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
public static void init() {
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    driveTrainLeftMotor = new Talon(0);
    LiveWindow.addActuator("DriveTrain", "LeftMotor", (Talon) driveTrainLeftMotor);
    
    driveTrainRightMotor = new Talon(1);
    LiveWindow.addActuator("DriveTrain", "RightMotor", (Talon) driveTrainRightMotor);
    
    driveTrainRobotDrive = new RobotDrive(driveTrainLeftMotor, driveTrainRightMotor);
    
    driveTrainRobotDrive.setSafetyEnabled(true);
    driveTrainRobotDrive.setExpiration(0.1);
    driveTrainRobotDrive.setSensitivity(0.5);
    driveTrainRobotDrive.setMaxOutput(1.0);

    intakeintakeMotor = new Talon(2);
    LiveWindow.addActuator("Intake", "intakeMotor", (Talon) intakeintakeMotor);
    
    pneumaticSystemCompressor = new Compressor(0);
    
    
    pneumaticSystemDoubleSolenoidPusher = new DoubleSolenoid(0, 0, 1);
    LiveWindow.addActuator("Pneumatic System", "DoubleSolenoidPusher", pneumaticSystemDoubleSolenoidPusher);
    
    sensorBaseUltraSonicMaxbotix = new AnalogInput(0);
    LiveWindow.addSensor("SensorBase", "UltraSonicMaxbotix", sensorBaseUltraSonicMaxbotix);

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
 
開發者ID:newheights,項目名稱:RobotBuilderTest,代碼行數:30,代碼來源:RobotMap.java

示例15: ADXL362

import edu.wpi.first.wpilibj.livewindow.LiveWindow; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:38,代碼來源:ADXL362.java


注:本文中的edu.wpi.first.wpilibj.livewindow.LiveWindow.addSensor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。