qmi.instruments.pololu.maestro

Instrument driver for the Pololu maestro servo controller

Classes

Pololu_Maestro(context, name, transport[, ...])

Instrument driver for the Pololu Maestro servo controller.

class qmi.instruments.pololu.maestro.Pololu_Maestro(context: QMI_Context, name: str, transport: str, num_channels: int = 6, channels_min_max_targets: Dict[int, Tuple[int, int]] | None = None, channels_min_max_speeds: Dict[int, Tuple[int, int]] | None = None, channels_min_max_accelerations: Dict[int, Tuple[int, int]] | None = None)

Instrument driver for the Pololu Maestro servo controller.

open() None

Connect to the instrument hardware.

When this method returns, the instrument must be ready for interaction via calls to instrument-specific methods.

Subclasses can extend this method to implement instrument-specific initialization. If they do, they should call super().open() as a last statement.

close() None

Close the connection to the instrument hardware and release associated resources.

When this method returns, the instrument must not be used again unless it is first re-opened by calling the open() method.

Subclasses can extend this method if they have specific resources to close. If they do, they should call super().close() as a last statement.

get_idn() QMI_InstrumentIdentification

Return QMI_InstrumentIdentification instance.

set_target(channel: int, value: int) None

Set channel to a specified target value. The target value is of units 0.25us. For example, if you want to set the target to 1500 us, you need to give as input 6000: (1500×4 = 6000 = 01011101110000 in binary) Servo will begin moving based on speed and acceleration parameters previously set. This method will check against the maximum and minimum target value of the channel. If the value to be set is out of the min/max range, the method will set the target value to the min/max.

Parameters:
  • channel – Channel number.

  • value – The target value in units of quarter microseconds.

get_targets() List[int]

Get the current targets for each channel.

Returns:

The target values for each channel.

get_position(channel: int) int

Get the current position of the specified channel in quarter-microseconds.

Parameters:

channel – The channel number.

Returns:

The position in quarter-microsecond units.

set_speed(channel: int, speed: int) None

Set speed of channel. This option specifies the speed of the servo in units of 0.25 us / 10 ms => speed * 1 us / 40 ms.

Parameters:
  • channel – The channel number.

  • speed – The target speed.

Raises:

ValueError if speed is out of allowable range.

set_acceleration(channel: int, acceleration: int) None

Set acceleration of a channel. This option specifies the acceleration of the servo in units of 0.25 us / 10 ms / 80 ms => acceleration * 1 us / 3.2 ms .

Parameters:
  • channel – The channel number.

  • acceleration – The target acceleration.

Raises:

ValueError if acceleration not within 0 to 255

go_home()

Send all servos and outputs to their home values.

set_min_target(channel: int, value: int) None

Set the minimum target value for a channel.

Parameters:
  • channel – The channel number.

  • value – The new minimum target value.

get_min_target(channel: int) int

Get the minimum target value for a channel.

Parameters:

channel – The channel number.

set_max_target(channel: int, value: int) None

Set the maximum target that can be set for a channel.

Parameters:
  • channel – The channel number.

  • value – The new maximum target value.

get_max_target(channel: int) int

Get the maximum target that can be set for a channel.

Parameters:

channel – The channel number.

set_max(channel: int, value: int) None

Set the maximum target that can be set for a channel.

Parameters:
  • channel – The channel number.

  • value – The new maximum target value.

set_min(channel: int, value: int) None

Set the minimum target that can be set for a channel.

Parameters:
  • channel – The channel number.

  • value – The new maximum target value.

set_target_value(channel: int, value: int) None

Set channel to a specified target value. The target value is of units 0.25us. For example, if you want to set the target to 1500 us, you need to give as input 6000: (1500×4 = 6000 = 01011101110000 in binary) Servo will begin moving based on speed and acceleration parameters previously set. This method will check against the maximum and minimum target value of the channel. If the value to be set is out of the min/max range, the method will set the target value to the min/max.

Parameters:
  • channel – Channel number.

  • value – The target value in units of quarter microseconds.

get_value(channel: int) int

Get the current position of the specified channel in quarter-microseconds.

Parameters:

channel – The channel number.

Returns:

The position in quarter-microsecond.

move_up(channel: int) None

Move the servo to maximal value.

Parameters:

channel – The channel number.

move_down(channel: int) None

Move the servo to minimal value.

Parameters:

channel – The channel number.

force_unlock() None

Forcefully unlock the remote object.

This unlocks the object, regardless of who owns the lock. This allows you to unlock an object if the locking proxy has been destroyed without unlocking.

Use this with care.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

classmethod get_category() str | None

Return the optional name of the category this object belongs to.

A category name is a free-form string that has no special significance. Its purpose is to distinguish between groups of RPC objects that fulfill similar roles.

get_name() str

Return the name of this object.

Returns:

name attribute.

get_signals() list[SignalDescription]

Return a list of signals that can be published by this object.

Returns:

List consisting of qmi_signals attributes.

is_locked() bool

Query if the remote object is locked.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

is_open() bool

Return True if the instrument is open (ready for interaction).

lock(timeout: float = 0.0, lock_token: str | None = None) bool

Lock the remote object. If timeout is given, try every 0.1s within the given timeout value. The remote object can be locked with an optional custom lock token by giving a string into lock_token keyword argument.

If successful, this proxy is the only proxy that can invoke RPC methods on the remote object; other proxies will receive an “object is locked” response. The return value indicates if the lock was granted; a denied lock means the object was already locked by another proxy.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.

release_rpc_object() None

Give a warning if the instrument is removed while still open.

unlock(lock_token: str | None = None) bool

Unlock the remote object.

Without optional parameters, this is only allowed by the proxy that initially locked the object. By giving the lock token as an input parameter, the specific object locked by this token can be unlocked. The return value indicates if the unlocking was successful.

Do not override this stub method in subclasses. It has already been implemented in QMI_RpcProxy.