本文整理汇总了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();
}
示例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);
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}