本文整理汇总了Java中com.ctre.CANTalon类的典型用法代码示例。如果您正苦于以下问题:Java CANTalon类的具体用法?Java CANTalon怎么用?Java CANTalon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CANTalon类属于com.ctre包,在下文中一共展示了CANTalon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Shooter
import com.ctre.CANTalon; //导入依赖的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);
}
示例2: Chassis
import com.ctre.CANTalon; //导入依赖的package包/类
public Chassis() {
leftMaster = new CANTalon(RobotMap.LEFT_MASTER);
leftSlave = new CANTalon(RobotMap.LEFT_SLAVE);
leftSlave.changeControlMode(CANTalon.TalonControlMode.Follower);
leftSlave.set(leftMaster.getDeviceID());
rightMaster = new CANTalon(RobotMap.RIGHT_MASTER);
rightSlave = new CANTalon(RobotMap.RIGHT_SLAVE);
rightSlave.changeControlMode(CANTalon.TalonControlMode.Follower);
rightSlave.set(rightMaster.getDeviceID());
rightMaster.enableBrakeMode(true);
rightSlave.enableBrakeMode(true);
leftMaster.enableBrakeMode(true);
leftSlave.enableBrakeMode(true);
System.out.println("Chassis sub system init");
threadInit(() -> {
SmartDashboard.putNumber("left speed:", leftMaster.get());
SmartDashboard.putNumber("right speed:", rightMaster.get());
});
}
示例3: DriveTest
import com.ctre.CANTalon; //导入依赖的package包/类
public DriveTest() {
_leftMain.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
_leftMain.set(0);
_rightMain.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
_rightMain.set(0);
_left2.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
_left2.set(0);
_right2.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
_right2.set(0);
_left3.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
_left3.set(0);
_right3.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
_right3.set(0);
_leftMain.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);
_rightMain.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);
}
示例4: Shooter
import com.ctre.CANTalon; //导入依赖的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);
}
示例5: SwerveDrive
import com.ctre.CANTalon; //导入依赖的package包/类
public SwerveDrive(CANTalon fr, CANTalon fra, AnalogInput fre, CANTalon fl, CANTalon fla, AnalogInput fle, CANTalon br, CANTalon bra, AnalogInput bre, CANTalon bl, CANTalon bla, AnalogInput ble)
{
FRM = new SwerveModule(fr, fra, fre, "FR");
FLM = new SwerveModule(fl, fla, fle, "FL");
BRM = new SwerveModule(br, bra, bre, "BR");
BLM = new SwerveModule(bl, bla, ble, "BL");
length = Config.getSetting("FrameLength",1);
width = Config.getSetting("FrameWidth",1);
diameter = Math.sqrt(Math.pow(length,2)+Math.pow(width,2));
temp = 0.0;
a = 0.0;b = 0.0;c = 0.0;d = 0.0;
ws1 = 0.0;ws2 = 0.0;ws3 = 0.0;ws4 = 0.0;
wa1 = 0.0;wa2 = 0.0;wa3 = 0.0;wa4 = 0.0;
max = 0.0;
movecount = 0;
}
示例6: setShooterPercentVBus
import com.ctre.CANTalon; //导入依赖的package包/类
/**
* Sets the shooter using percentvbus control. Useful for manual joystick control during testing.
*
* @param percentVbus The percentvbus value, 0.0 to 1.0
*/
public void setShooterPercentVBus(double percentVbus) {
if (shooterFault) {
killShooter();
return;
}
if (RobotMap.IS_ROADKILL) {
return;
}
logger.trace(String.format("Setting percentvbus=%f", percentVbus));
requestedRpm = -1;
shooterSlave.changeControlMode(CANTalon.TalonControlMode.Follower);
shooterSlave.set(masterId);
shooterSlave.enableControl();
shooterMaster.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
shooterMaster.set(percentVbus);
shooterMaster.enableControl();
}
示例7: checkEncoder
import com.ctre.CANTalon; //导入依赖的package包/类
private void checkEncoder(CANTalon talon) {
FeedbackDeviceStatus status = talon.isSensorPresent(getDevice());
if (status == null) {
return; // unit testing
}
switch (status) {
case FeedbackStatusPresent:
logger.info("{}: {} is present", talon.getDescription(), getDevice());
break;
case FeedbackStatusNotPresent:
logger.warn("{}: {} is MISSING", talon.getDescription(), getDevice());
break;
case FeedbackStatusUnknown:
logger.info(
"{}: encoder is unknown, only CTRE Mag or Pulse-Width Encoder supported",
talon.getDescription());
break;
}
}
示例8: testConfigurations
import com.ctre.CANTalon; //导入依赖的package包/类
/**
* Test that CANTalon outputs are being configured correctly
* TODO: Not all accounted for
*/
@Test
public void testConfigurations() throws Exception {
CANTalonOutput testOutput = new CANTalonOutput();
testOutput.gains = Gains.dericaPosition;
// Test vbus configuration
testOutput.setPercentVBus(0.5);
assertThat("Percent vbus setpoint incorrect", testOutput.getSetpoint(), equalTo(0.5));
assertThat("Percent vbus control mode incorrect", testOutput.getControlMode(), equalTo(CANTalon.TalonControlMode.PercentVbus));
testOutput = new CANTalonOutput();
// Test position configuration w/o factory used
testOutput.setPosition(10, Gains.dericaPosition);
assertThat("Position setpoint incorrect", testOutput.getSetpoint(), equalTo(10.0));
assertThat("Position control mode incorrect", testOutput.getControlMode(), equalTo(CANTalon.TalonControlMode.Position));
// TODO: test the PIDF izone ramprate
testOutput = new CANTalonOutput();
// Test position configuration w/o factory used
}
示例9: execute
import com.ctre.CANTalon; //导入依赖的package包/类
protected void execute() {
double t_delta;
if(onTime)
nextDouble = scanner.nextDouble();
t_delta = nextDouble - timer.get();
if (t_delta <= 0) {
for(CANTalon t : Robot.drivetrain.getTalons()) {
t.set(scanner.nextDouble());
}
onTime = true;
} else {
onTime = false;
}
}
示例10: 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;
}
示例11: onTarget
import com.ctre.CANTalon; //导入依赖的package包/类
@Override
public boolean onTarget() {
if (mCachedState == null) {
return false;
}
double positionTolerance = (Constants.kRobotName == Constants.RobotName.DERICA) ? Constants2016.kAcceptableDrivePositionError : Constants.kAcceptableDrivePositionError;
double velocityTolerance = (Constants.kRobotName == Constants.RobotName.DERICA) ? Constants2016.kAcceptableDriveVelocityError : Constants.kAcceptableDriveVelocityError;
// Motion magic is not PID so ignore whether talon closed loop error is around
if (mSignal.leftMotor.getControlMode() == CANTalon.TalonControlMode.MotionMagic) {
return (Math.abs(mCachedState.drivePose.leftEnc - mSignal.leftMotor.getSetpoint()) < positionTolerance) &&
(Math.abs(mCachedState.drivePose.leftSpeed) < velocityTolerance) &&
(Math.abs(mCachedState.drivePose.rightEnc - mSignal.rightMotor.getSetpoint()) < positionTolerance) &&
(Math.abs(mCachedState.drivePose.rightSpeed) < velocityTolerance);
}
if (!mCachedState.drivePose.leftError.isPresent() || !mCachedState.drivePose.rightError.isPresent()) {
// System.err.println("Talon closed loop error not found!");
return false;
}
return (Math.abs(mCachedState.drivePose.leftError.get()) < positionTolerance) &&
(Math.abs(mCachedState.drivePose.rightError.get()) < positionTolerance &&
Math.abs(mCachedState.drivePose.leftSpeed) < velocityTolerance &&
Math.abs(mCachedState.drivePose.rightSpeed) < velocityTolerance);
}
示例12: Winch
import com.ctre.CANTalon; //导入依赖的package包/类
public Winch() {
winchMotor = new CANTalon(RobotMap.WINCH_MOTOR);
winchBrake = new DoubleSolenoid(RobotMap.WINCH_STOPPER_CHANNEL_A, RobotMap.WINCH_STOPPER_CHANNEL_B);
this.winchMotor.enableBrakeMode(false);
this.winchMotor.changeControlMode(TalonControlMode.Voltage);
this.putBrakeOff();
}
示例13: CANTalonOutput
import com.ctre.CANTalon; //导入依赖的package包/类
public CANTalonOutput(CANTalon.TalonControlMode controlMode, Gains gains, double setpoint) {
this.controlMode = controlMode;
this.setpoint = setpoint;
profile = 0;
this.gains = gains;
accel = 0;
cruiseVel = 0;
}
示例14: Drivetrain
import com.ctre.CANTalon; //导入依赖的package包/类
public Drivetrain() {
//TODO: Init Gyro gyro = new Gyro();
pidOutput = new DrivetrainOutput(this);
pidInput = new GyroInput(gyro);
controller = new PIDController(0.0,0.0,0.0, pidInput, pidOutput);
//super(Kp, Ki, Kd);
leftFrontMotor = new CANTalon(RobotMap.LEFT_FRONT_MOTOR_PORT);
rightFrontMotor = new CANTalon(RobotMap.RIGHT_FRONT_MOTOR_PORT);
leftBackMotor = new CANTalon(RobotMap.LEFT_BACK_MOTOR_PORT);
rightBackMotor = new CANTalon(RobotMap.RIGHT_BACK_MOTOR_PORT);
//Assume the team does not have encoders if they do not have a mobility auton command.
robotDrive = new RobotDrive(leftBackMotor, leftFrontMotor, rightBackMotor, rightFrontMotor);
}
示例15: getCANTalon
import com.ctre.CANTalon; //导入依赖的package包/类
/**
* Checks if the CAN Device is a Talon
*
* @return talon object if type ID is 1; if not returns null
*/
public CANTalon getCANTalon ()
{
if (typeId == 1)
{
return talon;
}
return null;
}