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


Java FeedbackDevice类代码示例

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


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

示例1: Shooter

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
public Shooter() {
	shooterMotor = new CANTalon(RobotMap.SHOOTER_MOTOR);
	feederMotor = new CANTalon(RobotMap.FEEDER_MOTOR);

	this.shooterMotor.setFeedbackDevice(FeedbackDevice.QuadEncoder);
	this.shooterMotor.configEncoderCodesPerRev(12);
	this.shooterMotor.configNominalOutputVoltage(0.0, 0.0);
	this.shooterMotor.configPeakOutputVoltage(12, 0.0);
	this.shooterMotor.enableBrakeMode(false);

	this.shooterMotor.setPID(
			RobotMap.SHOOTER_SPEED_P,
			RobotMap.SHOOTER_SPEED_I,
			RobotMap.SHOOTER_SPEED_D,
			RobotMap.SHOOTER_SPEED_F,
			100,
			48.0,
			0);
	this.shooterMotor.changeControlMode(TalonControlMode.Speed);
	this.shooterMotor.SetVelocityMeasurementPeriod(VelocityMeasurementPeriod.Period_50Ms);
	this.shooterMotor.SetVelocityMeasurementWindow(64);
	
	this.feederMotor.changeControlMode(TalonControlMode.Voltage);
}
 
开发者ID:2141-Spartonics,项目名称:Spartonics-Code,代码行数:25,代码来源:Shooter.java

示例2: setupMotorController

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
/**
 * Initializes all the CAN stuff for the motor controller.
 * 
 * @param feedbackType
 *            The type of feedback device in the MotorController.
 * @param tunetype
 *            Speed or position. See the CTRE doc for more info
 * @param codesPerRev
 *            The number of signals the feedback devices gives per rotation, so
 *            the setpoint can function in rpm or revolutions.
 * @param reverseSensor
 *            Is the feedback device reversed.
 */
public void setupMotorController (FeedbackDevice feedbackType,
        TalonControlMode tunetype, int codesPerRev,
        boolean reverseSensor)
{
    this.feedbackType = feedbackType;
    this.tunedMotorController
            .setFeedbackDevice(feedbackType);
    this.tunedMotorController.changeControlMode(tunetype);
    this.tunedMotorController.configEncoderCodesPerRev(codesPerRev);
    this.tunedMotorController.reverseSensor(reverseSensor);
    this.tunedMotorController.setProfile(0);
    this.tunedMotorController.configPeakOutputVoltage(12f, -12f);
    this.tunedMotorController.configNominalOutputVoltage(0f, 0f);
    wasIncorrect = false;
    time.stop();
    time.reset();
}
 
开发者ID:FIRST-Team-339,项目名称:2017,代码行数:31,代码来源:CanTalonPIDTuner.java

示例3: Shooter

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
public Shooter(CANTalon m)
{
	flyWheel = m;
	
   	flyWheel.setFeedbackDevice(FeedbackDevice.QuadEncoder);
   	flyWheel.reverseSensor(false);
   	flyWheel.changeControlMode(TalonControlMode.Speed);
   	flyWheel.setF(Config.getSetting("FlyF", 0));
   	flyWheel.setPID(Config.getSetting("FlyP", 13), 
   					Config.getSetting("FlyI", 0.008), 
   					Config.getSetting("FlyD", 100));
   	flyWheel.enableBrakeMode(false);
   	flyWheel.configEncoderCodesPerRev(20);//40 for CIMcoder
   	flyWheel.enable();
   	
   	boilerRPM = Config.getSetting("boilerRPM",2500);
   	rpmThreshold = Config.getSetting("ShooterRPMThreshold", 10);
}
 
开发者ID:RAR1741,项目名称:RA17_RobotCode,代码行数:19,代码来源:Shooter.java

示例4: initTalonConfig

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
public void initTalonConfig() {

	    talons = new CANTalon[] {
	    		new CANTalon(TALONS_FRONT_LEFT), new CANTalon(TALONS_FRONT_RIGHT),
	            new CANTalon(TALONS_REAR_LEFT), new CANTalon(TALONS_REAR_RIGHT)};
	    
	    talons[MotorType.kFrontLeft.value].setInverted(true);
	    talons[MotorType.kFrontRight.value].setInverted(false);
	    talons[MotorType.kRearLeft.value].setInverted(true);
	    talons[MotorType.kRearRight.value].setInverted(false);
	    
	    for (CANTalon t: talons) {
            t.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
            t.enableBrakeMode(false);
            t.setFeedbackDevice(FeedbackDevice.QuadEncoder);
            t.configEncoderCodesPerRev(ENC_CODES_PER_REV);
            t.setEncPosition(0);
            t.set(0);
        }
	    robotDrive = new RobotDrive(talons[MotorType.kFrontLeft.value], talons[MotorType.kRearLeft.value], 
	    							talons[MotorType.kFrontRight.value], talons[MotorType.kRearRight.value]);
	    robotDrive.setSafetyEnabled(false);
	}
 
开发者ID:frc2879,项目名称:2017-newcomen,代码行数:24,代码来源:Drivetrain.java

示例5: Intake

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
public Intake(String name, CANTalon rollers, CANTalon angleAdjust)	{
  	super(name);
  	m_intake = rollers;
  	m_angleAdjust = angleAdjust;
  	
  	m_angleAdjust.setFeedbackDevice(FeedbackDevice.CtreMagEncoder_Absolute);
  	m_intake.setFeedbackDevice(FeedbackDevice.CtreMagEncoder_Relative);

m_angleAdjust.changeControlMode(TalonControlMode.Position);

m_angleAdjust.reverseSensor(false);
m_angleAdjust.reverseOutput(false);
m_angleAdjust.enableBrakeMode(true);

m_angleAdjust.setF(Constants.kIntakeF);
m_angleAdjust.setP(Constants.kIntakeP);
m_angleAdjust.setI(Constants.kIntakeI);
m_angleAdjust.setD(Constants.kIntakeD);
  }
 
开发者ID:nerdherd,项目名称:Stronghold2016,代码行数:20,代码来源:Intake.java

示例6: DriveSubsystem

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
public DriveSubsystem() {
	talonFrontLeft = new CANTalon(Ports.FRONT_LEFT_MOTOR);
	talonFrontRight = new CANTalon(Ports.FRONT_RIGHT_MOTOR);
	talonBackLeft = new Talon(Ports.BACK_LEFT_MOTOR);
	talonBackRight = new Talon(Ports.BACK_RIGHT_MOTOR);
	ultraSanic.setAutomaticMode(true);
	
	talonFrontLeft.setFeedbackDevice(FeedbackDevice.QuadEncoder);
	talonFrontRight.setFeedbackDevice(FeedbackDevice.QuadEncoder);
	talonFrontLeft.configEncoderCodesPerRev(PulsesPerRevolution);
	talonFrontRight.configEncoderCodesPerRev(PulsesPerRevolution);

	try {
		ahrs = new AHRS(Port.kMXP);
	} catch (Exception ex) {
		//System.out.println(ex);
	}
	// SPEED MODE CODE
	// setDriveControlMode(TalonControlMode.Speed);
	drivingStraight = false;
	driveLowerSpeed = false;
	reversed = true;
	enableForwardSoftLimit(false);
	enableReverseSoftLimit(false);
}
 
开发者ID:Team2537,项目名称:Cogsworth,代码行数:26,代码来源:DriveSubsystem.java

示例7: Shooter

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
public Shooter() {
	super();
	shooterFeeder = new CANTalon(8);
    LiveWindow.addActuator("Shooter", "Feeder", shooterFeeder);
    shooterFeeder.enableBrakeMode(false);
    
    shooterShootMotor = new CANTalon(7);
    LiveWindow.addActuator("Shooter", "ShootMotor", shooterShootMotor);
    shooterShootMotor.enableBrakeMode(false);
       /* choose the sensor */
    shooterShootMotor.setFeedbackDevice(FeedbackDevice.QuadEncoder);
    shooterShootMotor.reverseSensor(true);
    shooterShootMotor.configEncoderCodesPerRev(PulsesPerRevolution); // if using FeedbackDevice.QuadEncoder

       /* set the peak and nominal outputs, 12V means full */
    shooterShootMotor.configNominalOutputVoltage(+0.0f, -0.0f);
    shooterShootMotor.configPeakOutputVoltage(+12.0f, -12.0f);
       
       /* set closed loop gains in slot0 */
    shooterShootMotor.setProfile(0);
    shooterShootMotor.setF(pidF);
       shooterShootMotor.setP(pidP);	
       
       //only change I and D to smooth out control
       shooterShootMotor.setI(0); 
       shooterShootMotor.setD(0);
    
    shooterAgitator = new CANTalon(10);
    LiveWindow.addActuator("Shooter", "Agitator", shooterAgitator);
    shooterAgitator.enableBrakeMode(false);
}
 
开发者ID:FRC2832,项目名称:Robot_2017,代码行数:32,代码来源:Shooter.java

示例8: SwerveModule

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
public SwerveModule(CANTalon d, CANTalon a, AnalogInput e, String name)
{
	SpeedP = Config.getSetting("speedP",1);
	SpeedI = Config.getSetting("speedI",0);
	SpeedD = Config.getSetting("speedD",0);
	SteerP = Config.getSetting("steerP",2);
	SteerI = Config.getSetting("steerI",0);
	SteerD = Config.getSetting("steerD",0);
	SteerTolerance = Config.getSetting("SteeringTolerance", .25);
	SteerSpeed = Config.getSetting("SteerSpeed", 1);
	SteerEncMax = Config.getSetting("SteerEncMax",4.792);
	SteerEncMax = Config.getSetting("SteerEncMin",0.01);
	SteerOffset = Config.getSetting("SteerEncOffset",0);
	MaxRPM = Config.getSetting("driveCIMmaxRPM", 4200);
	
	drive = d;
	drive.setPID(SpeedP, SpeedI, SpeedD);
	drive.setFeedbackDevice(FeedbackDevice.QuadEncoder);
   drive.configEncoderCodesPerRev(20);
   drive.enable();
	
	angle = a;
	
	encoder = e;
	
	encFake = new FakePIDSource(SteerOffset,SteerEncMin,SteerEncMax);
	
	PIDc = new PIDController(SteerP,SteerI,SteerD,encFake,angle);
	PIDc.disable();
	PIDc.setContinuous(true);
	PIDc.setInputRange(SteerEncMin,SteerEncMax);
	PIDc.setOutputRange(-SteerSpeed,SteerSpeed);
	PIDc.setPercentTolerance(SteerTolerance);
	PIDc.setSetpoint(2.4);
	PIDc.enable();
	s = name;
}
 
开发者ID:RAR1741,项目名称:RA17_RobotCode,代码行数:38,代码来源:SwerveModule.java

示例9: robotInit

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
/**
    * This function is run when the robot is first started up and should be
    * used for any initialization code.
    */
   //@SuppressWarnings("unused")
public void robotInit() {
   RobotMap.init();
       // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
       motors = new Motors();
       camera = new Camera();
       electrical = new Electrical();
       bling = new Bling();

       // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
       // OI must be constructed after subsystems. If the OI creates Commands
       //(which it very likely will), subsystems are not guaranteed to be
       // constructed yet. Thus, their requires() statements may grab null
       // pointers. Bad news. Don't move it.
       oi = new OI();

       // instantiate the command used for the autonomous period
       // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS

       autonomousCommand = new AutonomousCommand();
       //LiveWindow liveWin = new LiveWindow();

       // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS 
       int pulseWidthPos = Motors.TestCANTalon.getPulseWidthPosition();
       int pulseWidthUs =  Motors.TestCANTalon.getPulseWidthRiseToFallUs();
       int periodUs =  Motors.TestCANTalon.getPulseWidthRiseToRiseUs();
       int pulseWidthVel = Motors.TestCANTalon.getPulseWidthVelocity();
       // Check to see if encoder is plugged in
       FeedbackDeviceStatus sensorStatus = Motors.TestCANTalon.isSensorPresent(FeedbackDevice.CtreMagEncoder_Absolute);
       boolean sensorPluggedIn = (FeedbackDeviceStatus.FeedbackStatusPresent == sensorStatus);
       Motors.TestCANTalon.changeControlMode(TalonControlMode.PercentVbus);
      Motors.TestCANTalon.setFeedbackDevice(FeedbackDevice.CtreMagEncoder_Absolute);
       CameraServer.getInstance().startAutomaticCapture();
   }
 
开发者ID:alpal23,项目名称:2017TestBench,代码行数:39,代码来源:Robot.java

示例10: Encoder

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
Encoder(
    @Nullable CANTalon.FeedbackDevice device,
    @Nullable Boolean reversed,
    @Nullable Integer ticksPerRevolution) {
  this.device = device;
  this.reversed = reversed != null ? reversed : false;
  unitScalingEnabled = ticksPerRevolution != null;
  this.ticksPerRevolution = unitScalingEnabled ? ticksPerRevolution : 0;
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:10,代码来源:Encoder.java

示例11: setFeedbackDevice

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
/**
 * This method sets the feedback device type.
 *
 * @param devType specifies the feedback device type.
 */
public void setFeedbackDevice(FeedbackDevice devType)
{
    final String funcName = "setFeedbackDevice";

    if (debugEnabled)
    {
        dbgTrace.traceEnter(funcName, TrcDbgTrace.TraceLevel.API, "devType=%s", devType.toString());
        dbgTrace.traceExit(funcName, TrcDbgTrace.TraceLevel.API);
    }

    motor.setFeedbackDevice(devType);
    feedbackDeviceIsPot = devType == FeedbackDevice.AnalogPot;
}
 
开发者ID:trc492,项目名称:Frc2017FirstSteamWorks,代码行数:19,代码来源:FrcCANTalon.java

示例12: shootFire

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
public void shootFire(double speed){
		
		_fire.changeControlMode(CANTalon.TalonControlMode.Speed);
		_fire.set(0);
		_fire.reverseSensor(false);
		_fire.setFeedbackDevice(FeedbackDevice.EncRising);
		_fire.configEncoderCodesPerRev(4);
		resetEnc();
		_fire.configPeakOutputVoltage(+12.0f, -12.0f);
		_fire.configNominalOutputVoltage(+0.0f, -0.0f);		
//		double  valueF = 1,
//				//valueP = 90,
//				valueP = 90,
//				valueI = 0,
//				valueD = 2;
		
		double valueP,
				valueI,
				valueD,
				valueF;
		
		valueP = Preferences.getInstance().getDouble("Shooter P", 90);
		valueI = Preferences.getInstance().getDouble("Shooter I", 0);
		valueD = Preferences.getInstance().getDouble("Shooter D", 2);
		valueF = Preferences.getInstance().getDouble("Shooter F", 1);
		
		_fire.setProfile(0);
		_fire.setF(valueF);
		_fire.setP(valueP);
		_fire.setI(valueI);
		_fire.setD(valueD);
		
//		_fire.setVoltageRampRate(6.0);
//		double P;
//		double I;
//		double D;
//		double F;
		
//		P = Preferences.getInstance().getDouble("Shooter P", .2);
//		I = Preferences.getInstance().getDouble("Shooter I", .0015);
//		D = Preferences.getInstance().getDouble("Shooter D", 0);
//		F = Preferences.getInstance().getDouble("Shooter F", 1);
//		
//		if((P < 0) || (P > 1)) {
//			P = .2;
//		}
//		
//		if((I < 0) || (I > 1)) {
//			I = .001;
//		}
//		
//		if((D < 0) || (D > 1)) {
//			D = 0;
//		}
//		
//		if((F < 0) || (F > 1)) {
//			F = 1;
//		}
		
//		P = .2;
//		I = .0015;
//		D = 0;
//		F = 1;
//		
//		_fire.setF(F);
//		_fire.setP(P);
//		_fire.setI(I);
//		_fire.setD(D);
//		
		_fire.set(speed);
	}
 
开发者ID:2729StormRobotics,项目名称:StormRobotics2017,代码行数:72,代码来源:ShootingSystem.java

示例13: initializeFlyWheelPID

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
/**
 * Initialize PID feedback and constants for flywheel
 * 
 * pGain 0.0 iGain 0.0001 dGain 0.0
 */
public void initializeFlyWheelPID() {
	RobotMap.shooterFlyWheel.setFeedbackDevice(FeedbackDevice.CtreMagEncoder_Relative);
	// TODO Tune collector PID if we want to use speed
	collectorFlyWheel.setPID(0.0, 0.0001, 0.0);
}
 
开发者ID:1757WestwoodRobotics,项目名称:2017-Steamworks,代码行数:11,代码来源:BallCollector.java

示例14: perform

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
@Override
public void perform() {
  String[] types = {
    "Analog",
    "Analog Potentiometer",
    "CTRE Magnetic Absolute",
    "CTRE Magnetic Relative",
    "Falling Edge",
    "Rising Edge",
    "Pulse Width",
    "Quadrature"
  };
  terminal.writer().println();
  for (int i = 0; i < types.length; i++) {
    terminal.writer().printf("%2d - %s ms%n", i + 1, types[i]);
  }
  boolean done = false;
  while (!done) {
    String line;
    try {
      line = reader.readLine(prompt()).trim();
    } catch (EndOfFileException | UserInterruptException e) {
      break;
    }

    if (line.isEmpty()) {
      logger.info("no value entered");
      break;
    }

    int choice;
    try {
      choice = Integer.valueOf(line);
    } catch (NumberFormatException nfe) {
      terminal.writer().println("please enter an integer");
      continue;
    }
    CANTalon.FeedbackDevice device;
    done = true;
    switch (choice) {
      case 1:
        device = FeedbackDevice.AnalogEncoder;
        break;
      case 2:
        device = FeedbackDevice.AnalogPot;
        break;
      case 3:
        device = FeedbackDevice.CtreMagEncoder_Absolute;
        break;
      case 4:
        device = FeedbackDevice.CtreMagEncoder_Relative;
        break;
      case 5:
        device = FeedbackDevice.EncFalling;
        break;
      case 6:
        device = FeedbackDevice.EncRising;
        break;
      case 7:
        device = FeedbackDevice.PulseWidth;
        break;
      case 8:
        device = FeedbackDevice.QuadEncoder;
        break;
      default:
        continue;
    }
    talonSet.talonConfigurationBuilder().encoder(device);
    for (CANTalon talon : talonSet.selected()) {
      talon.setFeedbackDevice(device);
      logger.info("set {} for {} to {}", name(), talon.getDescription(), device);
    }
  }
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:75,代码来源:SelectTypeCommand.java

示例15: copyWithEncoder

import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
@NotNull
Encoder copyWithEncoder(CANTalon.FeedbackDevice feedbackDevice) {
  return new Encoder(feedbackDevice, reversed, unitScalingEnabled ? ticksPerRevolution : null);
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:5,代码来源:Encoder.java


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