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