本文整理匯總了Java中com.ctre.phoenix.motorcontrol.can.TalonSRX類的典型用法代碼示例。如果您正苦於以下問題:Java TalonSRX類的具體用法?Java TalonSRX怎麽用?Java TalonSRX使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TalonSRX類屬於com.ctre.phoenix.motorcontrol.can包,在下文中一共展示了TalonSRX類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Chassis
import com.ctre.phoenix.motorcontrol.can.TalonSRX; //導入依賴的package包/類
public Chassis() {
leftMasterMotor = new TalonSRX(RobotMap.LEFT_MASTER_MOTOR);
leftSlaveMotor = new TalonSRX(RobotMap.LEFT_SLAVE_MOTOR);
rightMasterMotor = new TalonSRX(RobotMap.RIGHT_MASTER_MOTOR);
rightSlaveMotor = new TalonSRX(RobotMap.RIGHT_SLAVE_MOTOR);
//Setup Master Motor
this.leftMasterMotor.setNeutralMode(NeutralMode.Brake);
this.leftMasterMotor.setSensorPhase(false);
this.leftMasterMotor.setInverted(true);
this.leftMasterMotor.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 1, kTimeoutMs);
this.leftMasterMotor.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder, kSlotIdx, kTimeoutMs);
this.rightMasterMotor.setNeutralMode(NeutralMode.Brake);
this.rightMasterMotor.setSensorPhase(false);
this.rightMasterMotor.setInverted(true);
this.rightMasterMotor.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 1, kTimeoutMs);
this.rightMasterMotor.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder, kSlotIdx, kTimeoutMs);
//Tell the motor its starting position
int absoluteLeftPosition = leftMasterMotor.getSelectedSensorPosition(kTimeoutMs) & 0xFFF;
leftMasterMotor.setSelectedSensorPosition(absoluteLeftPosition, kPIDLoopIdx, kTimeoutMs);
int absoluteRightPosition = rightMasterMotor.getSelectedSensorPosition(kTimeoutMs) & 0xFFF;
rightMasterMotor.setSelectedSensorPosition(absoluteRightPosition, kPIDLoopIdx, kTimeoutMs);
//Set motor limits for master motor
leftMasterMotor.configNominalOutputForward(0, kTimeoutMs);
leftMasterMotor.configNominalOutputReverse(0, kTimeoutMs);
leftMasterMotor.configPeakOutputForward(1, kTimeoutMs);
leftMasterMotor.configPeakOutputReverse(-1, kTimeoutMs);
rightMasterMotor.configNominalOutputForward(0, kTimeoutMs);
rightMasterMotor.configNominalOutputReverse(0, kTimeoutMs);
rightMasterMotor.configPeakOutputForward(1, kTimeoutMs);
rightMasterMotor.configPeakOutputReverse(-1, kTimeoutMs);
//Configure closed pid loop
leftMasterMotor.configAllowableClosedloopError(0, kPIDLoopIdx, kTimeoutMs);
leftMasterMotor.config_kP(kPIDLoopIdx, pidP, kTimeoutMs);
leftMasterMotor.config_kI(kPIDLoopIdx, pidI, kTimeoutMs);
leftMasterMotor.config_kD(kPIDLoopIdx, pidD, kTimeoutMs);
leftMasterMotor.config_kF(kPIDLoopIdx, pidF, kTimeoutMs);
leftMasterMotor.selectProfileSlot(0, 0);
rightMasterMotor.configAllowableClosedloopError(0, kPIDLoopIdx, kTimeoutMs);
rightMasterMotor.config_kP(kPIDLoopIdx, pidP, kTimeoutMs);
rightMasterMotor.config_kI(kPIDLoopIdx, pidI, kTimeoutMs);
rightMasterMotor.config_kD(kPIDLoopIdx, pidD, kTimeoutMs);
rightMasterMotor.config_kF(kPIDLoopIdx, pidF, kTimeoutMs);
rightMasterMotor.selectProfileSlot(0, 0);
//Setup Slave Motor
leftSlaveMotor.setNeutralMode(NeutralMode.Brake);
leftSlaveMotor.follow(leftMasterMotor);
leftSlaveMotor.configClosedloopRamp(0.5, 0);
leftSlaveMotor.setInverted(true);
rightSlaveMotor.setNeutralMode(NeutralMode.Brake);
rightSlaveMotor.follow(rightMasterMotor);
rightSlaveMotor.configClosedloopRamp(0.5, 0);
}
示例2: getLeftMotor
import com.ctre.phoenix.motorcontrol.can.TalonSRX; //導入依賴的package包/類
public TalonSRX getLeftMotor(){
return this.leftMasterMotor;
}
示例3: getRightMotor
import com.ctre.phoenix.motorcontrol.can.TalonSRX; //導入依賴的package包/類
public TalonSRX getRightMotor(){
return this.rightMasterMotor;
}