WPI_BaseMotorController
- class phoenix5.WPI_BaseMotorController(deviceNumber: int, model: str)
Bases:
BaseMotorController
,MotorController
,MotorSafety
,Sendable
VEX Victor SPX Motor Controller when used on CAN Bus.
Constructor for a WPI_BaseMotorController
- Parameters:
deviceNumber – Device ID of BaseMotorController
- disable() None
Common interface for disabling a motor.
- get() float
Common interface for getting the current set speed of a speed controller.
- Returns:
The current set speed. Value is between -1.0 and 1.0.
- getDescription() str
- Returns:
description of controller
- getInverted() bool
Common interface for returning the inversion state of a speed controller.
- Returns:
isInverted The state of inversion, true is inverted.
- set(*args, **kwargs)
Overloaded function.
set(self: phoenix5._ctre.WPI_BaseMotorController, speed: float) -> None
Common interface for setting the speed of a simple speed controller.
- Parameters:
speed – The speed to set. Value should be between -1.0 and 1.0. Value is also saved for Get().
set(self: phoenix5._ctre.WPI_BaseMotorController, mode: phoenix5._ctre.ControlMode, value: float) -> None
Sets the appropriate output on the talon, depending on the mode.
Standard Driving Example:
_talonLeft.set(ControlMode.PercentOutput, leftJoy);
_talonRght.set(ControlMode.PercentOutput, rghtJoy);
- Parameters:
mode – The output mode to apply. In PercentOutput, the output is between -1.0 and 1.0, with 0.0 as stopped. In Current mode, output value is in amperes. In Velocity mode, output value is in position change / 100ms. In Position mode, output value is in encoder ticks or an analog value, depending on the sensor. In Follower mode, the output value is the integer device ID of the talon to duplicate.
value – The setpoint value, as described above.
set(self: phoenix5._ctre.WPI_BaseMotorController, mode: phoenix5._ctre.ControlMode, demand0: float, demand1Type: phoenix5._ctre.DemandType, demand1: float) -> None
Arcade Drive Example: * _talonLeft.set(ControlMode.PercentOutput, joyForward, DemandType.ArbitraryFeedForward, +joyTurn); * _talonRght.set(ControlMode.PercentOutput, joyForward, DemandType.ArbitraryFeedForward, -joyTurn);
Drive Straight Example:
Note: Selected Sensor Configuration is necessary for both PID0 and PID1.
_talonLeft.follow(_talonRght, FollwerType.AuxOutput1);
_talonRght.set(ControlMode.PercentOutput, joyForward, DemandType.AuxPID, desiredRobotHeading);
Drive Straight to a Distance Example:
Note: Other configurations (sensor selection, PID gains, etc.) need to be set.
_talonLeft.follow(_talonRght, FollwerType.AuxOutput1);
_talonRght.set(ControlMode.MotionMagic, targetDistance, DemandType.AuxPID, desiredRobotHeading);
- Parameters:
mode – Sets the appropriate output on the talon, depending on the mode.
demand0 – The output value to apply. such as advanced feed forward and/or auxiliary close-looping in firmware. In PercentOutput, the output is between -1.0 and 1.0, with 0.0 as stopped. In Current mode, output value is in amperes. In Velocity mode, output value is in position change / 100ms. In Position mode, output value is in encoder ticks or an analog value, depending on the sensor. See In Follower mode, the output value is the integer device ID of the talon to duplicate.
demand1Type – The demand type for demand1. Neutral: Ignore demand1 and apply no change to the demand0 output. AuxPID: Use demand1 to set the target for the auxiliary PID 1. ArbitraryFeedForward: Use demand1 as an arbitrary additive value to the * demand0 output. In PercentOutput the demand0 output is the motor output, and in closed-loop modes the demand0 output is the output of PID0.
demand1 – Supplmental output value. Units match the set mode.
- setInverted(*args, **kwargs)
Overloaded function.
setInverted(self: phoenix5._ctre.WPI_BaseMotorController, isInverted: bool) -> None
Common interface for inverting direction of a speed controller.
- Parameters:
isInverted – The state of inversion, true is inverted.
setInverted(self: phoenix5._ctre.WPI_BaseMotorController, invertType: phoenix5._ctre.InvertType) -> None
Common interface for inverting direction of a speed controller.
- Parameters:
invertType – The invert strategy to use. Follower controllers that mirror/oppose the master controller should * use this method.
- setVoltage(output: wpimath.units.volts) None
Sets the voltage output of the SpeedController. Compensates for the current bus voltage to ensure that the desired voltage is output even if the battery voltage is below 12V - highly useful when the voltage outputs are “meaningful” (e.g. they come from a feedforward calculation).
NOTE: This function must be called regularly in order for voltage compensation to work properly - unlike the ordinary set function, it is not “set it and forget it.”
- Parameters:
output – The voltage to output.
- stopMotor() None
Common interface to stop the motor until Set is called again.