本文整理汇总了Java中edu.wpi.first.wpilibj.communication.UsageReporting类的典型用法代码示例。如果您正苦于以下问题:Java UsageReporting类的具体用法?Java UsageReporting怎么用?Java UsageReporting使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UsageReporting类属于edu.wpi.first.wpilibj.communication包,在下文中一共展示了UsageReporting类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initGyro
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的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);
}
示例2: SerialPort
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的package包/类
/**
* Create an instance of a Serial Port class.
*
* @param baudRate The baud rate to configure the serial port.
* @param port The Serial port to use
* @param dataBits The number of data bits per transfer. Valid values are
* between 5 and 8 bits.
* @param parity Select the type of parity checking to use.
* @param stopBits The number of stop bits to use as defined by the enum
* StopBits.
*/
public SerialPort(final int baudRate, Port port, final int dataBits, Parity parity,
StopBits stopBits) {
m_port = (byte) port.getValue();
SerialPortJNI.serialInitializePort(m_port);
SerialPortJNI.serialSetBaudRate(m_port, baudRate);
SerialPortJNI.serialSetDataBits(m_port, (byte) dataBits);
SerialPortJNI.serialSetParity(m_port, (byte) parity.value);
SerialPortJNI.serialSetStopBits(m_port, (byte) stopBits.value);
// Set the default read buffer size to 1 to return bytes immediately
setReadBufferSize(1);
// Set the default timeout to 5 seconds.
setTimeout(5.0f);
// Don't wait until the buffer is full to transmit.
setWriteBufferMode(WriteBufferMode.kFlushOnAccess);
disableTermination();
UsageReporting.report(tResourceType.kResourceType_SerialPort, 0);
}
示例3: initCounter
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的package包/类
private void initCounter(final Mode mode) {
ByteBuffer index = ByteBuffer.allocateDirect(4);
// set the byte order
index.order(ByteOrder.LITTLE_ENDIAN);
m_counter = CounterJNI.initializeCounter(mode.value, index.asIntBuffer());
m_index = index.asIntBuffer().get(0);
m_allocatedUpSource = false;
m_allocatedDownSource = false;
m_upSource = null;
m_downSource = null;
setMaxPeriod(.5);
UsageReporting.report(tResourceType.kResourceType_Counter, m_index, mode.value);
}
示例4: initJaguar
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的package包/类
/**
* Common initialization code called by all constructors.
*/
private void initJaguar() {
/*
* 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);
setRaw(m_centerPwm);
setZeroLatch();
UsageReporting.report(tResourceType.kResourceType_Jaguar, getChannel());
LiveWindow.addActuator("Jaguar", getChannel(), this);
}
示例5: ADXRS450_Gyro
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的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);
}
示例6: AnalogOutput
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的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);
}
示例7: initialize
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的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);
}
示例8: initPWM
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的package包/类
/**
* Initialize PWMs given a channel.
*
* This method is private and is the common path for all the constructors for
* creating PWM instances. Checks channel value ranges and allocates the
* appropriate channel. The allocation is only done to help users ensure that
* they don't double assign channels.
*$
* @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the
* MXP port
*/
private void initPWM(final int channel) {
checkPWMChannel(channel);
m_channel = channel;
m_port = DIOJNI.initializeDigitalPort(DIOJNI.getPort((byte) m_channel));
if (!PWMJNI.allocatePWMChannel(m_port)) {
throw new AllocationException("PWM channel " + channel + " is already allocated");
}
PWMJNI.setPWM(m_port, (short) 0);
m_eliminateDeadband = false;
UsageReporting.report(tResourceType.kResourceType_PWM, channel);
}
示例9: initSolenoid
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的package包/类
/**
* 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);
}
示例10: init
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的package包/类
/**
* Set SPI bus parameters, bring device out of sleep and set format
*
* @param range The range (+ or -) that the accelerometer will measure.
*/
private void init(Range range) {
m_spi.setClockRate(500000);
m_spi.setMSBFirst();
m_spi.setSampleDataOnFalling();
m_spi.setClockActiveLow();
m_spi.setChipSelectActiveHigh();
// Turn on the measurements
byte[] commands = new byte[2];
commands[0] = kPowerCtlRegister;
commands[1] = kPowerCtl_Measure;
m_spi.write(commands, 2);
setRange(range);
UsageReporting.report(tResourceType.kResourceType_ADXL345, tInstances.kADXL345_SPI);
}
示例11: initRelay
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的package包/类
/**
* 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);
}
示例12: AnalogInput
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的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);
}
示例13: AnalogGyro
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的package包/类
/**
* Gyro constructor with a precreated analog channel object. Use this
* constructor when the analog channel needs to be shared.
*
* @param channel The AnalogInput object that the gyro is connected to.
* Analog gyros can only be used on on-board channels 0-1.
*/
public AnalogGyro(AnalogInput channel) {
analogInput = channel;
if (analogInput == null) {
throw new NullPointerException("AnalogInput supplied to AnalogGyro constructor is null");
}
result = new AccumulatorResult();
analogInput.setAverageBits(DEFAULT_AVERAGE_BITS);
analogInput.setOversampleBits(DEFAULT_OVERSAMPLE_BITS);
updateSampleRate();
analogInput.initAccumulator();
UsageReporting.report(tResourceType.kResourceType_Gyro, analogInput.getChannel(), 0,
"Custom more flexible implementation");
LiveWindow.addSensor("Analog Gyro", analogInput.getChannel(), this);
calibrate(DEFAULT_CALIBRATION_TIME);
}
示例14: tankDrive
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的package包/类
/**
* Provide tank steering using the stored robot configuration.
* This function lets you directly provide joystick values from any source.
* @param leftValue The value of the left stick.
* @param rightValue The value of the right stick.
* @param squaredInputs Setting this parameter to true decreases the sensitivity at lower speeds
*/
public void tankDrive(double leftValue, double rightValue, boolean squaredInputs) {
if(!kTank_Reported){
UsageReporting.report(UsageReporting.kResourceType_RobotDrive, getNumMotors(), UsageReporting.kRobotDrive_Tank);
kTank_Reported = true;
}
// square the inputs (while preserving the sign) to increase fine control while permitting full power
leftValue = limit(leftValue);
rightValue = limit(rightValue);
if(squaredInputs) {
if (leftValue >= 0.0) {
leftValue = (leftValue * leftValue);
} else {
leftValue = -(leftValue * leftValue);
}
if (rightValue >= 0.0) {
rightValue = (rightValue * rightValue);
} else {
rightValue = -(rightValue * rightValue);
}
}
setLeftRightMotorOutputs(leftValue, rightValue);
}
示例15: AnalogChannel
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入依赖的package包/类
/**
* Construct an analog channel on a specified module.
*
* @param moduleNumber The digital module to use (1 or 2).
* @param channel The channel number to represent.
*/
public AnalogChannel(final int moduleNumber, final int channel) {
m_shouldUseVoltageForPID = false;
checkAnalogModule(moduleNumber);
checkAnalogChannel(channel);
m_channel = channel;
m_moduleNumber = moduleNumber;
m_module = AnalogModule.getInstance(moduleNumber);
try {
channels.allocate((moduleNumber - 1) * kAnalogChannels + m_channel - 1);
} catch (CheckedAllocationException e) {
throw new AllocationException(
"Analog channel " + m_channel + " on module " + m_moduleNumber + " is already allocated");
}
if (channel == 1 || channel == 2) {
m_accumulator = new tAccumulator((byte) (channel - 1));
m_accumulatorOffset = 0;
} else {
m_accumulator = null;
}
LiveWindow.addSensor("Analog", moduleNumber, channel, this);
UsageReporting.report(UsageReporting.kResourceType_AnalogChannel, channel, m_moduleNumber-1);
}