• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AccumulatorResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中edu.wpi.first.wpilibj.AccumulatorResult的典型用法代码示例。如果您正苦于以下问题:Java AccumulatorResult类的具体用法?Java AccumulatorResult怎么用?Java AccumulatorResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AccumulatorResult类属于edu.wpi.first.wpilibj包,在下文中一共展示了AccumulatorResult类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initGyro

import edu.wpi.first.wpilibj.AccumulatorResult; //导入依赖的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: AnalogGyro

import edu.wpi.first.wpilibj.AccumulatorResult; //导入依赖的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);
}
 
开发者ID:RobotsByTheC,项目名称:CMonster2015,代码行数:27,代码来源:AnalogGyro.java


示例3: initGyro

import edu.wpi.first.wpilibj.AccumulatorResult; //导入依赖的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);
}
 
开发者ID:Team2168,项目名称:2014_Main_Robot,代码行数:32,代码来源:FalconGyro.java


示例4: initGyro

import edu.wpi.first.wpilibj.AccumulatorResult; //导入依赖的package包/类
/**
 * Initialize the gyro. Calibrate the gyro by running for a number of
 * samples and computing the center value. 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.
 */
public 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));
	
	AnalogInput.setGlobalSampleRate(sampleRate);
	Timer.delay(1.0);

	m_analog.initAccumulator();
	m_analog.resetAccumulator();

	// allow time for the Gyro run through the calibration
	Timer.delay(kCalibrationSampleTime);

	// read the accumulated value and the number of samples
	m_analog.getAccumulatorOutput(result);

	// the gyro center is the average of the accumulated counts, while if offset
	// is the fraction from the center (decimal)
	m_center = (int) ((double) result.value / (double) result.count + 0.5);
	m_offset =       ((double) result.value / (double) result.count) - m_center;

	m_center = Constants.GYRO_CENTER;
	m_offset = 0.0;
		
	// set the gyro center (integer) for the integration
	m_analog.setAccumulatorCenter(m_center);
	m_analog.resetAccumulator();

	// dead band will decrease drift at the cost of decreasing accuracy
	setDeadband(0.0);

	// set the PID source
	setPIDSourceParameter(PIDSourceParameter.kAngle);

	UsageReporting.report(tResourceType.kResourceType_Gyro, m_analog.getChannel());
	
	LiveWindow.addSensor("HVAGyro", m_analog.getChannel(), this);
	SmartDashboard.putNumber("m_center", m_center);
}
 
开发者ID:HVA-FRC-3824,项目名称:HolonomicDrive,代码行数:59,代码来源:HVAGyro.java


示例5: initGyro

import edu.wpi.first.wpilibj.AccumulatorResult; //导入依赖的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();
    
    channel.setAverageBits(kAverageBits);
    channel.setOversampleBits(kOversampleBits);
    double sampleRate = kSamplesPerSecond * (1 << (kAverageBits + kOversampleBits));
    channel.getModule().setSampleRate(sampleRate);

    Timer.delay(1.0);
    channel.initAccumulator();

    Timer.delay(kCalibrationSampleTime);

    channel.getAccumulatorOutput(result);

    int center = (int) ((double)result.value / (double)result.count + .5);

    voltageOffset = ((double)result.value / (double)result.count) - (double)center;

    channel.setAccumulatorCenter(center);

    channel.setAccumulatorDeadband(0); ///< TODO: compute / parameterize this
    channel.resetAccumulator();
}
 
开发者ID:Team3309,项目名称:frc-2013-offseason,代码行数:33,代码来源:SuperGyro.java



注:本文中的edu.wpi.first.wpilibj.AccumulatorResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CommandReceiver类代码示例发布时间:2022-05-23
下一篇:
Java ByteArrayMessageConverter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap