本文整理汇总了Java中edu.wpi.first.wpilibj.Encoder.start方法的典型用法代码示例。如果您正苦于以下问题:Java Encoder.start方法的具体用法?Java Encoder.start怎么用?Java Encoder.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.wpi.first.wpilibj.Encoder
的用法示例。
在下文中一共展示了Encoder.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: QuadratureEncoder
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
/**
* Creates an encoder using the two SIG inputs (A and B).
* Also allows the encoder to be reversed.
* Can also control the difference between getRaw and get values.
* pulsesPerRev is used for getDistance() methods.
* @param channelA I/0 SIG A.
* @param channelB I/O SIG B.
* @param isReversed When true, returned values are inverted.
* @param scaleValue getRaw() values are divided by multiples of 1, 2, or 4 to increase accuracy.
* @param pulsesPerRev Number of pulses for a revolution of the motor (look at instance variable).
*/
public QuadratureEncoder(int channelA, int channelB, boolean isReversed,
int scaleValue, double pulsesPerRev)
{
CounterBase.EncodingType encType = CounterBase.EncodingType.k4X;
if (scaleValue == 1)
encType = CounterBase.EncodingType.k1X;
else if (scaleValue == 2)
encType = CounterBase.EncodingType.k2X;
else if (scaleValue == 4)
encType = CounterBase.EncodingType.k4X;
enc = new Encoder(channelA, channelB, isReversed, encType);
pulsesPerRevolution = pulsesPerRev;
enc.start();
}
示例2: DriveTrain
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public DriveTrain(boolean isCan)
{
shifter = new Piston(SHIFTER_EXTEND_PORT, SHIFTER_RETRACT_PORT);
left = new BTMotor(LEFT_JAG_PORT, isCan, isVoltage);
left_2 = new BTMotor(LEFT_JAG_PORT_2, isCan, isVoltage);
right = new BTMotor(RIGHT_JAG_PORT, isCan, isVoltage);
right_2 = new BTMotor(RIGHT_JAG_PORT_2, isCan, isVoltage);
shiftSpeed = new Encoder(DRIVE_ENCODER_A_PORT, DRIVE_ENCODER_B_PORT, true, CounterBase.EncodingType.k1X);
shiftSpeed.setDistancePerPulse(distance);
shiftSpeed.start();
shiftSpeed.reset();
left.setBTVoltageRampRate(ramprate);
left_2.setBTVoltageRampRate(ramprate);
right.setBTVoltageRampRate(ramprate);
right_2.setBTVoltageRampRate(ramprate);
}
示例3: TankDrivePIDSubsystem
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public TankDrivePIDSubsystem(double p, double i, double d,
DriveSideWrapper motors,
int encoderAChannel, int encoderBChannel,
double distancePerPulse) {
super("LeftTankDrivePIDSubsystem", p, i, d);
// Use these to get going:
// setSetpoint() - Sets where the PID controller should move the system
// to
// enable() - Enables the PID controller.
this.motors = motors;
encoder = new Encoder(encoderAChannel, encoderBChannel);
encoder.start();
encoder.setDistancePerPulse(distancePerPulse);
rampTimer = new Timer();
rampTimer.start();
}
示例4: RightTankDrivePIDSubsystem
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public RightTankDrivePIDSubsystem() {
super("LeftTankDrivePIDSubsystem", Kp, Ki, Kd);
// Use these to get going:
// setSetpoint() - Sets where the PID controller should move the system
// to
// enable() - Enables the PID controller.
frontRightMotor = new Victor(RobotMap.FRONT_RIGHT_DRIVE_MOTOR);
backRightMotor = new Victor(RobotMap.BACK_RIGHT_DRIVE_MOTOR);
rightEncoder = new Encoder(RobotMap.FRONT_RIGHT_ENCODER_A, RobotMap.FRONT_RIGHT_ENCODER_B);
rightEncoder.start();
rightEncoder.setDistancePerPulse(1.0);
rampTimer = new Timer();
rampTimer.start();
}
示例5: LeftTankDrivePIDSubsystem
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public LeftTankDrivePIDSubsystem() {
super("LeftTankDrivePIDSubsystem", Kp, Ki, Kd);
// Use these to get going:
// setSetpoint() - Sets where the PID controller should move the system
// to
// enable() - Enables the PID controller.
frontLeftMotor = new Victor(RobotMap.FRONT_LEFT_DRIVE_MOTOR);
backLeftMotor = new Victor(RobotMap.BACK_LEFT_DRIVE_MOTOR);
leftEncoder = new Encoder(RobotMap.FRONT_LEFT_ENCODER_A, RobotMap.FRONT_LEFT_ENCODER_B);
leftEncoder.start();
leftEncoder.setDistancePerPulse(1.0);
rampTimer = new Timer();
rampTimer.start();
}
示例6: Winch
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
Winch(JoyStickCustom inStick){
winchRelease=new Pneumatics(1,2);
winch= new Victor(5);
states[0]="WINDING";
states[1]="RELEASING";
states[2]="HOLDING";
setState(HOLDING1);//same as holding used to be
limitSwitch= new DigitalInput(4);
secondStick = inStick;
winchE= new Encoder(3,2);
winchE.start();
}
示例7: initializeWinch
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
private void initializeWinch() {
winchEncoder = new Encoder(RobotMap.SHOOTER_WINCH_ENCODER_A, RobotMap.SHOOTER_WINCH_ENCODER_B);
winchEncoder.reset();
winchEncoder.setDistancePerPulse(1);
winchEncoder.setPIDSourceParameter(Encoder.PIDSourceParameter.kDistance);
winchEncoder.start();
controller = new PIDController(P, I, D, winchEncoder, winch);
controller.setOutputRange(-1, 1);
controller.setPID(P, I, D);
}
示例8: ShootArm
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public ShootArm() {
arm = new Talon(Ports.SHOOTER_LAUNCHER);
arm.set(0);
launcherEncoder = new Encoder(Ports.SHOOTER_ENCODER_1, Ports.SHOOTER_ENCODER_2, false, Encoder.EncodingType.k4X);
launcherEncoder.start();
launcherEncoder.setDistancePerPulse(0.96);
launcherEncoder.setMinRate(1);
armHome = new DigitalInput(Ports.SHOOTER_HOME);
armCounter = new Counter(armHome);
armCounter.start();
state = 0;
}
示例9: Shooter
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public Shooter(int encoderA, int encoderB, int victor1, int victor2, int victor3) {
m_encode = new Encoder(encoderA, encoderB);
m_encode.start();
m_encode.reset();
m_motor1 = new Victor(victor1);
m_motor2 = new Victor(victor2);
m_motor3 = new Victor(victor3);
m_shootTimer = new Timer();
m_retractTimer = new Timer();
}
示例10: Climber
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
private Climber()
{
climberController = new Jaguar(BadRobotMap.climberArticulator);
encoder = new Encoder(BadRobotMap.climberEncoderIn, BadRobotMap.climberEncoderOut, true);
encoder.start();
//controller = new EasyPID(.01, 0.0, 0.0, 0.0, "Climber Controller", encoder);
//controller.controller.enable();
//controller.setAbsoluteTolerance(8);
//controller.enable();
}
示例11: init
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
void init() {
gy = new Gyro(RobotMap.gyroport);
gy.reset();
rotaryEncoder = new Encoder(1,2);
rotaryEncoder.start();
rotaryEncoder.reset();//Justin Case, attorney at law!
feederLimit = new DigitalInput(14);
}
示例12: GRTEncoder
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
/**
* Instantiates an encoder on the default digital module.
*
* @param channelA digital channel for encoder channel A
* @param channelB digital channel for encoder channel B
* @param pulseDistance distance traveled for each pulse (typically 1 degree
* of rotation per pulse)
* @param reversed whether or not the encoder is reversed
* @param name name of encoder
*/
public GRTEncoder(int channelA, int channelB,
double pulseDistance, boolean reversed, String name) {
super(name, NUM_DATA);
//Create new encoder that does 1x encoding, as opposed to 4x.
rotaryEncoder = new Encoder(channelA, channelB, reversed,
CounterBase.EncodingType.k1X);
rotaryEncoder.start();
encoderListeners = new Vector();
distancePerPulse = pulseDistance;
rotaryEncoder.setDistancePerPulse(distancePerPulse);
}
示例13: Tilter
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
private Tilter() {
leadscrew = new BoundedTalon(Constants.TILTER_CHANNEL, Constants.TILTER_UPPER_LIMIT_SWITCH_CHANNEL, Constants.TILTER_LOWER_LIMIT_SWITCH_CHANNEL);
accel = new ADXL345_I2C(Constants.ACCELEROMETER_CHANNEL, ADXL345_I2C.DataFormat_Range.k2G);
accelMeasurements = new Vector();
updateAccel();
pendulum = new AnalogChannel(Constants.PENDULUM_CHANNEL);
enc = new Encoder(Constants.LEADSCREW_ENCODER_A_CHANNEL, Constants.LEADSCREW_ENCODER_B_CHANNEL);
enc.setDistancePerPulse(Constants.TILTER_DISTANCE_PER_PULSE);
enc.start();
Thread t = new Thread(new Runnable() {
public void run() {
Tilter.net = new NetworkIO();
}
});
t.start();
controller = new PIDController(Constants.PVAL_T, Constants.IVAL_T, Constants.DVAL_T, enc, new PIDOutput() {
public void pidWrite(double output) {
setLeadscrewMotor(output);
}
});
controller.setPercentTolerance(0.01);
controller.disable();
updatePID();
initialReadingTimer = new Timer();
initialReadingTimer.schedule(new TimerTask() {
public void run() {
initialLeadLength = calcLeadscrewLength(getAveragedAccelBasedAngle());
}
}, INITIAL_ANGLE_MEASUREMENT_DELAY);
}
示例14: WsDriveBase
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public WsDriveBase(String name) {
super(name);
WHEEL_DIAMETER_config = new DoubleConfigFileParameter(this.getClass().getName(), "wheel_diameter", 6);
TICKS_PER_ROTATION_config = new DoubleConfigFileParameter(this.getClass().getName(), "ticks_per_rotation", 360.0);
THROTTLE_LOW_GEAR_ACCEL_FACTOR_config = new DoubleConfigFileParameter(this.getClass().getName(), "throttle_low_gear_accel_factor", 0.250);
HEADING_LOW_GEAR_ACCEL_FACTOR_config = new DoubleConfigFileParameter(this.getClass().getName(), "heading_low_gear_accel_factor", 0.500);
THROTTLE_HIGH_GEAR_ACCEL_FACTOR_config = new DoubleConfigFileParameter(this.getClass().getName(), "throttle_high_gear_accel_factor", 0.125);
HEADING_HIGH_GEAR_ACCEL_FACTOR_config = new DoubleConfigFileParameter(this.getClass().getName(), "heading_high_gear_accel_factor", 0.250);
MAX_HIGH_GEAR_PERCENT_config = new DoubleConfigFileParameter(this.getClass().getName(), "max_high_gear_percent", 0.80);
ENCODER_GEAR_RATIO_config = new DoubleConfigFileParameter(this.getClass().getName(), "encoder_gear_ratio", 7.5);
DEADBAND_config = new DoubleConfigFileParameter(this.getClass().getName(), "deadband", 0.05);
SLOW_TURN_FORWARD_SPEED_config = new DoubleConfigFileParameter(this.getClass().getName(), "slow_turn_forward_speed", 0.16);
SLOW_TURN_BACKWARD_SPEED_config = new DoubleConfigFileParameter(this.getClass().getName(), "slow_turn_backward_speed", -0.19);
FEED_FORWARD_VELOCITY_CONSTANT_config = new DoubleConfigFileParameter(this.getClass().getName(), "feed_forward_velocity_constant", 1.00);
FEED_FORWARD_ACCELERATION_CONSTANT_config = new DoubleConfigFileParameter(this.getClass().getName(), "feed_forward_acceleration_constant", 0.00018);
MAX_ACCELERATION_DRIVE_PROFILE_config = new DoubleConfigFileParameter(this.getClass().getName(), "max_acceleration_drive_profile", 600.0);
MAX_SPEED_INCHES_LOWGEAR_config = new DoubleConfigFileParameter(this.getClass().getName(), "max_speed_inches_lowgear", 90.0);
DECELERATION_VELOCITY_THRESHOLD_config = new DoubleConfigFileParameter(this.getClass().getName(), "deceleration_velocity_threshold", 48.0);
DECELERATION_MOTOR_SPEED_config = new DoubleConfigFileParameter(this.getClass().getName(), "deceleration_motor_speed", 0.3);
STOPPING_DISTANCE_AT_MAX_SPEED_LOWGEAR_config = new DoubleConfigFileParameter(this.getClass().getName(), "stopping_distance_at_max_speed_lowgear", 10.0);
DRIVE_OFFSET_config = new AutonomousDoubleConfigFileParameter("DriveOffset", 1.00);
USE_LEFT_SIDE_FOR_OFFSET_config = new AutonomousBooleanConfigFileParameter("UseLeftDriveForOffset", true);
QUICK_TURN_CAP_config = new DoubleConfigFileParameter(this.getClass().getName(), "quick_turn_cap", 10.0);
QUICK_TURN_ANTITURBO_config = new DoubleConfigFileParameter(this.getClass().getName(), "quick_turn_antiturbo", 10.0);
//Anti-Turbo button
registerForJoystickButtonNotification(WsJoystickButtonEnum.DRIVER_BUTTON_8);
//Turbo button
registerForJoystickButtonNotification(WsJoystickButtonEnum.DRIVER_BUTTON_7);
//Shifter Button
registerForJoystickButtonNotification(WsJoystickButtonEnum.DRIVER_BUTTON_6);
//Left/right slow turn buttons
registerForJoystickButtonNotification(WsJoystickButtonEnum.DRIVER_BUTTON_1);
registerForJoystickButtonNotification(WsJoystickButtonEnum.DRIVER_BUTTON_3);
//Initialize the drive base encoders
leftDriveEncoder = new Encoder(2, 3, true, EncodingType.k4X);
leftDriveEncoder.reset();
leftDriveEncoder.start();
rightDriveEncoder = new Encoder(4, 5, false, EncodingType.k4X);
rightDriveEncoder.reset();
rightDriveEncoder.start();
//Initialize the gyro
//@TODO: Get the correct port
driveHeadingGyro = new Gyro(1);
//Initialize the PIDs
driveDistancePidInput = new WsDriveBaseDistancePidInput();
driveDistancePidOutput = new WsDriveBaseDistancePidOutput();
driveDistancePid = new WsPidController(driveDistancePidInput, driveDistancePidOutput, "WsDriveBaseDistancePid");
driveHeadingPidInput = new WsDriveBaseHeadingPidInput();
driveHeadingPidOutput = new WsDriveBaseHeadingPidOutput();
driveHeadingPid = new WsPidController(driveHeadingPidInput, driveHeadingPidOutput, "WsDriveBaseHeadingPid");
driveSpeedPidInput = new WsDriveBaseSpeedPidInput();
driveSpeedPidOutput = new WsDriveBaseSpeedPidOutput();
driveSpeedPid = new WsSpeedPidController(driveSpeedPidInput, driveSpeedPidOutput, "WsDriveBaseSpeedPid");
continuousAccelerationFilter = new ContinuousAccelFilter(0, 0, 0);
init();
}
示例15: robotInit
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public void robotInit() {
ds = DriverStation.getInstance();
drive = new RobotDrive(Ports.DRIVE_LEFT, Ports.DRIVE_RIGHT);
drive.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, true);
drive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, true);
drive.setInvertedMotor(RobotDrive.MotorType.kFrontRight, true);
drive.setInvertedMotor(RobotDrive.MotorType.kRearRight, true);
leftDrive = new Encoder(3, 4, true, Encoder.EncodingType.k4X);
rightDrive = new Encoder(5, 6, false, Encoder.EncodingType.k4X);
leftDrive.setDistancePerPulse(6 * Math.PI / 360);
rightDrive.setDistancePerPulse(6 * Math.PI / 360);
leftDrive.start();
rightDrive.start();
compressor = new Relay(Ports.COMPRESSOR_RELAY);
tankIsFull = new DigitalInput(Ports.COMPRESSOR_PRESSURE_SWITCH);
leftStick = new Joystick(Ports.JOYSTICK_LEFT);
rightStick = new Joystick(Ports.JOYSTICK_RIGHT);
gamepad = new Joystick(Ports.JOYSTICK_GAMEPAD);
left_stick_prev = new boolean[13];
right_stick_prev = new boolean[13];
gamepad_prev = new boolean[13];
arm = new ShootArm();
intake = new Intake();
tusks = new Tusks();
new Thread() {
public void run() {
while(true) {
//run the right state machines
tusks.runTusks();
arm.runArm();
//output to smartdash
debug();
try {
Thread.sleep(5);
} catch(InterruptedException e) {}
}
}
}.start();
}