本文整理汇总了Java中edu.wpi.first.wpilibj.communication.UsageReporting.report方法的典型用法代码示例。如果您正苦于以下问题:Java UsageReporting.report方法的具体用法?Java UsageReporting.report怎么用?Java UsageReporting.report使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.wpi.first.wpilibj.communication.UsageReporting
的用法示例。
在下文中一共展示了UsageReporting.report方法的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: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: initPWM
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入方法依赖的package包/类
/**
* Initialize PWMs given an module and channel.
*
* This method is private and is the common path for all the constructors for creating PWM
* instances. Checks module and channel value ranges and allocates the appropriate channel.
* The allocation is only done to help users ensure that they don't double assign channels.
*/
private void initPWM(final int moduleNumber, final int channel) {
checkPWMModule(moduleNumber);
checkPWMChannel(channel);
try {
allocated.allocate((moduleNumber - 1) * kPwmChannels + channel - 1);
} catch (CheckedAllocationException e) {
throw new AllocationException(
"PWM channel " + channel + " on module " + moduleNumber + " is already allocated");
}
m_channel = channel;
m_module = DigitalModule.getInstance(moduleNumber);
m_module.setPWM(m_channel, kPwmDisabled);
m_eliminateDeadband = false;
UsageReporting.report(UsageReporting.kResourceType_PWM, channel, moduleNumber-1);
}
示例8: 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);
}
示例9: initGyro
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入方法依赖的package包/类
/**
* Initialize the gyro. Calibrate the gyro by running for a number of
* samples and computing the center value for this part. Then use the center
* value as the Accumulator center value for subsequent measurements. It's
* important to make sure that the robot is not moving while the centering
* calculations are in progress, this is typically done when the robot is
* first turned on while it's sitting at rest before the competition starts.
*/
private void initGyro() {
result = new AccumulatorResult();
if (m_analog == null) {
System.out.println("Null m_analog");
}
m_voltsPerDegreePerSecond = kDefaultVoltsPerDegreePerSecond;
m_analog.setAverageBits(kAverageBits);
m_analog.setOversampleBits(kOversampleBits);
double sampleRate = kSamplesPerSecond
* (1 << (kAverageBits + kOversampleBits));
m_analog.getModule().setSampleRate(sampleRate);
Timer.delay(1.0);
reInitGyro();
setPIDSourceParameter(PIDSourceParameter.kAngle);
UsageReporting.report(UsageReporting.kResourceType_Gyro,
m_analog.getChannel(), m_analog.getModuleNumber() - 1);
LiveWindow.addSensor("Gyro", m_analog.getModuleNumber(),
m_analog.getChannel(), this);
}
示例10: initCounter
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入方法依赖的package包/类
private void initCounter(final Mode mode) {
m_allocatedUpSource = false;
m_allocatedDownSource = false;
try {
m_index = counters.allocate();
} catch (CheckedAllocationException e) {
throw new AllocationException("No counters left to be allocated");
}
m_counter = new tCounter(m_index);
m_counter.writeConfig_Mode(mode.value);
m_upSource = null;
m_downSource = null;
m_counter.writeTimerConfig_AverageSize(1);
UsageReporting.report(UsageReporting.kResourceType_Counter, m_index, mode.value);
}
示例11: 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_counter.start();
m_enabled = true; // make it available for round robin scheduling
setAutomaticMode(originalMode);
m_instances++;
UsageReporting.report(UsageReporting.kResourceType_Ultrasonic, m_instances);
LiveWindow.addSensor("Ultrasonic", m_echoChannel.getModuleForRouting(), m_echoChannel.getChannel(), this);
}
示例12: HiTechnicColorSensor
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param slot The slot of the digital module that the sensor is plugged into.
*/
public HiTechnicColorSensor(int slot) {
DigitalModule module = DigitalModule.getInstance(slot);
m_i2c = module.getI2C(kAddress);
// Verify Sensor
final byte[] kExpectedManufacturer = "HiTechnc".getBytes();
final byte[] kExpectedSensorType = "ColorPD ".getBytes();
if (!m_i2c.verifySensor(kManufacturerBaseRegister, kManufacturerSize, kExpectedManufacturer)) {
throw new ColorSensorException("Invalid Color Sensor Manufacturer");
}
if (!m_i2c.verifySensor(kSensorTypeBaseRegister, kSensorTypeSize, kExpectedSensorType)) {
throw new ColorSensorException("Invalid Sensor type");
}
LiveWindow.addSensor("HiTechnicColorSensor", slot, 0, this);
UsageReporting.report(UsageReporting.kResourceType_HiTechnicColorSensor, module.getModuleNumber()-1);
}
示例13: 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);
}
示例14: HiTechnicCompass
import edu.wpi.first.wpilibj.communication.UsageReporting; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param slot The slot of the digital module that the sensor is plugged into.
*/
public HiTechnicCompass(int slot) {
DigitalModule module = DigitalModule.getInstance(slot);
m_i2c = module.getI2C(kAddress);
// Verify Sensor
final byte[] kExpectedManufacturer = "HiTechnc".getBytes();
final byte[] kExpectedSensorType = "Compass ".getBytes();
if (!m_i2c.verifySensor(kManufacturerBaseRegister, kManufacturerSize, kExpectedManufacturer)) {
throw new CompassException("Invalid Compass Manufacturer");
}
if (!m_i2c.verifySensor(kSensorTypeBaseRegister, kSensorTypeSize, kExpectedSensorType)) {
throw new CompassException("Invalid Sensor type");
}
UsageReporting.report(UsageReporting.kResourceType_HiTechnicCompass, module.getModuleNumber()-1);
LiveWindow.addSensor("HiTechnicCompass", slot, 0, this);
}
示例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) {
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);
}