当前位置: 首页>>代码示例>>Java>>正文


Java CANTalon.setPosition方法代码示例

本文整理汇总了Java中com.ctre.CANTalon.setPosition方法的典型用法代码示例。如果您正苦于以下问题:Java CANTalon.setPosition方法的具体用法?Java CANTalon.setPosition怎么用?Java CANTalon.setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ctre.CANTalon的用法示例。


在下文中一共展示了CANTalon.setPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTalon

import com.ctre.CANTalon; //导入方法依赖的package包/类
/**
 * Create a wrapped {@link CANTalon} with appropriate default values.
 *
 * @param id the device ID of the CANTalon to create
 * @return the wrapped CANTalon
 * @see Wrapper
 */
@NotNull
private CANTalon createTalon(int id) {
  CANTalon talon = wrapperFactory.createWrapper(id, CONTROL_FRAME_MS);
  StatusFrameRate.DEFAULT.configure(talon);
  talon.changeControlMode(TalonControlMode.Voltage);
  talon.clearIAccum();
  talon.ClearIaccum();
  talon.clearMotionProfileHasUnderrun();
  talon.clearMotionProfileTrajectories();
  talon.clearStickyFaults();
  talon.enableZeroSensorPositionOnForwardLimit(false);
  talon.enableZeroSensorPositionOnIndex(false, false);
  talon.enableZeroSensorPositionOnReverseLimit(false);
  talon.reverseOutput(false);
  talon.reverseSensor(false);
  talon.setAnalogPosition(0);
  talon.setPosition(0);
  talon.setProfile(0);
  talon.setPulseWidthPosition(0);
  if (!seen.add(talon)) {
    throw new IllegalStateException("creating an already-existing talon");
  }
  logger.info("added {} to seen Set", talon);
  return talon;
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:33,代码来源:TalonFactory.java

示例2: configureMaster

import com.ctre.CANTalon; //导入方法依赖的package包/类
private void configureMaster(CANTalon talon) {
  logger.info("init master: " + talon.getDeviceID());
  talon.changeControlMode(CANTalon.TalonControlMode.Voltage);
  talon.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);
  talon.configEncoderCodesPerRev(RobotMap.QUAD_ENCODER_TICKS_PER_REV);
  talon.configNominalOutputVoltage(+0.0f, -0.0f);
  talon.configPeakOutputVoltage(+12.0f, -12.0f);
  talon.setProfile(0);
  talon.setF(0);
  talon.setP(0.5);
  talon.setI(0.0001);
  talon.setD(1.0);
  talon.setPosition(0);
  talon.enableBrakeMode(true);
}
 
开发者ID:ligerbots,项目名称:Steamworks2017Robot,代码行数:16,代码来源:DriveTrain.java

示例3: configureTalons

import com.ctre.CANTalon; //导入方法依赖的package包/类
void configureTalons(boolean calibrateSliderEncoder) {
	configureDriveTalons();
	if (Constants.kRobotName == RobotName.STEIK) {
		//Climber setup
		CANTalon climber = HardwareAdapter.ClimberHardware.getInstance().climberTalon;
		climber.reset();
		climber.setFeedbackDevice(CANTalon.FeedbackDevice.CtreMagEncoder_Relative);
		climber.setPosition(0);	
		climber.configMaxOutputVoltage(Constants.kClimberMaxVoltage);
		climber.configPeakOutputVoltage(Constants.kClimberMaxVoltage, 0); // Should never be used
		climber.ConfigRevLimitSwitchNormallyOpen(false); // Prevent the motor from spinning backwards
		climber.ConfigFwdLimitSwitchNormallyOpen(true);
		climber.enable();
		
		CANTalon slider = HardwareAdapter.SliderHardware.getInstance().sliderTalon;
		// Reset and turn on the Talon 
		slider.reset();
		slider.clearStickyFaults();
		slider.setStatusFrameRateMs(CANTalon.StatusFrameRate.General, 5);
		slider.enable();
		slider.enableControl();
		slider.configMaxOutputVoltage(Constants.kSliderMaxVoltage);
		slider.configPeakOutputVoltage(Constants.kSliderPeakOutputVoltage, -Constants.kSliderPeakOutputVoltage);
		if (calibrateSliderEncoder) {
			// Set up the Talon to read from a relative CTRE mag encoder sensor
			slider.setFeedbackDevice(CANTalon.FeedbackDevice.CtreMagEncoder_Relative);
			// Calibrate the encoder
			double current_pot_pos = HardwareAdapter.SliderHardware.getInstance().sliderPotentiometer.getValue();
			double distance_to_center = current_pot_pos - Constants.kPotentiometerCenterPos;
			double position_in_rev = (distance_to_center / 4096.0) * 10.0;
			if (Constants.kCalibrateSliderWithPotentiometer) {
				slider.setPosition(-position_in_rev);
			} else {
				slider.setPosition(0);
			}
		}
	}
}
 
开发者ID:team8,项目名称:FRC-2017-Public,代码行数:39,代码来源:HardwareUpdater.java

示例4: config

import com.ctre.CANTalon; //导入方法依赖的package包/类
@Override
protected void config(CANTalon talon, double value) {
  talon.setPosition(value);
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:5,代码来源:SetPositionCommand.java


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