VictorSPX
- class phoenix5.VictorSPX(*args, **kwargs)
Bases:
BaseMotorController
,IMotorController
VEX Victor SPX Motor Controller when used on CAN Bus.
{@code // Example usage of a VictorSPX motor controller VictorSPX motor{0}; // creates a new VictorSPX with ID 0 motor.Set(VictorSPXControlMode::PercentOutput, 0.5); // runs the motor at 50% power std::cout << motor.GetMotorOutputPercent() << std::endl; // prints the percent output of the motor (0.5) std::cout << motor.GetBusVoltage() << std::endl; // prints the bus voltage seen by the motor controller ErrorCode error = motor.GetLastError(); // gets the last error generated by the motor controller Faults faults; ErrorCode faultsError = motor.GetFaults(faults); // fills faults with the current motor controller faults; returns the last error generated }
See also
Overloaded function.
__init__(self: phoenix5._ctre.VictorSPX, deviceNumber: int) -> None
Constructor
- Parameters:
deviceNumber – [0,62]
__init__(self: phoenix5._ctre.VictorSPX, deviceNumber: int, canbus: str) -> None
Constructor so non-FRC platforms can specify a CAN 2.0 socketcan bus
- Parameters:
deviceNumber – CAN Device ID of VictorSPX
canbus – String specifying the bus
- configAllSettings(allConfigs: phoenix5._ctre.VictorSPXConfiguration, timeoutMs: int = 50) phoenix5._ctre.ErrorCode
Configures all persistent settings.
- Parameters:
allConfigs – Object with all of the persistant settings
timeoutMs – Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
- Returns:
Error Code generated by function. 0 indicates no error.
- getAllConfigs(allConfigs: phoenix5._ctre.VictorSPXConfiguration, timeoutMs: int = 50) None
Gets all persistant settings.
- Parameters:
allConfigs – Object with all of the persistant settings
timeoutMs – Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
- getPIDConfigs(pid: phoenix5._ctre.VictorSPXPIDSetConfiguration, pidIdx: int = 0, timeoutMs: int = 50) None
Gets all PID set persistant settings.
- Parameters:
pid – Object with all of the PID set persistant settings
pidIdx – 0 for Primary closed-loop. 1 for auxiliary closed-loop.
timeoutMs – Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
- getSimCollection() phoenix5._ctre.VictorSPXSimCollection
- Returns:
object that can set simulation inputs.
- set(*args, **kwargs)
Overloaded function.
set(self: phoenix5._ctre.VictorSPX, mode: phoenix5._ctre.VictorSPXControlMode, value: float) -> None
Sets the appropriate output on the motor controller, depending on the mode.
Standard Driving Example:
victorLeft.set(ControlMode.PercentOutput, leftJoy);
victorRght.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 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 motor controller to duplicate.
value – The setpoint value, as described above.
set(self: phoenix5._ctre.VictorSPX, mode: phoenix5._ctre.VictorSPXControlMode, demand0: float, demand1Type: phoenix5._ctre.DemandType, demand1: float) -> None
Arcade Drive Example: * _victorLeft.set(ControlMode.PercentOutput, joyForward, DemandType.ArbitraryFeedForward, +joyTurn); * _victorRght.set(ControlMode.PercentOutput, joyForward, DemandType.ArbitraryFeedForward, -joyTurn);
Drive Straight Example:
Note: Selected Sensor Configuration is necessary for both PID0 and PID1.
_victorLeft.follow(_victorRght, FollwerType.AuxOutput1);
_victorRght.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.
_victorLeft.follow(_victorRght, FollwerType.AuxOutput1);
_victorRght.set(ControlMode.MotionMagic, targetDistance, DemandType.AuxPID, desiredRobotHeading);
- Parameters:
mode – Sets the appropriate output on the motor controller, 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 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 motor controller 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. Auxiliary PID is always executed as standard Position PID control. 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. AuxPID: Target position in Sensor Units ArbitraryFeedForward: Percent Output between -1.0 and 1.0
set(self: phoenix5._ctre.VictorSPX, mode: phoenix5._ctre.ControlMode, value: float) -> None
set(self: phoenix5._ctre.VictorSPX, mode: phoenix5._ctre.ControlMode, demand0: float, demand1Type: phoenix5._ctre.DemandType, demand1: float) -> None