本文整理汇总了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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例15: copyWithEncoder
import com.ctre.CANTalon.FeedbackDevice; //导入依赖的package包/类
@NotNull
Encoder copyWithEncoder(CANTalon.FeedbackDevice feedbackDevice) {
return new Encoder(feedbackDevice, reversed, unitScalingEnabled ? ticksPerRevolution : null);
}