EncoderSim

class wpilib.simulation.EncoderSim(encoder: wpilib.Encoder)

Bases: pybind11_builtins.pybind11_object

Class to control a simulated encoder.

Constructs from an Encoder object.

Parameters

encoder – Encoder to simulate

static createForChannel(channel: int)wpilib.simulation.EncoderSim

Creates an EncoderSim for a digital input channel. Encoders take two channels, so either one may be specified.

Parameters

channel – digital input channel

Returns

Simulated object @throws NoSuchElementException if no Encoder is configured for that channel

static createForIndex(index: int)wpilib.simulation.EncoderSim

Creates an EncoderSim for a simulated index. The index is incremented for each simulated Encoder.

Parameters

index – simulator index

Returns

Simulated object

getCount()int

Read the count of the encoder.

Returns

the count

getDirection()bool

Get the direction of the encoder.

Returns

the direction of the encoder

getDistance()float

Read the distance of the encoder.

Returns

the encoder distance

getDistancePerPulse()float

Read the distance per pulse of the encoder.

Returns

the encoder distance per pulse

getInitialized()bool

Read the Initialized value of the encoder.

Returns

true if initialized

getMaxPeriod()float

Get the max period of the encoder.

Returns

the max period of the encoder

getPeriod()float

Read the period of the encoder.

Returns

the encoder period

getRate()float

Get the rate of the encoder.

Returns

the rate of change

getReset()bool

Check if the encoder has been reset.

Returns

true if reset

getReverseDirection()bool

Get the reverse direction of the encoder.

Returns

the reverse direction of the encoder

getSamplesToAverage()int

Get the samples-to-average value.

Returns

the samples-to-average value

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

Register a callback on the count property of the encoder.

Parameters
  • callback – the callback that will be called whenever the count property is changed

  • initialNotify – if true, the callback will be run on the initial value

Returns

the CallbackStore object associated with this callback

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

Register a callback on the direction of the encoder.

Parameters
  • callback – the callback that will be called whenever the direction is changed

  • initialNotify – if true, the callback will be run on the initial value

Returns

the CallbackStore object associated with this callback

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

Register a callback on the distance per pulse value of this encoder.

Parameters
  • callback – the callback that will be called whenever the distance per pulse is changed

  • initialNotify – if true, the callback will be run on the initial value

Returns

the CallbackStore object associated with this callback

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

Register a callback on the Initialized property of the encoder.

Parameters
  • callback – the callback that will be called whenever the Initialized property is changed

  • initialNotify – if true, the callback will be run on the initial value

Returns

the CallbackStore object associated with this callback

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

Register a callback to be run whenever the max period of the encoder is changed.

Parameters
  • callback – the callback

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

Returns

the CallbackStore object associated with this callback

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

Register a callback on the period of the encoder.

Parameters
  • callback – the callback that will be called whenever the period is changed

  • initialNotify – if true, the callback will be run on the initial value

Returns

the CallbackStore object associated with this callback

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

Register a callback to be called whenever the encoder is reset.

Parameters
  • callback – the callback

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

Returns

the CallbackStore object associated with this callback

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

Register a callback on the reverse direction.

Parameters
  • callback – the callback that will be called whenever the reverse direction is changed

  • initialNotify – if true, the callback will be run on the initial value

Returns

the CallbackStore object associated with this callback

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

Register a callback on the samples-to-average value of this encoder.

Parameters
  • callback – the callback that will be called whenever the samples-to-average is changed

  • initialNotify – if true, the callback will be run on the initial value

Returns

the CallbackStore object associated with this callback

resetData()None

Resets all simulation data for this encoder.

setCount(count: int)None

Change the count of the encoder.

Parameters

count – the new count

setDirection(direction: bool)None

Set the direction of the encoder.

Parameters

direction – the new direction

setDistance(distance: float)None

Change the encoder distance.

Parameters

distance – the new distance

setDistancePerPulse(distancePerPulse: float)None

Change the encoder distance per pulse.

Parameters

distancePerPulse – the new distance per pulse

setInitialized(initialized: bool)None

Change the Initialized value of the encoder.

Parameters

initialized – the new value

setMaxPeriod(maxPeriod: float)None

Change the max period of the encoder.

Parameters

maxPeriod – the new value

setPeriod(period: float)None

Change the encoder period.

Parameters

period – the new period

setRate(rate: float)None

Change the rate of the encoder.

Parameters

rate – the new rate

setReset(reset: bool)None

Change the reset property of the encoder.

Parameters

reset – the new value

setReverseDirection(reverseDirection: bool)None

Set the reverse direction.

Parameters

reverseDirection – the new value

setSamplesToAverage(samplesToAverage: int)None

Set the samples-to-average value.

Parameters

samplesToAverage – the new value