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


Java TalonSRX类代码示例

本文整理汇总了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);
			
}
 
开发者ID:2141-Spartonics,项目名称:Spartonics-Code,代码行数:66,代码来源:Chassis.java

示例2: getLeftMotor

import com.ctre.phoenix.motorcontrol.can.TalonSRX; //导入依赖的package包/类
public TalonSRX getLeftMotor(){
	return this.leftMasterMotor;
}
 
开发者ID:2141-Spartonics,项目名称:Spartonics-Code,代码行数:4,代码来源:Chassis.java

示例3: getRightMotor

import com.ctre.phoenix.motorcontrol.can.TalonSRX; //导入依赖的package包/类
public TalonSRX getRightMotor(){
	return this.rightMasterMotor;
}
 
开发者ID:2141-Spartonics,项目名称:Spartonics-Code,代码行数:4,代码来源:Chassis.java


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