GeminiMotorDrive.utilities

Module for a utility function and class.

strip_commands(commands) Strips a sequence of commands.
UnitConverter(dmepit, eres[, unit_in_meters]) Converter between physical units and motor units.

strip_commands

GeminiMotorDrive.utilities.strip_commands(commands)[source]

Strips a sequence of commands.

Strips down the sequence of commands by removing comments and surrounding whitespace around each individual command and then removing blank commands.

Parameters:commands (iterable of strings) – Iterable of commands to strip.
Returns:stripped_commands (list of str) – The stripped commands with blank ones removed.

UnitConverter

class GeminiMotorDrive.utilities.UnitConverter(dmepit, eres, unit_in_meters=1.0)[source]

Bases: object

Converter between physical units and motor units.

Class to convert between the desired physical unit of length and motor units; which are encoder counts for distance, motor pitches per second for velocity, and motor pitches per second squared for acceleration.

Parameters:
  • dmepit (float) – Electrical pitch of the motor.
  • eres (int) – Encoder resolution.
  • unit_in_meters (float, optional) – The length in meters of the desired physical unit of length for this convert to convert between. The default, 1.0, corresponds to converting between meters and motor units.
to_motor_distance(distance)[source]

Convert distance/s to motor units.

Converts distance/s to units of motor encoder counts, which is what the drive requires when given move instructions.

Parameters:distance (int, float, or iterable of ints and floats) – The distance/s to convert.
Returns:converted_distance (float or list of floats) – The converted distance/s.
to_motor_velocity_acceleration(va)[source]

Convert velocities/accelerations to motor units.

Converts velocity/ies and/or acceleration/s to units of motor pitch per second (or second squared), which is what the drive requires when given move instructions.

Parameters:va (int, float, or iterable of ints and floats) – The velocities/accelerations to convert.
Returns:converted_va (float or list of floats) – The converted velocities/accelerations.
to_unit_distance(distance)[source]

Convert distance/s to units of UnitConverter.

Converts distance/s from motor encoder counts to that of this UnitConverter.

Parameters:distance (int, float, or iterable of ints and floats) – The distance/s to convert.
Returns:converted_distance (float or list of floats) – The converted distance/s.
to_unit_velocity_acceleration(va)[source]

Convert velocities/accelerations to units of UnitConverter.

Converts velocity/ies and/or acceleration/s from units of motor pitch per second (or second squared) to that of this UnitConverter.

Parameters:va (int, float, or iterable of ints and floats) – The velocities/accelerations to convert.
Returns:converted_va (float or list of floats) – The converted velocities/accelerations.