本文整理汇总了Java中com.ctre.CANTalon.reverseSensor方法的典型用法代码示例。如果您正苦于以下问题:Java CANTalon.reverseSensor方法的具体用法?Java CANTalon.reverseSensor怎么用?Java CANTalon.reverseSensor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ctre.CANTalon
的用法示例。
在下文中一共展示了CANTalon.reverseSensor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: Shooter
import com.ctre.CANTalon; //导入方法依赖的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);
}
示例3: 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);
}
示例4: configure
import com.ctre.CANTalon; //导入方法依赖的package包/类
public void configure(CANTalon talon) {
talon.setFeedbackDevice(getDevice());
talon.reverseSensor(reversed);
logger.info(
"{}: encoder {} {} reversed", talon.getDescription(), getDevice(), reversed ? "" : "not");
if (unitScalingEnabled) {
talon.configEncoderCodesPerRev(ticksPerRevolution);
logger.info(
"{}: configured {} encoder codes per revolution",
talon.getDescription(),
ticksPerRevolution);
}
checkEncoder(talon);
}
示例5: 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;
}
});
}
示例6: config
import com.ctre.CANTalon; //导入方法依赖的package包/类
@Override
protected void config(CANTalon talon, boolean value) {
talon.reverseSensor(value);
}