SimDeviceSim¶
- class wpilib.simulation.SimDeviceSim(*args, **kwargs)¶
Bases:
pybind11_object
Interact with a generic simulated device
Any devices that support simulation but don’t have a dedicated sim object associated with it can be interacted with via this object. You just need to know the name of the associated object.
Here are two ways to find the names of available devices:
The static function
enumerateDevices()
can give you a list of all available devices – note that the device must be created first before this will return any results!When running the WPILib simulation GUI, the names of the ‘Other Devices’ panel are names of devices that you can interact with via this class.
Once you’ve created a simulated device, you can use the
enumerateValues()
method to determine what values you can interact with.Note
WPILib has simulation support for all of its devices. Some vendors may only have limited support for simulation – read the vendor’s documentation or contact them for more information.
Overloaded function.
__init__(self: wpilib.simulation._simulation.SimDeviceSim, name: str) -> None
Constructs a SimDeviceSim.
- Parameters:
name – name of the SimDevice
__init__(self: wpilib.simulation._simulation.SimDeviceSim, name: str, index: int) -> None
Constructs a SimDeviceSim.
- Parameters:
name – name of the SimDevice
index – device index number to append to name
__init__(self: wpilib.simulation._simulation.SimDeviceSim, name: str, index: int, channel: int) -> None
Constructs a SimDeviceSim.
- Parameters:
name – name of the SimDevice
index – device index number to append to name
channel – device channel number to append to name
__init__(self: wpilib.simulation._simulation.SimDeviceSim, handle: int) -> None
Constructs a SimDeviceSim.
- Parameters:
handle – the low level handle for the corresponding SimDevice.
- static enumerateDevices(prefix: str = '') List[str] ¶
Returns a list of available device names
- enumerateValues() List[Tuple[str, bool]] ¶
Returns a list of (name, readonly) tuples of available values for this device
- getBoolean(name: str) hal._wpiHal.SimBoolean ¶
Retrieves an object that allows you to interact with simulated values represented as a boolean.
- getDouble(name: str) hal._wpiHal.SimDouble ¶
Retrieves an object that allows you to interact with simulated values represented as a double.
- getEnum(name: str) hal._wpiHal.SimEnum ¶
Get the property object with the given name.
- Parameters:
name – the property name
- Returns:
the property object
- static getEnumOptions(val: hal._wpiHal.SimEnum) List[str] ¶
Get all options for the given enum.
- Parameters:
val – the enum
- Returns:
names of the different values for that enum
- getInt(name: str) hal._wpiHal.SimInt ¶
Retrieves an object that allows you to interact with simulated values represented as an integer.
- getLong(name: str) hal._wpiHal.SimLong ¶
Retrieves an object that allows you to interact with simulated values represented as a long.
- getName() str ¶
Get the name of this object.
- Returns:
name
- getValue(name: str) hal._wpiHal.SimValue ¶
Provides a readonly mechanism to retrieve all types of device values
- static resetData() None ¶
Reset all SimDevice data.