PWMSim

class wpilib.simulation.PWMSim(*args, **kwargs)

Bases: pybind11_object

Class to control a simulated PWM output.

Overloaded function.

  1. __init__(self: wpilib.simulation._simulation.PWMSim, pwm: wpilib._wpilib.PWM) -> None

Constructs from a PWM object.

Parameters:

pwm – PWM to simulate

  1. __init__(self: wpilib.simulation._simulation.PWMSim, motorctrl: wpilib._wpilib.PWMMotorController) -> None

Constructs from a PWMMotorController object.

Parameters:

motorctrl – PWMMotorController to simulate

  1. __init__(self: wpilib.simulation._simulation.PWMSim, channel: int) -> None

Constructs from a PWM channel number.

Parameters:

channel – Channel number

getInitialized() bool

Check whether the PWM has been initialized.

Returns:

true if initialized

getPeriodScale() int

Get the PWM period scale.

Returns:

the PWM period scale

getPosition() float

Get the PWM position.

Returns:

the PWM position (0.0 to 1.0)

getRawValue() int

Get the PWM raw value.

Returns:

the PWM raw value

getSpeed() float

Get the PWM speed.

Returns:

the PWM speed (-1.0 to 1.0)

getZeroLatch() bool

Check whether the PWM is zero latched.

Returns:

true if zero latched

registerInitializedCallback(callback: Callable[[str, HAL_Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback to be run when the PWM is initialized.

Parameters:
  • callback – the callback

  • initialNotify – whether to run the callback with the initial state

Returns:

the CallbackStore object associated with this callback

registerPeriodScaleCallback(callback: Callable[[str, HAL_Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback to be run when the PWM period scale changes.

Parameters:
  • callback – the callback

  • initialNotify – whether to run the callback with the initial value

Returns:

the CallbackStore object associated with this callback

registerPositionCallback(callback: Callable[[str, HAL_Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback to be run when the PWM position changes.

Parameters:
  • callback – the callback

  • initialNotify – whether to run the callback with the initial value

Returns:

the CallbackStore object associated with this callback

registerRawValueCallback(callback: Callable[[str, HAL_Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback to be run when the PWM raw value changes.

Parameters:
  • callback – the callback

  • initialNotify – whether to run the callback with the initial value

Returns:

the CallbackStore object associated with this callback

registerSpeedCallback(callback: Callable[[str, HAL_Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback to be run when the PWM speed changes.

Parameters:
  • callback – the callback

  • initialNotify – whether to run the callback with the initial value

Returns:

the CallbackStore object associated with this callback

registerZeroLatchCallback(callback: Callable[[str, HAL_Value], None], initialNotify: bool) wpilib.simulation._simulation.CallbackStore

Register a callback to be run when the PWM zero latch state changes.

Parameters:
  • callback – the callback

  • initialNotify – whether to run the callback with the initial state

Returns:

the CallbackStore object associated with this callback

resetData() None

Reset all simulation data.

setInitialized(initialized: bool) None

Define whether the PWM has been initialized.

Parameters:

initialized – whether this object is initialized

setPeriodScale(periodScale: int) None

Set the PWM period scale.

Parameters:

periodScale – the PWM period scale

setPosition(position: float) None

Set the PWM position.

Parameters:

position – the PWM position (0.0 to 1.0)

setRawValue(rawValue: int) None

Set the PWM raw value.

Parameters:

rawValue – the PWM raw value

setSpeed(speed: float) None

Set the PWM speed.

Parameters:

speed – the PWM speed (-1.0 to 1.0)

setZeroLatch(zeroLatch: bool) None

Define whether the PWM has been zero latched.

Parameters:

zeroLatch – true to indicate zero latched