Motion

class ingeniamotion.motion.Motion(motion_controller)

Bases: object

Motion.

CONTROL_WORD_REGISTER = 'DRV_STATE_CONTROL'
OPERATION_MODE_REGISTER = 'DRV_OP_CMD'
OPERATION_MODE_DISPLAY_REGISTER = 'DRV_OP_VALUE'
POSITION_SET_POINT_REGISTER = 'CL_POS_SET_POINT_VALUE'
VELOCITY_SET_POINT_REGISTER = 'CL_VEL_SET_POINT_VALUE'
CURRENT_QUADRATURE_SET_POINT_REGISTER = 'CL_CUR_Q_SET_POINT'
CURRENT_DIRECT_SET_POINT_REGISTER = 'CL_CUR_D_SET_POINT'
VOLTAGE_QUADRATURE_SET_POINT_REGISTER = 'CL_VOL_Q_SET_POINT'
VOLTAGE_DIRECT_SET_POINT_REGISTER = 'CL_VOL_D_SET_POINT'
ACTUAL_POSITION_REGISTER = 'CL_POS_FBK_VALUE'
ACTUAL_VELOCITY_REGISTER = 'CL_VEL_FBK_VALUE'
ACTUAL_DIRECT_CURRENT_REGISTER = 'CL_CUR_D_VALUE'
ACTUAL_QUADRATURE_CURRENT_REGISTER = 'CL_CUR_Q_VALUE'
GENERATOR_FREQUENCY_REGISTER = 'FBK_GEN_FREQ'
GENERATOR_GAIN_REGISTER = 'FBK_GEN_GAIN'
GENERATOR_OFFSET_REGISTER = 'FBK_GEN_OFFSET'
GENERATOR_CYCLE_NUMBER_REGISTER = 'FBK_GEN_CYCLES'
GENERATOR_REARM_REGISTER = 'FBK_GEN_REARM'
STATUS_WORD_TARGET_REACHED_BIT = 2048
CONTROL_WORD_TARGET_LATCH_BIT = 512
target_latch(servo='default', axis=1)

Active target latch.

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

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

Raises:

TypeError – If some read value has a wrong type.

Return type:

None

set_operation_mode(operation_mode, servo='default', axis=1)

Set operation mode to a target servo and axis.

Parameters:
  • operation_mode (Union[OperationMode, int]) – operation mode, any of OperationMode.

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

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

Return type:

None

get_operation_mode(servo='default', axis=1)

Return current operation mode.

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

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

Return type:

Union[OperationMode, int]

Returns:

Return current operation mode.

Raises:

TypeError – If some read value has a wrong type.

motor_enable(servo='default', axis=1, error_timeout=6)

Enable motor.

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

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

  • error_timeout (float) – Maximum wait for error update in seconds.

Raises:
  • ingenialink.exceptions.ILError – If the servo cannot enable the motor.

  • ingenialink.exceptions.ILTimeoutError – If the error was not raised in time.

Return type:

None

motor_disable(servo='default', axis=1)

Disable motor.

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

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

Return type:

None

fault_reset(servo='default', axis=1)

Fault reset.

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

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

Return type:

None

move_to_position(position, servo='default', axis=1, target_latch=True, blocking=False, error=20, timeout=None, interval=None)

Set position set point to a target servo and axis, in counts.

Parameters:
  • position (int) – target position, in counts.

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

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

  • target_latch (bool) – if True does target latch at the end. True by default.

  • blocking (bool) – if True, the function is blocked until the target position is reached. False by default.

  • error (int) – If blocking is enabled, allowed error between actual position and target position, in counts.

  • timeout (Optional[float]) – If blocking is enabled, how many seconds to wait for the servo to reach the target position, if None it will wait forever. None by default.

  • interval (Optional[float]) – If blocking is enabled, interval of time between actual position reads, in seconds. None by default.

Raises:
Return type:

None

set_velocity(velocity, servo='default', axis=1, target_latch=True, blocking=False, error=0.1, timeout=None, interval=None)

Set velocity set point to a target servo and axis, in rev/s.

Parameters:
  • velocity (float) – target velocity, in rev/s.

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

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

  • target_latch (bool) – if True does target latch at the end. True by default.

  • blocking (bool) – if True, the function is blocked until the target position is reached. False by default.

  • error (float) – If blocking is enabled, allowed error between actual velocity and target velocity, in rev/s.

  • timeout (Optional[float]) – If blocking is enabled, how many seconds to wait for the servo to reach the target velocity, if None it will wait forever. None by default.

  • interval (Optional[float]) – If blocking is enabled, interval of time between actual velocity reads, in seconds. None by default.

Raises:
Return type:

None

set_current_quadrature(current, servo='default', axis=1)

Set quadrature current set point to a target servo and axis, in A.

Parameters:
  • current (float) – target quadrature current, in A.

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

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

Raises:

TypeError – If current is not a float.

Return type:

None

set_current_direct(current, servo='default', axis=1)

Set direct current set point to a target servo and axis, in A.

Parameters:
  • current (float) – target direct current, in A.

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

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

Raises:

TypeError – If current is not a float.

Return type:

None

set_voltage_quadrature(voltage, servo='default', axis=1)

Set quadrature voltage set point to a target servo and axis, in V.

Parameters:
  • voltage (float) – target quadrature voltage, in V.

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

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

Raises:

TypeError – If voltage is not a float.

Return type:

None

set_voltage_direct(voltage, servo='default', axis=1)

Set direct voltage set point to a target servo and axis, in V.

Parameters:
  • voltage (float) – target direct voltage, in V.

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

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

Raises:

TypeError – If voltage is not a float.

Return type:

None

current_quadrature_ramp(target_value, time_s, servo='default', axis=1, init_value=0, interval=None)

Generate a current quadrature ramp.

Given a target value and a time in seconds, changes the current quadrature set-point linearly following a ramp. This function is blocked until target reached.

Parameters:
  • target_value (float) – target value of the ramp.

  • time_s (float) – duration of the ramp, in seconds.

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

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

  • init_value (float) – initial value of the ramp. 0 by default.

  • interval (Optional[float]) – time interval between register writes, in seconds. None by default, no interval.

Raises:

TypeError – If target_value or time_s is not a float.

Return type:

None

current_direct_ramp(target_value, time_s, servo='default', axis=1, init_value=0, interval=None)

Generate a current direct ramp.

Given a target value and a time in seconds, changes the current direct set-point linearly following a ramp. This function is blocked until target reached.

Parameters:
  • target_value (float) – target value of the ramp.

  • time_s (float) – duration of the ramp, in seconds.

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

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

  • init_value (float) – initial value of the ramp. 0 by default.

  • interval (Optional[float]) – time interval between register writes, in seconds. None by default, no interval.

Raises:

TypeError – If target_value or time_s is not a float.

Return type:

None

voltage_quadrature_ramp(target_value, time_s, servo='default', axis=1, init_value=0, interval=None)

Generate a voltage quadrature ramp.

Given a target value and a time in seconds, changes the voltage quadrature set-point linearly following a ramp. This function is blocked until target reached.

Parameters:
  • target_value (float) – target value of the ramp.

  • time_s (float) – duration of the ramp, in seconds.

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

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

  • init_value (float) – initial value of the ramp. 0 by default.

  • interval (Optional[float]) – time interval between register writes, in seconds. None by default, no interval.

Raises:

TypeError – If target_value or time_s is not a float.

Return type:

None

voltage_direct_ramp(target_value, time_s, servo='default', axis=1, init_value=0, interval=None)

Generate a voltage direct ramp.

Given a target value and a time in seconds, changes the voltage direct set-point linearly following a ramp. This function is blocked until target reached.

Parameters:
  • target_value (float) – target value of the ramp.

  • time_s (float) – duration of the ramp, in seconds.

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

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

  • init_value (float) – initial value of the ramp. 0 by default.

  • interval (Optional[float]) – time interval between register writes, in seconds. None by default, no interval.

Raises:

TypeError – If target_value or time_s is not a float.

Return type:

None

static ramp_generator(init_v, final_v, total_t, interval=None)

Generate a ramp.

Parameters:
  • init_v (float) – Initial value.

  • final_v (float) – Final value.

  • total_t (float) – Total time.

  • interval (Optional[float]) – Time between each sample.

Yields:

Ramp values from initial to final value.

Return type:

Generator[float, None, None]

get_actual_position(servo='default', axis=1)

Returns actual position register.

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

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

Returns:

actual position value

Return type:

int

Raises:

TypeError – If some read value has a wrong type.

get_actual_velocity(servo='default', axis=1)

Returns actual velocity register.

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

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

Returns:

actual velocity value

Return type:

int

Raises:

TypeError – If some read value has a wrong type.

get_actual_current_direct(servo='default', axis=1)

Returns actual direct current register.

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

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

Returns:

actual direct current value

Return type:

float

Raises:

TypeError – If some read value has a wrong type.

get_actual_current_quadrature(servo='default', axis=1)

Returns actual quadrature current register.

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

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

Returns:

actual quadrature current value

Return type:

float

Raises:

TypeError – If some read value has a wrong type.

wait_for_position(position, servo='default', axis=1, error=20, timeout=None, interval=None)

Wait until actual position is equal to a target position, with an error.

Parameters:
  • position (int) – target position, in counts.

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

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

  • error (int) – allowed error between actual position and target position, in counts.

  • timeout (Optional[float]) – how many seconds to wait for the servo to reach the target position, if None it will wait forever . None by default.

  • interval (Optional[float]) – interval of time between actual position reads, in seconds. None by default.

Raises:

IMTimeoutError – If the target position is not reached in time.

Return type:

None

wait_for_velocity(velocity, servo='default', axis=1, error=0.1, timeout=None, interval=None)

Wait until actual velocity is equal to a target velocity, with an error.

Parameters:
  • velocity (float) – target velocity, in rev/s.

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

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

  • error (float) – allowed error between actual velocity and target velocity, in rev/s.

  • timeout (Optional[float]) – how many seconds to wait for the servo to reach the target velocity, if None it will wait forever. None by default.

  • interval (Optional[float]) – interval of time between actual velocity reads, in seconds. None by default.

Raises:

IMTimeoutError – If the target velocity is not reached in time.

Return type:

None

set_internal_generator_configuration(op_mode, servo='default', axis=1, pair_poles=1)

Set internal generator configuration.

Note

This functions affects the following drive registers: motor pair poles, operation mode, phasing mode and commutation feedback. This is an advanced-user oriented method, you could lose your drive configuration, use it at your own risk.

Parameters:
  • op_mode (OperationMode) – select Current or Voltage operation mode for internal generator configuration.

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

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

  • pair_poles (int) – motor poles pair. 1 by default.

Raises:

ValueError – If operation mode is not set to Current or Voltage.

Return type:

None

internal_generator_saw_tooth_move(direction, cycles, frequency, gain=1.0, servo='default', axis=1)

Move motor in internal generator configuration with generator mode saw tooth.

Parameters:
  • direction (int) – 1 for positive direction and -1 for negative direction.

  • cycles (int) – movement cycles.

  • frequency (float) – cycles for second.

  • gain (float) – positive generator gain.

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

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

Raises:
  • TypeError – If direction, cycles or frequency is not of the correct type.

  • ValueError – If gain is not positive.

Return type:

None

internal_generator_constant_move(offset, servo='default', axis=1)

Move motor in internal generator configuration with generator mode constant.

Parameters:
  • offset (int) – internal generator offset.

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

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

Raises:

TypeError – If offset is not an int.

Return type:

None