当前位置: 首页>>代码示例>>Java>>正文


Java VictorSP.setInverted方法代码示例

本文整理汇总了Java中edu.wpi.first.wpilibj.VictorSP.setInverted方法的典型用法代码示例。如果您正苦于以下问题:Java VictorSP.setInverted方法的具体用法?Java VictorSP.setInverted怎么用?Java VictorSP.setInverted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.wpi.first.wpilibj.VictorSP的用法示例。


在下文中一共展示了VictorSP.setInverted方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Shooter

import edu.wpi.first.wpilibj.VictorSP; //导入方法依赖的package包/类
public Shooter() {
    shooterMotor = new VictorSP(Constants.SHOOTER);
    shooterMotor2 = new VictorSP(Constants.SHOOTER_2);

    shooterMotor.setInverted(true);
    shooterMotor2.setInverted(true);

    hallEffect = new Counter(Constants.HALL_EFFECT);
    hallEffect.setDistancePerPulse(1);
}
 
开发者ID:Team334,项目名称:R2017,代码行数:11,代码来源:Shooter.java

示例2: DriveTrain

import edu.wpi.first.wpilibj.VictorSP; //导入方法依赖的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);
}
 
开发者ID:Team334,项目名称:R2017,代码行数:14,代码来源:DriveTrain.java

示例3: DriveTrain

import edu.wpi.first.wpilibj.VictorSP; //导入方法依赖的package包/类
public DriveTrain() {
	Robot.logList.add(this);
	ahrs = new AHRS(RobotMap.Ports.AHRS);
	left = new VictorSP(RobotMap.Ports.leftDriveMotor);
	right = new VictorSP(RobotMap.Ports.rightDriveMotor);
	right.setInverted(true);
	
	final double gearRatio = 4/3;
	final double ticksPerRev = 2048;
	final double radius = 1.5;
	final double magic = 1/.737;
	final double calculated = (radius * 2 * Math.PI) * gearRatio * magic / ticksPerRev;
	
	ahrs.reset();
	
	leftEncoder = new Encoder(RobotMap.Ports.leftEncoderOne, RobotMap.Ports.leftEncoderTwo, true, EncodingType.k4X);
	leftEncoder.setDistancePerPulse(calculated);
	leftEncoder.setPIDSourceType(PIDSourceType.kRate);
	rightEncoder = new Encoder(RobotMap.Ports.rightEncoderOne, RobotMap.Ports.rightEncoderTwo, false, EncodingType.k4X);
	rightEncoder.setDistancePerPulse(calculated);
	rightEncoder.setPIDSourceType(PIDSourceType.kRate);

	leftPID = new PIDController(
			RobotMap.Values.driveTrainP, RobotMap.Values.driveTrainI,
			RobotMap.Values.driveTrainD, RobotMap.Values.driveTrainF, 
			new RateEncoder(leftEncoder), left);
	leftPID.setInputRange(-300, 300);
	leftPID.setOutputRange(-1, 1);
	rightPID = new PIDController(
			RobotMap.Values.driveTrainP, RobotMap.Values.driveTrainI,
			RobotMap.Values.driveTrainD, RobotMap.Values.driveTrainF, 
			new RateEncoder(rightEncoder), right);
	rightPID.setInputRange(-300, 300);
	rightPID.setOutputRange(-1, 1);
	
	// Let's show everything on the LiveWindow
	LiveWindow.addActuator("Drive Train", "Left Motor", (VictorSP) left);
	LiveWindow.addActuator("Drive Train", "Right Motor", (VictorSP) right);
	LiveWindow.addSensor("Drive Train", "Left Encoder", leftEncoder);
	LiveWindow.addSensor("Drive Train", "Right Encoder", rightEncoder);
	LiveWindow.addSensor("Drive Train", "Gyro", ahrs);
	LiveWindow.addActuator("Drive Train", "PID", leftPID);
	
}
 
开发者ID:Team997Coders,项目名称:2017SteamBot2,代码行数:45,代码来源:DriveTrain.java

示例4: Drive

import edu.wpi.first.wpilibj.VictorSP; //导入方法依赖的package包/类
public Drive() {
// Instantiate VictorSPs
leftFront = new VictorSP(RobotMap.DriveMap.PWM_LEFT_FRONT);
leftBack = new VictorSP(RobotMap.DriveMap.PWM_LEFT_BACK);
rightFront = new VictorSP(RobotMap.DriveMap.PWM_RIGHT_FRONT);
rightBack = new VictorSP(RobotMap.DriveMap.PWM_RIGHT_BACK);

// Create list of motors
leftMotors = new ArrayList<SpeedController>();
leftMotors.add(leftFront);
leftMotors.add(leftBack);

rightMotors = new ArrayList<SpeedController>();
rightMotors.add(rightFront);
rightMotors.add(rightBack);

// Instantiate Encoders
leftEncoder = new Encoder(RobotMap.DriveMap.DIO_ENCODER_LEFT_A, RobotMap.DriveMap.DIO_ENCODER_LEFT_B);
rightEncoder = new Encoder(RobotMap.DriveMap.DIO_ENCODER_RIGHT_A, RobotMap.DriveMap.DIO_ENCODER_RIGHT_B);

// Invert VictorSPs
leftFront.setInverted(RobotMap.DriveMap.INV_LEFT_FRONT);
leftBack.setInverted(RobotMap.DriveMap.INV_LEFT_BACK);
rightFront.setInverted(RobotMap.DriveMap.INV_RIGHT_FRONT);
rightBack.setInverted(RobotMap.DriveMap.INV_RIGHT_BACK);

// Invert Encoders
// leftEncoder.setReverseDirection(RobotMap.DriveMap.INV_ENCODER_LEFT);
// rightEncoder.setReverseDirection(RobotMap.DriveMap.INV_ENCODER_RIGHT);

// Set distance per pulse
leftEncoder.setDistancePerPulse(RobotMap.DriveMap.DISTANCE_PER_PULSE);
rightEncoder.setDistancePerPulse(RobotMap.DriveMap.DISTANCE_PER_PULSE);

// Instantiate solenoid
solenoid = new DoubleSolenoid(RobotMap.DriveMap.SOL_FORWARD, RobotMap.DriveMap.SOL_REVERSE);

// Instantiate drivesides

leftSide = new DriveSide(leftMotors, leftEncoder);
rightSide = new DriveSide(rightMotors, rightEncoder);
   }
 
开发者ID:Team236,项目名称:2016-Robot-Final,代码行数:43,代码来源:Drive.java


注:本文中的edu.wpi.first.wpilibj.VictorSP.setInverted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。