本文整理汇总了Java中com.ctre.CANTalon.changeControlMode方法的典型用法代码示例。如果您正苦于以下问题:Java CANTalon.changeControlMode方法的具体用法?Java CANTalon.changeControlMode怎么用?Java CANTalon.changeControlMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ctre.CANTalon
的用法示例。
在下文中一共展示了CANTalon.changeControlMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
});
}
示例2: initTalonConfig
import com.ctre.CANTalon; //导入方法依赖的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);
}
示例3: 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;
}
示例4: init
import com.ctre.CANTalon; //导入方法依赖的package包/类
public static void init() {
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
compressor = new Compressor();
driveTrainLeftFront = new CANTalon(1);
LiveWindow.addActuator("DriveTrain", "LeftFront", driveTrainLeftFront);
driveTrainRightFront = new CANTalon(3);
LiveWindow.addActuator("DriveTrain", "RightFront", driveTrainRightFront);
driveTrainLeftRear = new CANTalon(2);
driveTrainLeftRear.changeControlMode(TalonControlMode.Follower);
driveTrainLeftRear.set(driveTrainLeftFront.getDeviceID());
LiveWindow.addActuator("DriveTrain", "LeftRear", driveTrainLeftRear);
driveTrainRightRear = new CANTalon(4);
driveTrainRightRear.changeControlMode(TalonControlMode.Follower);
driveTrainRightRear.set(driveTrainRightFront.getDeviceID());
driveTrainRightRear.reverseOutput(false);
LiveWindow.addActuator("DriveTrain", "RightRear", driveTrainRightRear);
driveTrainLeftFront.setInverted(true);
driveTrainRightFront.setInverted(true);
driveTrainLeftRear.setInverted(true);
driveTrainRightRear.setInverted(true);
driveTrainRobotDrive41 = new RobotDrive(driveTrainRightFront, driveTrainLeftFront);
driveTrainRobotDrive41.setSafetyEnabled(true);
driveTrainRobotDrive41.setExpiration(0.1);
driveTrainRobotDrive41.setSensitivity(0.5);
driveTrainRobotDrive41.setMaxOutput(1.0);
climbMotor = new CANTalon(5);
LiveWindow.addActuator("Climbing", "Motor", climbMotor);
lightsLightEnable = new Relay(0);
LiveWindow.addActuator("Lights", "LightEnable", lightsLightEnable);
gearIntakeRamp = new DoubleSolenoid(1, 0);
LiveWindow.addActuator("GearIntake", "IntakeRamp", gearIntakeRamp);
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
示例5: Manipulation
import com.ctre.CANTalon; //导入方法依赖的package包/类
public Manipulation(int in1,int in2,int out)
{
input1 = new Spark(in1);
input2 = new Spark(in2);
output = new CANTalon(out);
output.changeControlMode(TalonControlMode.PercentVbus);
}
示例6: Intake
import com.ctre.CANTalon; //导入方法依赖的package包/类
/**
* Creates the intake subsystem.
*/
public Intake() {
if (Robot.deviceFinder.isTalonAvailable(RobotMap.CT_ID_INTAKE)) {
logger.info("Initialize");
intakeTalon = new CANTalon(RobotMap.CT_ID_INTAKE);
intakeTalon.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
intakeTalon.setSafetyEnabled(false);
setIntakeOn(false);
} else {
logger.warn("Intake unavailable");
}
}
示例7: 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);
}
示例8: Feeder
import com.ctre.CANTalon; //导入方法依赖的package包/类
/**
* Creates the Feeder subsystem.
*/
public Feeder() {
if (Robot.deviceFinder.isTalonAvailable(RobotMap.CT_ID_FEEDER)) {
logger.trace("Initialize");
feederTalon = new CANTalon(RobotMap.CT_ID_FEEDER);
feederTalon.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
feederTalon.enableBrakeMode(true);
feederTalon.setSafetyEnabled(false);
} else {
logger.warn("Feeder unavailable");
}
}
示例9: Shooter
import com.ctre.CANTalon; //导入方法依赖的package包/类
public Shooter() {
motor = new CANTalon(LEAD_SHOOTER_PORT);
motor.setInverted(true);
CANTalon follower = new CANTalon(FOLLOWER_SHOOTER_PORT);
agitatorMotor = new Talon(AGITATOR_PORT);
motor.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);
motor.changeControlMode(CANTalon.TalonControlMode.Speed);
follower.changeControlMode(CANTalon.TalonControlMode.Follower);
follower.set(LEAD_SHOOTER_PORT);
motor.setF(0);
motor.setP(.88);
motor.setI(0);
motor.setD(0);
}
示例10: Drivebase
import com.ctre.CANTalon; //导入方法依赖的package包/类
public Drivebase() {
super();
left = new CANTalon(FRONT_LEFT_MOTOR_DEVICE_NUMBER);
leftSlave = new CANTalon(BACK_LEFT_MOTOR_DEVICE_NUMBER);
leftSlave.changeControlMode(CANTalon.TalonControlMode.Follower);
leftSlave.set(FRONT_LEFT_MOTOR_DEVICE_NUMBER);
right = new CANTalon(FRONT_RIGHT_MOTOR_DEVICE_NUMBER);
rightSlave = new CANTalon(BACK_RIGHT_MOTOR_DEVICE_NUMBER);
rightSlave.changeControlMode(CANTalon.TalonControlMode.Follower);
rightSlave.set(FRONT_RIGHT_MOTOR_DEVICE_NUMBER);
left.setInverted(true);
right.setInverted(true);
leftSlave.setInverted(true);
rightSlave.setInverted(true);
left.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);
right.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);
left.configEncoderCodesPerRev(TICS_PER_REVOLUTION);
right.configEncoderCodesPerRev(TICS_PER_REVOLUTION);
left.reverseSensor(true);
right.reverseSensor(true);
// PID Stuff
left.setPID(0.1, 0, 0, 0.025, 0, 1, 0);
right.setPID(0.1, 0, 0, 0.025, 0, 1, 0);
left.configNominalOutputVoltage(+0, -0);
right.configPeakOutputVoltage(+12, -12);
left.setProfile(0);
right.setProfile(0);
robotDrive = new RobotDrive(left, right);
}
示例11: Lift
import com.ctre.CANTalon; //导入方法依赖的package包/类
public Lift() {
super("Lift");
//SmartDashboard.putData(this);
liftTalon = new CANTalon(TALONS_LIFT);
liftTalon.enableBrakeMode(true);
liftTalon.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
liftTalon.set(0);
}
示例12: configure
import com.ctre.CANTalon; //导入方法依赖的package包/类
@Override
public void configure(@NotNull CANTalon talon) {
super.configure(talon);
talon.changeControlMode(TalonControlMode.MotionMagic);
talon.setMotionMagicAcceleration(valueOrElse(motionMagicAcceleration, 0));
talon.setMotionMagicCruiseVelocity(valueOrElse(motionMagicCruiseVelocity, 0));
}
示例13: updateCANTalonSRX
import com.ctre.CANTalon; //导入方法依赖的package包/类
/**
* Helper method for processing a CANTalonOutput for an SRX
*/
private void updateCANTalonSRX(CANTalon talon, CANTalonOutput output) {
talon.changeControlMode(output.getControlMode());
if(output.getControlMode().isPID() || output.getControlMode() == TalonControlMode.MotionMagic) {
talon.setPID(output.gains.P, output.gains.I, output.gains.D, output.gains.F, output.gains.izone, output.gains.rampRate, output.profile);
}
if (output.getControlMode() == CANTalon.TalonControlMode.MotionMagic) {
talon.setMotionMagicAcceleration(output.accel);
talon.setMotionMagicCruiseVelocity(output.cruiseVel);
}
talon.set(output.getSetpoint());
}
示例14: Shooter
import com.ctre.CANTalon; //导入方法依赖的package包/类
/**
* Create the instance of Shooter.
*/
public Shooter() {
logger.info("Initialize");
if (RobotMap.IS_ROADKILL) {
return;
}
// account for missing Talons
if (Robot.deviceFinder.isTalonAvailable(RobotMap.CT_ID_SHOOTER_MASTER)) {
masterId = RobotMap.CT_ID_SHOOTER_MASTER;
slaveId = RobotMap.CT_ID_SHOOTER_SLAVE;
} else {
logger.warn("Master talon is missing");
masterId = RobotMap.CT_ID_SHOOTER_SLAVE;
// in case it comes back
slaveId = RobotMap.CT_ID_SHOOTER_MASTER;
}
shooterMaster = new CANTalon(masterId);
// basic setup
shooterMaster.changeControlMode(CANTalon.TalonControlMode.Speed);
shooterMaster.enableBrakeMode(false); // probably bad for 775pros
shooterMaster.setFeedbackDevice(CANTalon.FeedbackDevice.CtreMagEncoder_Relative);
shooterMaster.reverseSensor(false);
// the Talon needs peak and nominal output values
shooterMaster.configNominalOutputVoltage(+0.0f, -0.0f);
shooterMaster.configPeakOutputVoltage(+12.0f, -12.0f);
// configure PID
shooterMaster.setProfile(0);
shooterMaster.setF(0);
shooterMaster.setP(0.12);
shooterMaster.setI(0.00012);
shooterMaster.setD(0.5);
// add to LiveWindow for easy testing
LiveWindow.addActuator("Shooter", "Master", shooterMaster);
shooterSlave = new CANTalon(slaveId);
shooterSlave.changeControlMode(CANTalon.TalonControlMode.Follower);
shooterSlave.enableBrakeMode(false);
shooterSlave.set(masterId);
LiveWindow.addActuator("Shooter", "Slave", shooterSlave);
Thread shooterWatchdog = new Thread(this::shooterWatchdogThread);
// allow JVM to exit
shooterWatchdog.setDaemon(true);
// in the debugger, we'd like to know what this is
shooterWatchdog.setName("Shooter Watchdog Thread");
shooterWatchdog.start();
SmartDashboard.putData(new InstantCommand("ForceOverrideShooterFault") {
@Override
public void execute() {
shooterFault = false;
}
});
}
示例15: configureSlave
import com.ctre.CANTalon; //导入方法依赖的package包/类
private void configureSlave(CANTalon talon, int masterId) {
logger.info("init slave: " + talon.getDeviceID() + " to master " + masterId);
talon.changeControlMode(CANTalon.TalonControlMode.Follower);
talon.set(masterId);
talon.enableBrakeMode(true);
}