本文整理匯總了Java中edu.wpi.first.wpilibj.Encoder.setDistancePerPulse方法的典型用法代碼示例。如果您正苦於以下問題:Java Encoder.setDistancePerPulse方法的具體用法?Java Encoder.setDistancePerPulse怎麽用?Java Encoder.setDistancePerPulse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edu.wpi.first.wpilibj.Encoder
的用法示例。
在下文中一共展示了Encoder.setDistancePerPulse方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DriveEncoders
import edu.wpi.first.wpilibj.Encoder; //導入方法依賴的package包/類
/**
* Constructs left and right encoders to be used by the subsystem
* @param leftChannelA DIO port for the left encoder and channel a
* @param leftChannelB DIO port for the left encoder and channel b
* @param rightChannelA DIO port for the right encoder and channel a
* @param rightChannelB DIO port for the right encoder and channel b
* @param maxPeriod max period to be considered stopped
* @param minRate max rate to be considered stopped
* @param distancePerPulse value to convert a pulse into a distance. This is based on encoder resolution and wheel size.
* @param reverseDirection should the encoder direction be reversed
* @param samplesToAverage number of samples to average to calculate period
*/
public DriveEncoders(int leftChannelA, int leftChannelB, int rightChannelA,int rightChannelB,
double maxPeriod, int minRate, double distancePerPulse, boolean reverseDirection,int samplesToAverage) {
encoderLeft = new Encoder(leftChannelA, leftChannelB, reverseDirection, Encoder.EncodingType.k4X);
encoderRight = new Encoder(rightChannelA, rightChannelB, reverseDirection, Encoder.EncodingType.k4X);
encoderLeft.setMaxPeriod(maxPeriod);
encoderLeft.setMinRate(minRate);
encoderLeft.setDistancePerPulse(distancePerPulse);
encoderLeft.setSamplesToAverage(samplesToAverage);
encoderRight.setMaxPeriod(maxPeriod);
encoderRight.setMinRate(minRate);
encoderRight.setDistancePerPulse(distancePerPulse);
encoderRight.setSamplesToAverage(samplesToAverage);
}
示例2: Arm
import edu.wpi.first.wpilibj.Encoder; //導入方法依賴的package包/類
public Arm() {
super("arm", kP, kI, kD);
motor = new Talon(RobotMap.ArmMap.PWM_MOTOR);
motor.setInverted(RobotMap.ArmMap.INV_MOTOR);
encoder = new Encoder(RobotMap.ArmMap.DIO_ENCODER_A, RobotMap.ArmMap.DIO_ENCODER_B);
encoder.setDistancePerPulse(RobotMap.ArmMap.DISTANCE_PER_PULSE);
encoder.setReverseDirection(RobotMap.ArmMap.INV_ENCODER);
upperLimit = new DigitalInput(RobotMap.ArmMap.DIO_LIMIT_TOP);
bottomLimit = new DigitalInput(RobotMap.ArmMap.DIO_LIMIT_BOTTOM);
setAbsoluteTolerance(0.05);
getPIDController().setContinuous(false);
}
示例3: Shooter
import edu.wpi.first.wpilibj.Encoder; //導入方法依賴的package包/類
public Shooter() {
shooterLeftSide = new Talon(RobotMap.Pwm.LeftShooterMotor);
shooterRightSide = new Talon(RobotMap.Pwm.RightShooterMotor);
encoderLeft = new Encoder(RobotMap.Digital.ShooterLeftChannelA, RobotMap.Digital.ShooterLeftChannelB);
encoderRight = new Encoder(RobotMap.Digital.ShooterRightChannelA, RobotMap.Digital.ShooterRightChannelB);
encoderLeft.setPIDSourceType(PIDSourceType.kRate);
encoderRight.setPIDSourceType(PIDSourceType.kRate);
encoderLeft.setDistancePerPulse(distancePerPulse);
encoderRight.setDistancePerPulse(distancePerPulse);
// leftPID = new PIDSpeedController(encoderLeft, shooterLeftSide, "Shooter", "Left Wheel");
// rightPID = new PIDSpeedController(encoderRight, shooterRightSide, "Shooter", "Right Wheel");
}
示例4: SensorInput
import edu.wpi.first.wpilibj.Encoder; //導入方法依賴的package包/類
/**
* Instantiates the Sensor Input module to read all sensors connected to the roboRIO.
*/
private SensorInput() {
limit_left = new DigitalInput(ChiliConstants.left_limit);
limit_right = new DigitalInput(ChiliConstants.right_limit);
accel = new BuiltInAccelerometer(Accelerometer.Range.k2G);
gyro = new Gyro(ChiliConstants.gyro_channel);
pdp = new PowerDistributionPanel();
left_encoder = new Encoder(ChiliConstants.left_encoder_channelA, ChiliConstants.left_encoder_channelB, false);
right_encoder = new Encoder(ChiliConstants.right_encoder_channelA, ChiliConstants.right_encoder_channelB, true);
gyro_i2c = new GyroITG3200(I2C.Port.kOnboard);
gyro_i2c.initialize();
gyro_i2c.reset();
gyro.initGyro();
left_encoder.setDistancePerPulse(ChiliConstants.kDistancePerPulse);
right_encoder.setDistancePerPulse(ChiliConstants.kDistancePerPulse);
}
示例5: Drive
import edu.wpi.first.wpilibj.Encoder; //導入方法依賴的package包/類
private Drive()
{
drive = new RobotDrive(new Talon(1),new Talon(2),new Talon(3),new Talon(4));
drive.setSafetyEnabled(false);
e1 = new Encoder(RobotMap.ENCODER_1_A, RobotMap.ENCODER_1_B, false, CounterBase.EncodingType.k4X);
e2 = new Encoder(RobotMap.ENCODER_2_A, RobotMap.ENCODER_2_B, false, CounterBase.EncodingType.k4X);
//A calculated constant to convert from encoder ticks to feet on 4 inch diameter wheels
e1.setDistancePerPulse(0.0349065850388889/12);
e2.setDistancePerPulse(0.0349065850388889/12);
startEncoders();
drive.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, true);
drive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, true);
sonic = new Ultrasonic(RobotMap.ULTRASONIC_A, RobotMap.ULTRASONIC_B);
sonic.setAutomaticMode(true);
sonic.setEnabled(true);
shifter = new DoubleSolenoid(RobotMap.SHIFTER_ENGAGE, RobotMap.SHIFTER_DISENGAGE);
}
示例6: 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);
}
示例7: 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();
}
示例8: 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();
}
示例9: 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();
}
示例10: DriveTrain
import edu.wpi.first.wpilibj.Encoder; //導入方法依賴的package包/類
public DriveTrain () {
rightMotors = new VictorSP(Constants.DRIVETRAIN_RIGHT);
leftMotors = new VictorSP(Constants.DRIVETRAIN_LEFT);
rightMotors.setInverted(rightInverted);
leftMotors.setInverted(leftInverted);
encLeft = new Encoder(Constants.ENCODER_LEFT_1, Constants.ENCODER_LEFT_2);
encLeft.setDistancePerPulse(Constants.DRIVEWHEEL_CIRCUMFERENCE / Constants.DRIVE_PULSES_PER_REVOLUTION);
encRight = new Encoder(Constants.ENCODER_RIGHT_1, Constants.ENCODER_RIGHT_2);
encRight.setDistancePerPulse(Constants.DRIVEWHEEL_CIRCUMFERENCE / Constants.DRIVE_PULSES_PER_REVOLUTION);
}
示例11: init
import edu.wpi.first.wpilibj.Encoder; //導入方法依賴的package包/類
public static void init() {
// Drivetrain
DRIVETRAIN_ROBOT_DRIVE = new RobotDrive(0, 1);
DRIVETRAIN_ENCODER_LEFT = new Encoder(0, 1);
DRIVETRAIN_ENCODER_LEFT.setDistancePerPulse(0.0481);
DRIVETRAIN_ENCODER_RIGHT = new Encoder(2, 3, true);
DRIVETRAIN_ENCODER_RIGHT.setDistancePerPulse(0.0481);
// Floor Gear
FLOORGEAR_INTAKE = new VictorSP(2);
FLOORGEAR_LIFTER = new DoubleSolenoid(0, 1);
FLOORGEAR_BLOCKER = new DoubleSolenoid(2, 3);
// Climber
CLIMBER = new VictorSP(3);
// Passive Gear
SLOTGEAR_HOLDER = new DoubleSolenoid(4, 5);
// Vision
VISION_SERVER = CameraServer.getInstance();
VISION_CAMERA = VISION_SERVER.startAutomaticCapture("FRONT", 0);
VISION_CAMERA.getProperty("saturation").set(20);
VISION_CAMERA.getProperty("gain").set(50);
VISION_CAMERA.getProperty("exposure_auto").set(1);
VISION_CAMERA.getProperty("brightness").set(50);
VISION_CAMERA.getProperty("exposure_absolute").set(1);
VISION_CAMERA.getProperty("exposure_auto_priority").set(0);
}
示例12: TankDrive
import edu.wpi.first.wpilibj.Encoder; //導入方法依賴的package包/類
public TankDrive() {
super();
leftMotor1 = new CANTalon(RobotMap.DRIVE_LEFT_MOTOR1);
leftMotor2 = new CANTalon(RobotMap.DRIVE_LEFT_MOTOR2);
rightMotor1 = new CANTalon(RobotMap.DRIVE_RIGHT_MOTOR1);
rightMotor2 = new CANTalon(RobotMap.DRIVE_RIGHT_MOTOR2);
leftEncoder = new Encoder(RobotMap.DRIVE_LEFT_ENCODERA, RobotMap.DRIVE_LEFT_ENCODERB, false);// would spin clockwise or +; T=-, f=-?
rightEncoder = new Encoder(RobotMap.DRIVE_RIGHT_ENCODERA, RobotMap.DRIVE_RIGHT_ENCODERB,
/*RobotMap.ROBOT_TYPE == RobotMap.COMP_BOT_NUM*/ false);// would spin counter-clockwise or -; boolean reverses direction
leftEncoder.setDistancePerPulse(RobotMap.DRIVE_RATIO);
rightEncoder.setDistancePerPulse(RobotMap.DRIVE_RATIO);
}
示例13: DriveTrain
import edu.wpi.first.wpilibj.Encoder; //導入方法依賴的package包/類
public DriveTrain() {
super();
front_left_motor = new Talon(1);
back_left_motor = new Talon(2);
front_right_motor = new Talon(3);
back_right_motor = new Talon(4);
drive = new RobotDrive(front_left_motor, back_left_motor,
front_right_motor, back_right_motor);
left_encoder = new Encoder(1, 2);
right_encoder = new Encoder(3, 4);
// Encoders may measure differently in the real world and in
// simulation. In this example the robot moves 0.042 barleycorns
// per tick in the real world, but the simulated encoders
// simulate 360 tick encoders. This if statement allows for the
// real robot to handle this difference in devices.
if (Robot.isReal()) {
left_encoder.setDistancePerPulse(0.042);
right_encoder.setDistancePerPulse(0.042);
} else {
// Circumference in ft = 4in/12(in/ft)*PI
left_encoder.setDistancePerPulse((4.0/12.0*Math.PI) / 360.0);
right_encoder.setDistancePerPulse((4.0/12.0*Math.PI) / 360.0);
}
rangefinder = new AnalogInput(6);
gyro = new AnalogGyro(1);
// Let's show everything on the LiveWindow
LiveWindow.addActuator("Drive Train", "Front_Left Motor", (Talon) front_left_motor);
LiveWindow.addActuator("Drive Train", "Back Left Motor", (Talon) back_left_motor);
LiveWindow.addActuator("Drive Train", "Front Right Motor", (Talon) front_right_motor);
LiveWindow.addActuator("Drive Train", "Back Right Motor", (Talon) back_right_motor);
LiveWindow.addSensor("Drive Train", "Left Encoder", left_encoder);
LiveWindow.addSensor("Drive Train", "Right Encoder", right_encoder);
LiveWindow.addSensor("Drive Train", "Rangefinder", rangefinder);
LiveWindow.addSensor("Drive Train", "Gyro", gyro);
}
示例14: 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);
}
示例15: EncoderPIDSubsystem
import edu.wpi.first.wpilibj.Encoder; //導入方法依賴的package包/類
public EncoderPIDSubsystem(String name, double kP, double kI, double kD, int motorChannel, int encoderAChannel, int encoderBChannel, boolean reverseEncoder, double gearRatioEncoderToOutput) {
super(name, kP, kI, kD);
try {
m_motorController = new Victor(motorChannel);
m_encoder = new Encoder(1, encoderAChannel, 1, encoderBChannel, reverseEncoder, CounterBase.EncodingType.k4X);
double degPerPulse = 360.0 / gearRatioEncoderToOutput / DEFAULT_PULSES_PER_ROTATION;
m_encoder.setDistancePerPulse(degPerPulse);
resetZeroPosition();
} catch (Exception e) {
System.out.println("Unknown error initializing " + getName() + "-EncoderPIDSubsystem. Message = " + e.getMessage());
}
}