Servo
- class ingenialink.servo.DictionaryFactory[source]
Dictionary factory, creates the appropriate dictionary instance according to the file version and connection interface
- classmethod create_dictionary(dictionary_path: str, interface: Interface) Dictionary [source]
- Creates a dictionary instance choosing the class depending on dictionary version and
connection interface.
- Parameters:
dictionary_path – target dictionary path
interface – connection interface
- Returns:
Dictionary instance
- Raises:
FileNotFoundError – dictionary path does not exist.
ILDictionaryParseError – xdf is not well-formed.
ILDictionaryParseError – File is not a xdf.
NotImplementedError – Dictionary version is not supported.
- classmethod get_dictionary_description(dictionary_path: str, interface: Interface) DictionaryDescriptor [source]
Quick function to get target dictionary description
- Parameters:
dictionary_path – target dictionary path
interface – device interface
- Returns:
Target dictionary description
- Raises:
FileNotFoundError – dictionary path does not exist.
ILDictionaryParseError – xdf is not well-formed.
NotImplementedError – Dictionary version is not supported.
- class ingenialink.servo.Servo(target: int | str, dictionary_path: str, servo_status_listener: bool = False)[source]
Declaration of a general Servo object.
- Parameters:
target – Target ID of the servo.
dictionary_path – Path to the dictionary file.
servo_status_listener – Toggle the listener of the servo for its status, errors, faults, etc.
- Raises:
ILDictionaryParseError – If dictionary can not be parsed.
- check_configuration(config_file: str, subnode: int | None = None) None [source]
Check if the drive is configured in the same way as the given configuration file. Compares the value of each register in the given file with the corresponding value in the drive.
- Parameters:
config_file – the configuration to check
subnode – Subnode of the axis. Defaults to None.
- Raises:
FileNotFoundError – If the configuration file cannot be found.
ValueError – If a configuration file from a subnode different from 0 is attempted to be loaded to subnode 0.
ValueError – If an invalid subnode is provided.
ILConfigurationError – If the configuration file differs from the drive state.
- disable(subnode: int = 1, timeout: int = 1000) None [source]
Disable PDS.
- Parameters:
subnode – Subnode of the drive.
timeout – Timeout in milliseconds.
- Raises:
ILTimeoutError – The servo could not be disabled due to timeout.
ILError – Failed to disable PDS.
- disturbance_get_num_mapped_registers() int [source]
Obtain the number of disturbance mapped registers.
- Returns:
Actual number of mapped registers.
- disturbance_set_mapped_register(channel: int, address: int, subnode: int, dtype: int, size: int) None [source]
Set monitoring mapped register.
- Parameters:
channel – Identity channel number.
address – Register address to map.
subnode – Subnode to be targeted.
dtype – Register data type.
size – Size of data in bytes.
- disturbance_write_data(channels: int | List[int], dtypes: REG_DTYPE | List[REG_DTYPE], data_arr: List[int | float] | List[List[int | float]]) None [source]
Write disturbance data.
- Parameters:
channels – Channel identifier.
dtypes – Data type.
data_arr – Data array.
- emcy_subscribe(callback: Callable[[EmergencyMessage], None]) None [source]
Subscribe to emergency messages.
- Parameters:
callback – Callable that takes an EmergencyMessage instance as argument.
- emcy_unsubscribe(callback: Callable[[EmergencyMessage], None]) None [source]
Unsubscribe from emergency messages.
- Parameters:
callback – Subscribed callback.
- enable(subnode: int = 1, timeout: int = 1000) None [source]
Enable PDS.
- Args:
subnode: Subnode of the drive. timeout: Timeout in milliseconds.
- Raises:
ILTimeoutError – The servo could not be enabled due to timeout.
ILError – Failed to enable PDS.
- fault_reset(subnode: int = 1, timeout: int = 1000) None [source]
Executes a fault reset on the drive.
- Parameters:
subnode – Subnode of the drive.
timeout – Timeout in milliseconds.
- Raises:
ILTimeoutError – If fault reset spend too much time.
ILError – Failed to fault reset.
- is_alive() bool [source]
Checks if the servo responds to a reading a register.
- Returns:
Return code with the result of the read.
- is_listener_started() bool [source]
Check if servo listener is started
- Returns:
True if listener is started, else False
- load_configuration(config_file: str, subnode: int | None = None, strict: bool = False) None [source]
Write current dictionary storage to the servo drive.
- Parameters:
config_file – Path to the dictionary.
subnode – Subnode of the axis.
strict – Whether to raise an exception if any error occurs during the loading
false (configuration process. If)
ignored. (all errors will only be)
default. (False by)
- Raises:
FileNotFoundError – If the configuration file cannot be found.
ValueError – If a configuration file from a subnode different from 0 is attempted to be loaded to subnode 0.
ValueError – If an invalid subnode is provided.
ILError – If strict is set to True and any error occurs during the loading
configuration process. –
- monitoring_channel_data(channel: int, dtype: REG_DTYPE | None = None) List[float] [source]
Obtain processed monitoring data of a channel.
- Parameters:
channel – Identity channel number.
dtype – Data type of the register to map.
Note
The dtype argument is not necessary for this function, it was added to maintain compatibility with IPB’s implementation of monitoring.
- Returns:
Monitoring data.
- monitoring_get_bytes_per_block() int [source]
Obtain Bytes x Block configured.
- Returns:
Actual number of Bytes x Block configured.
- monitoring_get_num_mapped_registers() int [source]
Obtain the number of monitoring mapped registers.
- Returns:
Actual number of mapped registers.
- monitoring_read_data() None [source]
Obtain processed monitoring data.
- Returns:
Actual processed monitoring data.
- monitoring_set_mapped_register(channel: int, address: int, subnode: int, dtype: int, size: int) None [source]
Set monitoring mapped register.
- Parameters:
channel – Identity channel number.
address – Register address to map.
subnode – Subnode to be targeted.
dtype – Register data type.
size – Size of data in bytes.
- read(reg: str | Register, subnode: int = 1, **kwargs: Any) int | float | str | bytes [source]
Read a register value from servo.
- Parameters:
reg – Register.
subnode – Target axis of the drive.
- Returns:
int, float or Value stored in the register.
- Raises:
ILAccessError – Wrong access to the register.
ILIOError – Error reading the register.
ILTimeoutError – Read timeout.
- read_bitfields(reg: str | Register, subnode: int = 1, bitfields: Dict[str, BitField] | None = None) Dict[str, int] [source]
Read bitfields of a register.
- Parameters:
reg – Register.
subnode – Target subnode of the drive.
bitfields – Optional bitfield specification. If not it will be used from the register definition (if Any)
- Returns:
Dictionary with values of the bitfields. Key is the name of the bitfield. Value is the value parsed.
- register_update_subscribe(callback: Callable[[Servo, Register, int | float | str | bytes], None]) None [source]
Subscribe to register updates. The callback will be called when a read/write operation occurs.
- Parameters:
callback – Callable that takes a Servo and a Register instance as arguments.
- register_update_unsubscribe(callback: Callable[[Servo, Register, int | float | str | bytes], None]) None [source]
Unsubscribe to register updates.
- Parameters:
callback – Subscribed callback.
- reload_errors(dictionary: str) None [source]
Force to reload all dictionary errors.
- Parameters:
Dictionary.
- replace_dictionary(dictionary: str) None [source]
Deletes and creates a new instance of the dictionary.
- Parameters:
dictionary – Path to the dictionary.
- restore_parameters(subnode: int | None = None) None [source]
Restore all the current parameters of all the slave to default.
Note
The drive needs a power cycle after this in order for the changes to be properly applied.
- Parameters:
subnode – Subnode of the axis. None by default which restores all the parameters.
- Raises:
ILError – Invalid subnode.
- save_configuration(config_file: str, subnode: int | None = None) None [source]
Read all dictionary registers content and put it to the dictionary storage.
- Parameters:
config_file – Destination path for the configuration file.
subnode – Subnode of the axis.
- state_wait_change(state: SERVO_STATE, timeout: int, subnode: int = 1) SERVO_STATE [source]
Waits for a state change.
- Parameters:
state – Servo state before calling this function.
timeout – Maximum value to wait for the change.
subnode – Subnode of the drive.
- Returns:
The last read state.
- Raises:
ILTimeoutError – If state does not change in the given time.
- status_word_decode(status_word: Dict[str, int]) SERVO_STATE [source]
Decodes the status word to a known value.
- Parameters:
status_word – Read value for the status word.
- Returns:
Status word value.
- status_word_wait_change(status_word: int, timeout: int, subnode: int = 1) None [source]
Waits for a status word change.
- Parameters:
status_word – Status word to wait for.
timeout – Maximum value to wait for the change.
subnode – Subnode of the drive.
- Raises:
ILTimeoutError – If status word does not change in the given time.
- store_parameters(subnode: int | None = None) None [source]
Store all the current parameters of the target subnode.
- Parameters:
subnode – Subnode of the axis. None by default which stores
parameters. (all the)
- Raises:
ILError – Invalid subnode.
- subscribe_to_status(callback: Callable[[SERVO_STATE, int], Any]) None [source]
Subscribe to state changes.
- Parameters:
callback – Callback function.
- Returns:
Assigned slot.
- unsubscribe_from_status(callback: Callable[[SERVO_STATE, int], Any]) None [source]
Unsubscribe from state changes.
- Parameters:
function. (Callback)
- write(reg: str | Register, data: int | float | str | bytes, subnode: int = 1, **kwargs: Any) None [source]
Writes a data to a target register.
- Parameters:
reg – Target register to be written.
data – Data to be written.
subnode – Target axis of the drive.
- Raises:
ILAccessError – Wrong access to the register.
ILIOError – Error writing the register.
ILTimeoutError – Write timeout.
- write_bitfields(reg: str | Register, values: Dict[str, int], subnode: int = 1, bitfields: Dict[str, BitField] | None = None) None [source]
Write bitfields of a register.
Only the values specified will be updated. The register will be read first to prevent overwriting other bits.
- Parameters:
reg – Register
values – Dictionary with values of the bitfields. Key is the name of the bitfield. Value is the value to set.
subnode – Target subnode of the drive.
bitfields – Optional bitfield specification. If not it will be used from the register definition (if Any)
- property dictionary: Dictionary
Returns dictionary object
- property disturbance_data: bytes
Obtain disturbance data.
- Returns:
Current disturbance data.
- property disturbance_data_size: int
Obtain disturbance data size.
- Returns:
Current disturbance data size.
- property disturbance_number_mapped_registers: int
Get the number of mapped disturbance registers.
- property errors: Dict[int, DictionaryError]
Errors.
- property full_name: str
Obtains the servo full name.
- property info: Dict[str, None | str | int]
Servo information.
- property monitoring_data_size: int
Obtain monitoring data size.
- Returns:
Current monitoring data size in bytes.
- property monitoring_number_mapped_registers: int
Get the number of mapped monitoring registers.
- property status: Dict[int, SERVO_STATE]
Servo status.
- property subnodes: Dict[int, SubnodeType]
Dictionary of subnode ids and their type
- units_acc
Acceleration units.
- Type:
SERVO_UNITS_ACC
- units_pos
Position units.
- Type:
SERVO_UNITS_POS
- units_torque
Torque units.
- Type:
SERVO_UNITS_TORQUE
- units_vel
Velocity units.
- Type:
SERVO_UNITS_VEL