PDO

class ingeniamotion.pdo.PDOPoller(mc, servo, refresh_time, watchdog_timeout, buffer_size)

Bases: object

Poll register values using PDOs.

start()

Start the poller.

Return type:

None

stop()

Stop the poller.

Return type:

None

property data: tuple[list[float], list[list[int | float | bytes]]]

Get the poller data. After the data is retrieved, the data buffers are cleared.

Return type:

tuple[list[float], list[list[Union[int, float, bytes]]]]

Returns:

A tuple with a list of the readings timestamps and a list of lists with the readings values.

add_channels(registers)

Configure the PDOs with the registers to be read.

Parameters:

registers (list[dict[str, Union[int, str]]]) – list of registers to add to the Poller.

Return type:

None

subscribe_to_exceptions(callback)

Get notified when an exception occurs on the PDO thread.

Parameters:

callback (Callable[[ILError], None]) – Function to be called when an exception occurs.

Return type:

None

property available_samples: int

Number of samples in the buffer.

Return type:

int

class ingeniamotion.pdo.PDONetwork(alias, network, refresh_rate, watchdog_timeout, _PDONetwork__pdo_thread_status=False)

Bases: object

Represents a PDO network.

alias: str
network: EthercatNetwork
refresh_rate: float | None
watchdog_timeout: float | None
property is_active: bool

Check if the PDO thread is active.

Return type:

bool

Returns:

True if the PDO thread is active. False otherwise.

compare_configuration(refresh_rate, watchdog_timeout)

Compares the current PDO thread configuration with another.

Parameters:
  • refresh_rate (Optional[float]) – Determines how often (seconds) the PDO values will be updated.

  • watchdog_timeout (Optional[float]) – The PDO watchdog time. If not provided it will be set proportional to the refresh rate.

Return type:

bool

Returns:

True if the configurations are equal, False otherwise.

classmethod create_and_subscribe(alias, network, refresh_rate=None, watchdog_timeout=None)

Creates a new PDONetwork instance and subscribes to EtherCAT network PDO thread status.

Parameters:
  • alias (str) – The network alias.

  • network (EthercatNetwork) – The EthercatNetwork instance.

  • refresh_rate (Optional[float]) – Determines how often (seconds) the PDO values will be updated.

  • watchdog_timeout (Optional[float]) – The PDO watchdog time. If not provided it will be set proportional to the refresh rate.

Return type:

PDONetwork

Returns:

A new PDONetwork instance.

teardown()

Unsubscribes from network exceptions.

Return type:

None

class ingeniamotion.pdo.PDONetworksTracker

Bases: object

Tracks the different networks that have been required to activate PDOs.

is_network_tracked(alias)

Checks if a network is being tracked.

Parameters:

alias (str) – The network alias.

Return type:

bool

Returns:

True if the network is tracked, False otherwise.

add_network(alias, network, refresh_rate=None, watchdog_timeout=None)

Add a network to the tracker.

Parameters:
  • alias (str) – The network alias.

  • network (EthercatNetwork) – The EthercatNetwork instance.

  • refresh_rate (Optional[float]) – Determines how often (seconds) the PDO values will be updated.

  • watchdog_timeout (Optional[float]) – The PDO watchdog time. If not provided it will be set proportional to the refresh rate.

Raises:

IMError – If the network is already tracked with a different configuration.

Return type:

None

remove_network(alias)

Remove a network from the tracker.

Parameters:

alias (str) – The network alias.

Raises:

IMError – If the PDOs are not active for the network.

Return type:

None

get_il_network(alias)

Retrieves the Ethercat network for a specific alias.

Parameters:

alias (str) – The network alias.

Return type:

EthercatNetwork

Returns:

The EthercatNetwork instance for the specified alias.

Raises:

IMError – If the PDOs are not active for the network.

is_active(alias)

Checks if the PDO thread is active for a specific network.

Parameters:

alias (str) – The network alias.

Returns:

True if the PDO thread is active, False otherwise.

Return type:

bool

class ingeniamotion.pdo.PDONetworkManager(motion_controller)

Bases: object

Manage all the PDO functionalities.

Parameters:

mc – The MotionController.

create_pdo_item(register_uid, axis=1, servo='default', value=None)

Create a PDOMapItem by specifying a register UID.

Parameters:
  • register_uid (str) – Register to be mapped.

  • axis (int) – servo axis. 1 by default.

  • servo (str) – servo alias to reference it. default by default.

  • value (Union[float, int, None]) – Initial value for an RPDO register.

Return type:

Union[RPDOMapItem, TPDOMapItem]

Returns:

Mappable PDO item.

Raises:
  • ValueError – If there is a type mismatch retrieving the register object.

  • AttributeError – If an initial value is not provided for an RPDO register.

static create_pdo_maps(rpdo_map_items, tpdo_map_items)

Create the RPDO and TPDO maps from PDOMapItems.

Parameters:
  • rpdo_map_items (Union[RPDOMapItem, list[RPDOMapItem]]) – The RPDOMapItems to be added to a RPDOMap.

  • tpdo_map_items (Union[TPDOMapItem, list[TPDOMapItem]]) – The TDOMapItems to be added to a TPDOMap.

Return type:

tuple[RPDOMap, TPDOMap]

Returns:

RPDO and TPDO maps.

static create_empty_rpdo_map()

Create an empty RPDOMap.

Return type:

RPDOMap

Returns:

The empty RPDOMap.

static create_empty_tpdo_map()

Create an empty TPDOMap.

Return type:

TPDOMap

Returns:

The empty TPDOMap.

set_pdo_maps_to_slave(rpdo_maps, tpdo_maps, servo='default')

Map the PDOMaps to the slave.

Parameters:
  • rpdo_maps (Union[RPDOMap, list[RPDOMap]]) – The RPDOMaps to be mapped.

  • tpdo_maps (Union[TPDOMap, list[TPDOMap]]) – he TPDOMaps to be mapped.

  • servo (str) – servo alias to reference it. default by default.

Raises:
  • ValueError – If there is a type mismatch retrieving the drive object.

  • ValueError – If not all elements of the RPDO map list are instances of a RPDO map.

  • ValueError – If not all elements of the TPDO map list are instances of a TPDO map.

Return type:

None

clear_pdo_mapping(servo='default')

Clear the PDO mapping within the servo.

Parameters:

servo (str) – servo alias to reference it. default by default.

Raises:

ValueError – If there is a type mismatch retrieving the drive object.

Return type:

None

remove_rpdo_map(servo='default', rpdo_map=None, rpdo_map_index=None)

Remove a RPDOMap from the RPDOMap list.

The RPDOMap instance or the index of the map in the RPDOMap list

should be provided.

Parameters:
  • servo (str) – servo alias to reference it. default by default.

  • rpdo_map (Optional[RPDOMap]) – The RPDOMap instance to be removed.

  • rpdo_map_index (Optional[int]) – The index of the RPDOMap list to be removed.

Raises:

ValueError – If there is a type mismatch retrieving the drive object.

Return type:

None

remove_tpdo_map(servo='default', tpdo_map=None, tpdo_map_index=None)

Remove a TPDOMap from the TPDOMap list.

The TPDOMap instance or the index of the map in the TPDOMap list should be provided.

Parameters:
  • servo (str) – servo alias to reference it. DEFAULT_SERVO by default.

  • tpdo_map (Optional[TPDOMap]) – The TPDOMap instance to be removed.

  • tpdo_map_index (Optional[int]) – The index of the TPDOMap list to be removed.

Raises:

ValueError – If there is a type mismatch retrieving the drive object.

Return type:

None

start_pdos(network_type=None, refresh_rate=None, watchdog_timeout=None, servo='default')

Start the PDO exchange process.

Warning

Note that the PDO exchange will start for all servos connected to the same network.

Parameters:
  • network_type (Optional[CommunicationType]) – Network type (EtherCAT or CANopen) on which to start the PDO exchange.

  • refresh_rate (Optional[float]) – Determines how often (seconds) the PDO values will be updated.

  • watchdog_timeout (Optional[float]) – The PDO watchdog time. If not provided it will be set proportional to the refresh rate.

  • servo (str) – servo alias to reference it. DEFAULT_SERVO by default. If network_type is provided, servo must be connected to that network.

Raises:
  • ValueError – If the MotionController is not connected to any Network.

  • ValueError – If there is a type mismatch retrieving the network object.

Return type:

None

stop_pdos(servo='default')

Stop the PDO exchange process.

Warning

Note that the PDO exchange will stop for all servos connected to the same network.

Parameters:

servo (str) – servo alias to reference it. DEFAULT_SERVO by default. PDOs will be stopped in the network to which the servo is connected.

Raises:

IMError – If the PDOs are not active yet.

Return type:

None

is_active(servo='default', net_alias=None)

Check if the PDO thread is active for the network to which the servo is connected.

Alternatively, it can be checked for a specific network. If the network alias is provided, the servo will be ignored.

Parameters:
  • servo (Optional[str]) – servo alias to reference it. DEFAULT_SERVO by default.

  • net_alias (Optional[str]) – network alias to reference it. None by default.

Return type:

bool

Returns:

True if the PDO thread is active. False otherwise.

Raises:

ValueError – If neither servo nor net_alias is provided.

subscribe_to_send_process_data(callback, servo='default')

Subscribe be notified when the RPDO values will be sent.

Parameters:
  • callback (Callable[[], None]) – Callback function.

  • servo (str) – servo alias to reference it. DEFAULT_SERVO by default. The subscription will be added to the network to which the servo is connected.

Return type:

None

subscribe_to_receive_process_data(callback, servo='default')

Subscribe be notified when the TPDO values are received.

Parameters:
  • callback (Callable[[], None]) – Callback function.

  • servo (str) – servo alias to reference it. DEFAULT_SERVO by default. The subscription will be added to the network to which the servo is connected.

Return type:

None

subscribe_to_exceptions(callback, servo='default')

Subscribe be notified when there is an exception in the PDO process data thread.

If a callback is subscribed, the PDO exchange process is paused when an exception is raised. It can be resumed using the resume_pdos method.

Parameters:
  • callback (Callable[[ILError], None]) – Callback function.

  • servo (str) – servo alias to reference it. DEFAULT_SERVO by default. The subscription will be added to the network to which the servo is connected.

Return type:

None

unsubscribe_to_send_process_data(callback, servo='default')

Unsubscribe from the send process data notifications.

Parameters:
  • callback (Callable[[], None]) – Subscribed callback function.

  • servo (str) – servo alias to reference it. DEFAULT_SERVO by default. The unsubscription will be removed from the network to which the servo is connected.

  • callback – Subscribed callback function.

Return type:

None

unsubscribe_to_receive_process_data(callback, servo='default')

Unsubscribe from the receive process data notifications.

Parameters:
  • callback (Callable[[], None]) – Subscribed callback function.

  • servo (str) – servo alias to reference it. DEFAULT_SERVO by default. The unsubscription will be removed from the network to which the servo is connected.

Return type:

None

create_poller(registers, servo='default', sampling_time=0.125, buffer_size=100, watchdog_timeout=None, start=True)

Create a register Poller using PDOs.

Parameters:
  • registers (list[dict[str, Union[int, str]]]) –

    list of registers to add to the Poller. Dicts should have the follow format:

    [
        { # Poller register one
            "name": "CL_POS_FBK_VALUE",  # Register name.
            "axis": 1  # Register axis.
            # If it has no axis field, by default axis 1.
        },
        { # Poller register two
            "name": "CL_VEL_FBK_VALUE",  # Register name.
            "axis": 1  # Register axis.
            # If it has no axis field, by default axis 1.
        }
    ]
    

  • servo (str) – servo alias to reference it. default by default.

  • sampling_time (float) – period of the sampling in seconds. By default 0.125 seconds.

  • watchdog_timeout (Optional[float]) – The PDO watchdog time. If not provided it will be set proportional to the refresh rate.

  • buffer_size (int) – number maximum of sample for each data read. 100 by default.

  • start (bool) – if True, function starts poller, if False poller should be started after. True by default.

Return type:

PDOPoller

Returns:

The poller instance.

unsubscribe_to_exceptions(callback, servo='default')

Unsubscribe from the exceptions in the process data notifications.

Parameters:
  • callback (Callable[[ILError], None]) – Subscribed callback function.

  • servo (str) – servo alias to reference it. DEFAULT_SERVO by default. The unsubscription will be removed from the network to which the servo is connected.

Return type:

None