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


Java CANTalon类代码示例

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


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

示例1: initialize

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
protected void initialize() {
    setTimeout(5);
    Robot.intakeLauncher.aimMotor.disableControl();
    Robot.intakeLauncher.aimMotor.changeControlMode(CANTalon.TalonControlMode.Position);
    Robot.intakeLauncher.aimMotor.setPID(0.1, 0.01, 1);
 //   Robot.intakeLauncher.aimMotor.config
    System.out.println("Launcher go to " + myPosition + " command");
    switch (myPosition) {
        case ANGLE: 
            Robot.intakeLauncher.launcherJumpToAngle(myDegrees); //Known to be nonfunctional 
            break;
        case NEUTRAL:
            Robot.intakeLauncher.launcherSetNeutralPosition();
            break;
        case TRAVEL:
            Robot.intakeLauncher.launcherSetTravelPosition();
            break;
        case INTAKE:
            Robot.intakeLauncher.launcherSetIntakeHeightPosition();
            break;
        default:
            break;
    }
    Robot.intakeLauncher.aimMotor.enableControl();
    Robot.intakeLauncher.moveToSetPoint();
}
 
开发者ID:Spartronics4915,项目名称:2016-Stronghold,代码行数:27,代码来源:LauncherGoToPositionCommand.java

示例2: Harvester

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
public Harvester() {		
	
	//TODO: sync left/right motors
	tiltRight = new CANTalon(RobotMap.HARVESTER_AIMING_RIGHT);
	tiltLeft = new CANTalon(RobotMap.HARVESTER_AIMING_LEFT);
	
	//tiltLeft.setVoltageRampRate(5); // this might be a good way to solve our ramp rate issue IE smooth out the jerkiness
	//tiltRight.setVoltageRampRate(5); // this might be a good way to solve our ramp rate issue IE smooth out the jerkiness
	
	limitLeft = new DigitalInput(RobotMap.HARVESTER_LEFT_BUMP_BOTTOM);
	limitRight = new DigitalInput(RobotMap.HARVESTER_RIGHT_BUMP_BOTTOM);
	limitLeftTop = new DigitalInput(RobotMap.HARVESTER_LEFT_BUMP_TOP);
	limitRightTop = new DigitalInput(RobotMap.HARVESTER_RIGHT_BUMP_TOP);
	
	leftPot = new ZeroablePotentiometer(RobotMap.LEFT_AIM_POT, 250);
	rightPot = new ZeroablePotentiometer(RobotMap.RIGHT_AIM_POT, 250);
	leftPot.setInverted(true);
}
 
开发者ID:CraftSpider,项目名称:Stronghold2016-340,代码行数:19,代码来源:Harvester.java

示例3: initialize

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
public static void initialize()
{
	if (!initialized) {
        mFrontLeft = new CANTalon(LEFT_FRONT_TALON_ID);
        mBackLeft = new CANTalon(LEFT_REAR_TALON_ID);
        mFrontRight = new CANTalon(RIGHT_FRONT_TALON_ID);
        mBackRight = new CANTalon(RIGHT_REAR_TALON_ID);
        	        
        drive = new RobotDrive(mFrontLeft, mBackLeft, mFrontRight, mBackRight);
        	        
        drive.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, false);
        drive.setInvertedMotor(RobotDrive.MotorType.kFrontRight, false);
        drive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, false);
        drive.setInvertedMotor(RobotDrive.MotorType.kRearRight, false);   
        
        leftStick = new Joystick(LEFT_JOYSTICK_ID);
        rightStick = new Joystick(RIGHT_JOYSTICK_ID);
        
        initialized = true;
	}
}
 
开发者ID:MTHSRoboticsClub,项目名称:FRC-2017,代码行数:22,代码来源:CANDriveAssembly.java

示例4: DriveTrainSubsystem

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
public DriveTrainSubsystem()
{
    lastLeft = 0.0D;
    lastRight = 0.0D;

    leftTalon0 = new CANTalon(RobotMap.Motor.LEFT_TALON_0);
    leftTalon1 = new CANTalon(RobotMap.Motor.LEFT_TALON_1);
    rightTalon0 = new CANTalon(RobotMap.Motor.RIGHT_TALON_0);
    rightTalon1 = new CANTalon(RobotMap.Motor.RIGHT_TALON_1);

    drive = new RobotDrive(leftTalon0, leftTalon1, rightTalon0, rightTalon1);
    drive.setExpiration(0.1D);

    setTalonSettings(leftTalon0);
    setTalonSettings(leftTalon1);
    setTalonSettings(rightTalon0);
    setTalonSettings(rightTalon1);
}
 
开发者ID:Team-2502,项目名称:RobotCode2017,代码行数:19,代码来源:DriveTrainSubsystem.java

示例5: DrivetrainPID

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
public DrivetrainPID() {
  	super(RobotMap.DRIVE_TURN_P, RobotMap.DRIVE_TURN_I, RobotMap.DRIVE_TURN_D);
  	frontLeft = new CANTalon(RobotMap.FRONT_LEFT_MOTOR);
frontRight = new CANTalon(RobotMap.FRONT_RIGHT_MOTOR);
rearLeft = new CANTalon(RobotMap.REAR_LEFT_MOTOR);
rearRight = new CANTalon(RobotMap.REAR_RIGHT_MOTOR);

frontLeft.enableControl();
frontRight.enableControl();
rearLeft.enableControl();
rearRight.enableControl();

oneDrive = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight);
SmartDashboard.putNumber("Front right", 0);
SmartDashboard.putNumber("Front left", 0);
  }
 
开发者ID:SouthEugeneRoboticsTeam,项目名称:Stronghold-2016,代码行数:17,代码来源:DrivetrainPID.java

示例6: initialize

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
/**
 * This initializes the variables for the distance calculator.
 */
protected void initialize() {
    desiredTicksValue = new ArrayList<Double>();

    double ticksToMove = inputDistance * 12 * 1000 / (6 * Math.PI);

    System.out.println("Input distance: " + inputDistance + " ft, ticks to move: " + ticksToMove);
    System.out.println("*************READY TO DRIVE**************");
    for (int i = 0; i < motors.size(); i++) {
        CANTalon motor = motors.get(i);

        double startingTickValue = motor.getPosition();
        double endValue = startingTickValue + ticksToMove;
        if (i == 1 || i == 3) {
            // right motors are inverted and we are reversing the back motors
            endValue = startingTickValue - ticksToMove;
        }

        System.out.println("Motor " + i + ": starting position " + startingTickValue + ", desired position " + endValue);
        desiredTicksValue.add(endValue);
    }
}
 
开发者ID:Spartronics4915,项目名称:2015-Recycle-Rush,代码行数:25,代码来源:StrafeCommand.java

示例7: initialize

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
/**
 * This initializes the variables for the distance calculator.
 */
protected void initialize() {
    desiredTicksValue = new ArrayList<Double>();

    double ticksToMove = inputDistance * 12 * 1000 / (6 * Math.PI);

    Robot.debugger.logError(CustomDebugger.LoggerNames.DRIVETRAIN, "Input distance: " + inputDistance + " ft, ticks to move: " + ticksToMove);

    for (int i = 0; i < motors.size(); i++) {
        CANTalon motor = motors.get(i);

        double startingTickValue = motor.getPosition();
        double endValue = startingTickValue + ticksToMove;
        if (i >= 2) {
            // right motors are inverted
            endValue = startingTickValue - ticksToMove;
        }
        System.out.println("!!!!!!!!!" + inputSpeed + "!!!!!!!!!!!");
        Robot.debugger.logError(CustomDebugger.LoggerNames.DRIVETRAIN, "Motor " + i + ": starting position " + startingTickValue + ", desired position " + endValue);

        desiredTicksValue.add(endValue);
    }
}
 
开发者ID:Spartronics4915,项目名称:2015-Recycle-Rush,代码行数:26,代码来源:MoveStraightPositionModeCommand.java

示例8: moveToLevel

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
/**
 * @param newLevel The level amt to move up/down
 * @return The amount of meters high that level is.
 */
public static double moveToLevel(int newLevel)
{
	if (RobotMap.forkliftMotor.getControlMode() != CANTalon.ControlMode.Position)
		return (RobotMap.forkliftMotor.getPosition());
	
	if(newLevel >= metersToLevel.length)
		newLevel = metersToLevel.length - 1;
	else if(newLevel < 0)
		newLevel = 0;
	
	double target = metersToLevel[newLevel] * pulsePerMeter;
	
	moveToPosition(target);
	
	return (target);
}
 
开发者ID:FRC2832,项目名称:Robot_2015,代码行数:21,代码来源:LiftControl.java

示例9: moveToPosition

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
/**
 * Moves the lift up or down.
 * @param pos The position to move to, in encoder ticks. Bottom is 0, top is (TODO: Find Top).
 */
public static void moveToPosition(double pos) {
	
	if (RobotMap.forkliftMotor.getControlMode() != CANTalon.ControlMode.Position)
		return;
	
	// Make sure not above the top stop
	if(pos > maxValue) 
   		pos = maxValue;
	
	// Make sure not below the bottom stop
	if(pos < 0) 
   		pos = 0;
	
	RobotMap.forkliftMotor.enableControl();
	RobotMap.forkliftMotor.set(pos);
}
 
开发者ID:FRC2832,项目名称:Robot_2015,代码行数:21,代码来源:LiftControl.java

示例10: CANTalonEncoderWheelController

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
/**
 * Creates a {@link CANTalonEncoderWheelController} that uses the specified
 * PID constants, max speed and distance per encoder pulse. It also takes a
 * list of motors that form this wheel controller. The first Talon SRX
 * serves as the master and it does the PID calculation, while the rest
 * follow its output. This means that the encoder should be attached to the
 * first Talon in the list.
 * 
 * @param speedPIDConstants the constants for the speed PID controller
 * @param maxSpeed the maximum speed the wheel can turn
 * @param encoderDistancePerPulse the distance the wheel moves per encoder
 *            pulse
 * @param pdpPorts the PDP ports the motors are connected to
 * @param motors the list of motors that make up this wheel controller
 */
public CANTalonEncoderWheelController(PIDConstants speedPIDConstants,
        double maxSpeed, double encoderDistancePerPulse, int[] pdpPorts, CANTalon... motors) {
    super(pdpPorts, motors);

    this.maxSpeed = maxSpeed;
    this.encoderDistancePerPulse = encoderDistancePerPulse;

    // Master controller does all the controlling while the others are
    // slaves.
    masterMotor = motors[0];
    // Set all other motors as slaves
    for (int i = 1; i < motors.length; i++) {
        motors[i].changeControlMode(CANTalon.ControlMode.Follower);
        // Setup the motors to follow the master
        motors[i].set(motors[0].getDeviceID());
    }

    masterMotor.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);

    // Speed profile (using 0 ramp value to disable ramping)
    masterMotor.setPID(speedPIDConstants.p, speedPIDConstants.i, speedPIDConstants.d,
            speedPIDConstants.f, 0, 0, 0);
}
 
开发者ID:RobotsByTheC,项目名称:CMonster2015,代码行数:39,代码来源:CANTalonEncoderWheelController.java

示例11: initialize

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
public static void initialize(){
	climbingWinch = new CANTalon(8); //this value is guessed as of 3/21
	release = new Servo(2); //this value is guessed as of 3/21
	motorLatch = new Servo(3); //this value is guessed as of 3/21
	climbingWinch.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
	climbingWinch.enableBrakeMode(true);
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:8,代码来源:Climber.java

示例12: upSpeedMode

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
public static void upSpeedMode()
{
	RobotMap.winchMotor.changeControlMode(CANTalon.TalonControlMode.Speed);
	loadPreferences();
	RobotMap.winchMotor.setPID(UP_PID_P, UP_PID_I, UP_PID_D);
	RobotMap.winchMotor.setAllowableClosedLoopErr(0);
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:8,代码来源:Aimer.java

示例13: downSpeedMode

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
public static void downSpeedMode()
{
	RobotMap.winchMotor.changeControlMode(CANTalon.TalonControlMode.Speed);
	loadPreferences();
	RobotMap.winchMotor.setPID(DOWN_PID_P, DOWN_PID_I, DOWN_PID_D);
	RobotMap.winchMotor.setAllowableClosedLoopErr(0);
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:8,代码来源:Aimer.java

示例14: reset

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
public void reset() {
	for (int i = 0; i < motors.length; i++) {
		if (motors[i] == null) {
			continue;
		}
		if (motors[i] instanceof CANTalon) {
			((CANTalon) motors[i]).delete();
		} else if (motors[i] instanceof Victor) {
			((Victor) motors[i]).free();
		}
	}
	motors = new SpeedController[64];
	
	for (int i = 0; i < solenoids.length; i++) {
		if (solenoids[i] == null) {
			continue;
		}
		solenoids[i].free();
	}
	solenoids = new Solenoid[64];

	for (int i = 0; i < relays.length; i++) {
		if (relays[i] == null) {
			continue;
		}
		relays[i].free();
	}
	relays = new Relay[64];

	for (int i = 0; i < analogInputs.length; i++) {
		if (analogInputs[i] == null) {
			continue;
		}
		analogInputs[i].free();
	}
	analogInputs = new AnalogInput[64];
	
	if (compressor != null)
	compressor.free();
}
 
开发者ID:Wazzaps,项目名称:PCRobotClient,代码行数:41,代码来源:Robot.java

示例15: initialize

import edu.wpi.first.wpilibj.CANTalon; //导入依赖的package包/类
protected void initialize() {
    if (!m_isRunning){
        m_initialHeading = Robot.driveTrain.getCurrentHeading(); 
        m_isRunning = true;
    }
    RobotMap.leftMasterMotor.changeControlMode(CANTalon.TalonControlMode.Speed);
    RobotMap.rightMasterMotor.changeControlMode(CANTalon.TalonControlMode.Speed);
    System.out.println("DriveStraightCommand:init");
    Robot.driveTrain.init();
}
 
开发者ID:Spartronics4915,项目名称:2016-Stronghold,代码行数:11,代码来源:DriveStraightCommand.java


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