phoenix6.hardware.parent_device#

Module Contents#

Attributes#

phoenix6.hardware.parent_device.DEFAULT_CONTROL_RATE_PERIOD_SEC = 0.01#
class phoenix6.hardware.parent_device.SupportsSendRequest#

Bases: Protocol

Represents any type that can be used to send a control request to a device.

property name: str#
property control_info: dict#
phoenix6.hardware.parent_device.T#
class phoenix6.hardware.parent_device.ParentDevice(device_id: int, model: str, canbus: str)#

Base class of Phoenix devices. This holds the base information for the devices, and can be used as a generic type to hold onto a collection of multiple devices.

property device_id: int#

Gets the ID of this device.

Returns:

ID of this device

Return type:

int

property network: str#

Gets the name of the network this device is on.

Returns:

Name of the network this device is on

Return type:

str

property device_hash: int#

Gets a number unique for this device’s hardware type and ID. This number is not unique across networks.

This can be used to easily reference hardware devices on the same network in collections such as maps.

Returns:

Hash of this device

Return type:

int

property control_request: SupportsSendRequest#

Get the latest applied control.

Returns:

Latest applied control

Return type:

SupportsSendRequest

property has_reset_occurred: bool#

Check if the device has reset since the previous call to this routine

Returns:

True if device has reset

Return type:

bool

get_reset_occurred_checker() Callable[[], bool]#

Get a lambda that checks for device resets.

Returns:

A lambda that checks for device resets

Return type:

Callable[[], bool]

optimize_bus_utilization(optimized_freq_hz: phoenix6.units.hertz = 0.0, timeout_seconds: phoenix6.units.second = 0.05) phoenix6.status_code.StatusCode#

Optimizes the device’s bus utilization by reducing the update frequencies of its status signals.

All status signals that have not been explicitly gven an update frequency using BaseStatusSignal.set_update_frequency will be disabled. Note that if other status signals in the same frame have been given an update frequency, the update frequency will be honored for the entire frame.

This function only needs to be called once on this device in the robot program. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.

To restore the default status update frequencies, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. Alternatively, the user can override individual status update frequencies using BaseStatusSignal.set_update_frequency.

Parameters:
  • optimized_freq_hz (hertz, optional) – The update frequency to apply to the optimized status signals. A frequency of 0 Hz (default) will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz.

  • timeout_seconds (second, optional) – Maximum amount of time to wait for each status frame when performing the action

Returns:

Status code of the first failed update frequency set call, or OK if all succeeded.

Return type:

StatusCode

static optimize_bus_utilization_for_all(*devices: ParentDevice | list[ParentDevice], optimized_freq_hz: phoenix6.units.hertz = 0.0) phoenix6.status_code.StatusCode#

Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.

All status signals that have not been explicitly given an update frequency using BaseStatusSignal.set_update_frequency will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.

This function only needs to be called once in the robot program for the provided devices. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.

To restore the default status update frequencies, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. Alternatively, the user can override individual status update frequencies using BaseStatusSignal.set_update_frequency.

This will wait up to 0.050 seconds (50ms) for each status frame.

Parameters:
  • devices (tuple[ParentDevice | list[ParentDevice], ...]) – Devices for which to optimize bus utilization.

  • optimized_freq_hz (hertz, optional) – The update frequency to apply to the optimized status signals. A frequency of 0 Hz (default) will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz. This must be specified using a named parameter at the end of the parameter list.

Returns:

Status code of the first failed optimize call, or OK if all succeeded

Return type:

StatusCode