本文整理汇总了Java中edu.wpi.first.wpilibj.Encoder.reset方法的典型用法代码示例。如果您正苦于以下问题:Java Encoder.reset方法的具体用法?Java Encoder.reset怎么用?Java Encoder.reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.wpi.first.wpilibj.Encoder
的用法示例。
在下文中一共展示了Encoder.reset方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: resetEncoders
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public void resetEncoders() {
for (Encoder encoder: encoderArr) {
encoder.reset();
}
for (PIDController wheelSpeedPID: wheelSpeedPIDArr) {
wheelSpeedPID.setSetpoint(0.0);
}
}
示例3: 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);
}
示例4: RPMEncoder
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public RPMEncoder(int aSlot, int aChannel, int bSlot, int bChannel, boolean reverseDirection, double pulsesPerRotation, int numAveragedCycles) {
m_pulsesPerRotation = pulsesPerRotation;
m_numAveragedCycles = numAveragedCycles;
m_encoder = new Encoder(aSlot, aChannel, bSlot, bChannel, reverseDirection, CounterBase.EncodingType.k4X);
m_motorRPM = new double[numAveragedCycles];
m_encoder.reset();
resetMotorRPM();
}
示例5: 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();
}
示例6: initialize
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public void initialize()
{
rearLeftMotor = new Jaguar(0);
frontLeftMotor = new Jaguar(1);
liftMotor = new Jaguar(2);
liftMotor2 = new Jaguar(3);
liftEncoder = new Encoder(6, 7, false, EncodingType.k4X);
drivetrain = new RobotDrive(rearLeftMotor, frontLeftMotor);
drivetrain.setInvertedMotor(MotorType.kFrontLeft, true);
drivetrain.setInvertedMotor(MotorType.kFrontRight, true);
halsensor = new DigitalInput(0);
horizontalCamera = new Servo(8);
verticalCamera = new Servo(9);
solenoid = new DoubleSolenoid(0,1);
gyro = new Gyro(1);
accelerometer = new BuiltInAccelerometer();
liftEncoder.reset();
RobotHardwareWoodbot hardware = (RobotHardwareWoodbot)Robot.bot;
LiveWindow.addActuator("Drive Train", "Front Left Motor", (Jaguar)hardware.frontLeftMotor);
LiveWindow.addActuator("Drive Train", "Back Left Motor", (Jaguar)hardware.rearLeftMotor);
//LiveWindow.addActuator("Drive Train", "Front Right Motor", (Jaguar)hardware.frontRightMotor);
//LiveWindow.addActuator("Drive Train", "Back Right Motor", (Jaguar)hardware.rearRightMotor);
}
示例7: 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);
}
示例8: DriveTrain
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public DriveTrain() {
super();
frontLeft = new CANTalon(RobotMap.DRIVE_TRAIN_FRONT_LEFT);
frontRight = new CANTalon(RobotMap.DRIVE_TRAIN_FRONT_RIGHT);
backLeft = new CANTalon(RobotMap.DRIVE_TRAIN_BACK_LEFT);
backRight = new CANTalon(RobotMap.DRIVE_TRAIN_BACK_RIGHT);
frontLeft.set(0);
frontRight.set(0);
backLeft.set(0);
backRight.set(0);
double voltageRampRate = 150;//20;
frontLeft.setVoltageRampRate(voltageRampRate);
frontRight.setVoltageRampRate(voltageRampRate);
backLeft.setVoltageRampRate(voltageRampRate);
backRight.setVoltageRampRate(voltageRampRate);
//backRight.setCurrentLimit(0);
setBrake(false);
drive = new RobotDrive(frontLeft, backLeft, frontRight, backRight);
// Scale encoder pulses to distance in inches
double wheelDiameter = 4.0; // inches
double encoderToShaftRatio = 3; // 3X gear reduction
double pulsesPerRevolution = 256;
double stage3Ratio = 50.0 / 34.0;
double distancePerPulse = Math.PI * wheelDiameter / (encoderToShaftRatio * pulsesPerRevolution);
distancePerPulse /= stage3Ratio;
leftEncoder = new Encoder(RobotMap.DRIVE_TRAIN_ENCODER_LEFT_A, RobotMap.DRIVE_TRAIN_ENCODER_LEFT_B,
true, EncodingType.k4X);
leftEncoder.reset();
leftEncoder.setDistancePerPulse(distancePerPulse);
rightEncoder = new Encoder(RobotMap.DRIVE_TRAIN_ENCODER_RIGHT_A, RobotMap.DRIVE_TRAIN_ENCODER_RIGHT_B,
true, EncodingType.k4X);
rightEncoder.reset();
rightEncoder.setDistancePerPulse(distancePerPulse);
}
示例9: 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();
}
示例10: DriveBase
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public DriveBase(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(JoystickButtonEnum.DRIVER_BUTTON_8);
//Turbo button
registerForJoystickButtonNotification(JoystickButtonEnum.DRIVER_BUTTON_7);
//Shifter Button
registerForJoystickButtonNotification(JoystickButtonEnum.DRIVER_BUTTON_6);
//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);
continuousAccelerationFilter = new ContinuousAccelFilter(0, 0, 0);
driveSpeedPidInput = new DriveBaseSpeedPidInput();
driveSpeedPidOutput = new DriveBaseSpeedPidOutput();
driveSpeedPid = new SpeedPidController(driveSpeedPidInput, driveSpeedPidOutput, "DriveBaseSpeedPid");
init();
}
示例11: 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
Subject subject = WsInputManager.getInstance().getOiInput(WsInputManager.DRIVER_JOYSTICK).getSubject(WsDriverJoystickButtonEnum.BUTTON8);
subject.attach(this);
//Turbo button
subject = WsInputManager.getInstance().getOiInput(WsInputManager.DRIVER_JOYSTICK).getSubject(WsDriverJoystickButtonEnum.BUTTON7);
subject.attach(this);
//Shifter Button
subject = WsInputManager.getInstance().getOiInput(WsInputManager.DRIVER_JOYSTICK).getSubject(WsDriverJoystickButtonEnum.BUTTON6);
subject.attach(this);
//Left/right slow turn buttons
subject = WsInputManager.getInstance().getOiInput(WsInputManager.DRIVER_JOYSTICK).getSubject(WsDriverJoystickButtonEnum.BUTTON1);
subject.attach(this);
subject = WsInputManager.getInstance().getOiInput(WsInputManager.DRIVER_JOYSTICK).getSubject(WsDriverJoystickButtonEnum.BUTTON3);
subject.attach(this);
//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();
}
示例12: WheelRotation
import edu.wpi.first.wpilibj.Encoder; //导入方法依赖的package包/类
public WheelRotation(double wheelDiameter, double pulsesPerRevolution){
leftEncoder = new Encoder(0, 1, false);
rightEncoder = new Encoder(2, 3, false);
inchesPerPulse = Math.PI*wheelDiameter/pulsesPerRevolution;
leftEncoder.setDistancePerPulse(inchesPerPulse);
rightEncoder.setDistancePerPulse(inchesPerPulse);
leftEncoder.reset();
rightEncoder.reset();
}