roboglia.dynamixel.DynamixelSyncWriteLoop

class DynamixelSyncWriteLoop(name='BASESYNC', patience=1.0, frequency=None, warning=0.9, throttle=0.1, review=1.0, group=None, registers=[], auto=True)[source]

Bases: roboglia.base.sync.BaseSync

Implements SyncWrite as specified in the frequency parameter.

The devices are provided in the group parameter and the registers in the registers as a list of register names. It will update from int_value of each register for every device. Will raise exceptions if the SyncWrite cannot be setup or fails to execute.

setup()[source]

This allocates the GroupSyncWrite. It needs to be here and not in the constructor as this is part of the wrapped execution that is produced by BaseThread class.

atomic()[source]

Executes a SyncWrite.

__init__(name='BASESYNC', patience=1.0, frequency=None, warning=0.9, throttle=0.1, review=1.0, group=None, registers=[], auto=True)

Initialize self. See help(type(self)) for accurate signature.

property actual_frequency

Returns the actual running frequency that is calculated by statistics.

property auto_start

Shows if the sync should be started automatically when the robot starts.

property bus

The bus this sync works with.

property devices

The devices used by the sync.

property error_stat

(error in %, total errors, total items).

Type

Returns the error statistics as a tuple

property errors

Returns the number of errors logged by the statistics.

property frequency

Loop frequency.

get_register_range()

Determines the start address of the range of registers and the whole length. Registers do not need to be order, but be careful that not all communication protocols can support gaps in the bulk read of registers.

Returns

  • int – The start address of the range

  • int – The length covering all the registers (including gaps)

  • bool – True is the range of registers is contiguous

inc_errors()

Used by subclasses to increment the number of errors.

inc_processed()

Used by subclasses to increment the number of processed items.

property name

Returns the name of the thread.

pause()

Requests the thread to pause.

property paused

Indicates the thread was paused.

property period

Loop period = 1 / frequency.

process_devices()

Processes the provided devices.

The devices are exected as a set in the init_dict. This is normally performed by the robot class when reading the robot definition by replacing the name of the group with the actual content of the group. This method checks that all devices are assigned to the same bus otherwise raises an exception. It returns the single instance of the bus that manages all devices.

process_registers()

Checks that the supplied registers are available in all devices.

property processed

Returns the number of items processed in the current statistics. The items processed depends on the loop and might be different from the number of loops executed. For example the one execution loop might include several communication packets.

property register_names

The register names used by the sync.

resume()

Requests the thread to resume.

property review

Indicates the amount of time in seconds before the thread will review the actual frequency against the target and take action.

run()

Run method of the thread.

property running

Indicates if the thread is running.

start()

Checks that the bus is open, then refreshes the register, sets the sync flag before calling the inherited :py:meth:BaseLoop.`start.

property started

Indicates if the thread was started.

stop()

Before calling the inherited method it un-flags the registers for syncing.

property stopped

Indicates if the thread was stopped.

teardown()

Thread cleanup. Subclasses should override.

property warning

Control the warning level for the warning message, the setter is smart: if the value is larger than 2 it will assume it is a percentage and divied it by 100 and ignore if the number is higher than 110. The over 100 is available for testing purposes.