Class WsTalon
java.lang.Object
org.wildstang.framework.io.outputs.Output
org.wildstang.framework.io.outputs.AnalogOutput
org.wildstang.hardware.roborio.outputs.WsMotorController
org.wildstang.hardware.roborio.outputs.WsTalon
Controls a Talon or Victor motor controller as a Phoenix BaseMotorController.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClosedLoop(double P, double I, double D) voidaddFollower(int canConstant, String CANBUS, boolean oppose) Add a follower motor to the current motor.doubleReturns the current motor output percent.doubleReturns the quadrature position from a Talon's encoder.doubleReturn the motor controller or motor temperaturedoubleReturns the quadrature velocity from a Talon's encoder.voidinitClosedLoop(double P, double I, double D) Sets up closed loop control for the motorvoidDoes nothing, config values only affects start state.voidSets motor speed to current value, from -1.0 to 1.0.voidsetBrake()Sets the motor to brake mode, will not freely spin.voidsetCoast()Sets the motor to coast mode, will freely spin.voidsetCurrentLimit(int statorLimit) voidsetCurrentLimit(int statorLimit, int supplyLimit) Sets the current limit of the motor controller.voidsetPosition(double target) Sets the motor to track the given positionvoidsetPosition(double target, int slotID) Sets the motor to track the given position with a specific PIDFF constantsvoidsetSpeed(double value) Wraps setValue().Methods inherited from class org.wildstang.hardware.roborio.outputs.WsMotorController
stopMethods inherited from class org.wildstang.framework.io.outputs.AnalogOutput
getValue, setValue
-
Constructor Details
-
WsTalon
Constructs the motor controller from config.- Parameters:
name- Descriptive name of the controller.channel- Motor controller CAN constant.p_default- Default output value.
-
-
Method Details
-
addFollower
Add a follower motor to the current motor.- Parameters:
canConstant- CAN constant of the new follower motor.CANBUS- Attached CAN bus name.oppose- True if the follow should oppose the direction of this motor.
-
setBrake
public void setBrake()Sets the motor to brake mode, will not freely spin.- Specified by:
setBrakein classWsMotorController
-
setCoast
public void setCoast()Sets the motor to coast mode, will freely spin.- Specified by:
setCoastin classWsMotorController
-
setCurrentLimit
public void setCurrentLimit(int statorLimit, int supplyLimit) Sets the current limit of the motor controller.- Parameters:
statorLimit- the stator limit to applysupplyLimit- the supply limit to apply
-
setCurrentLimit
public void setCurrentLimit(int statorLimit) -
getVelocity
public double getVelocity()Returns the quadrature velocity from a Talon's encoder.- Specified by:
getVelocityin classWsMotorController- Returns:
- Current velocity, 0 if not a Talon.
-
getPosition
public double getPosition()Returns the quadrature position from a Talon's encoder.- Specified by:
getPositionin classWsMotorController- Returns:
- Current position, 0 if not a Talon.
-
getOutput
public double getOutput()Description copied from class:WsMotorControllerReturns the current motor output percent.- Specified by:
getOutputin classWsMotorController- Returns:
- Current motor output as a percent.
-
getTemperature
public double getTemperature()Description copied from class:WsMotorControllerReturn the motor controller or motor temperature- Specified by:
getTemperaturein classWsMotorController- Returns:
- Current temperature.
-
sendDataToOutput
public void sendDataToOutput()Sets motor speed to current value, from -1.0 to 1.0.- Specified by:
sendDataToOutputin classWsMotorController
-
setSpeed
public void setSpeed(double value) Description copied from class:WsMotorControllerWraps setValue().- Overrides:
setSpeedin classWsMotorController- Parameters:
value- New motor percent speed, from -1.0 to 1.0.
-
initClosedLoop
public void initClosedLoop(double P, double I, double D) Sets up closed loop control for the motor- Parameters:
P- the P valueI- the I valueD- the D value
-
addClosedLoop
public void addClosedLoop(double P, double I, double D) -
setPosition
public void setPosition(double target) Sets the motor to track the given position- Parameters:
target- the encoder target value to track to
-
setPosition
public void setPosition(double target, int slotID) Sets the motor to track the given position with a specific PIDFF constants- Parameters:
target- the encoder target to track toslotID- the ID slot of the sparkmax to use
-
notifyConfigChange
public void notifyConfigChange()Does nothing, config values only affects start state.
-