brace.example.zaber package

Submodules

brace.example.zaber.ArduinoADCInterface module

class brace.example.zaber.ArduinoADCInterface.LoadCellInterface(serialPort: str)[source]

Bases: IInputCom

This class is the input interface for the Arduino that gets the load cell voltage from the Serial interface.

isComOn() bool[source]

Returns whether or not this communications interface is considered on.

Returns:

Whether this communication is on.

Return type:

bool

printLoadCellValue() float[source]

Gets the load cell voltage by parsing in the Serial message

Returns:

The floating-point voltage read in by the Arduino.

Return type:

float

readValue(ser: Serial) float[source]

Gets the one channel voltage from the Arduino by serial command.

Parameters:

serial (serial.Serial) – The Serial class that is communicating through USB.

Returns:

The voltage value read from the Arduino ADC.

Return type:

float

turnOnOffComm(enable: bool) bool[source]

Enables and disables the state of this interface.

Parameters:

enable (bool) – Enables or disables this serial interface

Returns:

Whether or not enabling or disable was successful.

Return type:

bool

brace.example.zaber.ConfiguredProportionalPlots module

class brace.example.zaber.ConfiguredProportionalPlots.ProportionalPlotsPyQt(graphicsLayoutWidget: GraphicsLayoutWidget, **kwargs)[source]

Bases: PyQTBasePlot

createGraphContext(proportionalGraphToggleHorizontalLayout: QHBoxLayout, proportionalGraphWidget: GraphicsLayoutWidget, MAX_TIME_RANGE: float, *_: list)[source]

Factory Function to create graph context (and plots) for the Proportional plots with pyqtgraph. Returns the index of the graph context.

Params graphContexts:

The list of GraphContexts to be used in the plots.

Params proportionalGraphToggleHorizontalLayout:

The Horizontal Layout to populate the checkboxes for hiding the graphs.

Params proportionalGraphWidget:

The widget that contains the graphs.

Params MAX_TIME_RANGE:

The time range that the graph should show on the x-axis.

Returns:

The index of the graph context.

Return type:

int

resetProportionalPlotAxis(xGraphLim: int) None[source]

Resets the plots back to a given view.

Parameters:
  • axes (numpy.ndarray[PlotItem]) – Set of PlotItems whose plots should be altered.

  • xGraphLim (int) – Initialized limit of the X-axis value.

Returns:

None

Return type:

None

brace.example.zaber.MainWindow module

exception brace.example.zaber.MainWindow.UnableToTurnOnError[source]

Bases: BaseException

Raised when unable to turn on controller.

class brace.example.zaber.MainWindow.ZaberMainWindow(app: QApplication, textBrowserHandler: TextBrowserHandler, *args, **kwargs)[source]

Bases: QMainWindow, Ui_ZaberWindow

Main GUI for the Mechanical Actuation for Unpleasant Stimulus (MAUS) device This class handles the main functionality for the GUI elements.

MQTT_REMOTE_TOPIC = 'remotecommands/command'
changeGraphContext(configurationPageIndex: int) None[source]

Changes the graph context to a different one provided that it exists. This should happen when the configuration tab is set to a different control logic tab.

Parameters:

configurationPageIndex (int) – The index of the configuration page that is to be changed into.

Returns:

None

Return type:

None

checkButtonPress() None[source]

Callback to display that the synchronization trigger has been pressed. :return: None :rtype: None

closeEvent(event)[source]

Runs shutdown callbacks when the X is pressed on the GUI. Turns off the robot and stops streaming from the remote.

configurationSingleWidgetNamePrefixes = []
configurationWidgetNamePrefixes = []
connectToRemoteManager() None[source]

Connects to the remote by first connecting to the MQTT server, and attempting an initial heartbeat to determine whether the server on the remote is on and ready.

Returns:

None

Return type:

None

getConfigurationParametersFromGUI() dict[str, Any][source]

Gets the values from the GUI and places the values into a dictionary. Currently only Spinboxes and Comboboxes are supported

Returns:

Dictionary containing the field names and their values.

Return type:

dict[str, Any]

handleDisconnection() None[source]

Returns some of the widgets back to an initial state if the disconnection happens. The user should not be able to stream or enable actuation on disconnection.

Returns:

None

Return type:

None

heartbeat() None[source]

Runs the actual heartbeat command. A successful heartbeat returns “ACK” as a response to the “SYN” message received.

Returns:

None

Return type:

None

invertPosition() None[source]

Inverts the retraction/extension actuation convention on the remote side.

Returns:

None

Return type:

None

onMessage(client: Client, userdata, msg: MQTTMessage)[source]
readControllerConfiguration() None[source]

Reads the configuration from the remote then reads it into the GUI fields.

Returns:

bool

Return type:

bool

readControllerConfigurationRemote(controlLogicType: ControlLogic, formatForConfiguration: bool) dict[str, Any][source]

Reads the configuration from the remote.

Parameters:
  • controlLogicType (ControlLogic) – The enum that should be changed.

  • formatForConfiguration (bool) – Whether the configuration should be formatted for a save file.

Returns:

The configuration parameters from the remote.

Return type:

dict[str, Any]

resetAllGraphLimits() None[source]

Resets all the graphs to specific x and y-axis limits given by the graph context’s function.

Returns:

None

Return type:

None

runCalibration() None[source]

Runs the calibration of the robot to zero the loadcell voltage to the current offset value. Subsequent measurements have this offset value subtracted.

Returns:

None

Return type:

None

sendRemoteCommand(sentFunction: str, sentParameters: dict[str, Any], logComment: bool = True) Any[source]

Publishes the command to the remote through MQTT, then waits for a response.

Parameters:
  • sentFunction (str) – The RPC function that should be executed.

  • sentParameters (dict[str, Any]) – The parameters for the RPC function that should be executed with.

  • logComment (bool) – Whether the remote command should be logged.

Returns:

The return value from the RPC.

Return type:

Any

showBottomRowLabel(axes: ndarray[PlotItem]) None[source]

Shows the bottom axis (time axis) of the last axis that is displayed on the graph.

Parameters:

axes (numpy.ndarray[PlotItem]) – A array of PlotItems representing the plots that were generated for this widget.

Returns:

None

Return type:

None

staticMetaObject = PySide6.QtCore.QMetaObject("ZaberMainWindow" inherits "QMainWindow": Methods:   #39 type=Signal, signature=triggerPressSignal()   #40 type=Slot, signature=connectToRemoteManager()   #41 type=Slot, signature=invertPosition()   #42 type=Slot, signature=timedHeartbeat()   #43 type=Slot, signature=checkButtonPress()   #44 type=Slot, signature=readControllerConfiguration()   #45 type=Slot, signature=runCalibration()   #46 type=Slot, signature=changeGraphContext()   #47 type=Slot, signature=writeChangesToExoController()   #48 type=Slot, signature=warnSixMinuteStream()   #49 type=Slot, signature=toggleStreaming(bool), parameters=bool   #50 type=Slot, signature=toggleActuation() )
stopDrawing() None[source]

Stops the drawing from the animatedGraphManager (stops taking messages).

Returns:

None

Return type:

None

timedHeartbeat() None[source]

Runs a heartbeat with 2 retries to determine whether the remote is reachable and able to take commands. 2 failures indicates disconnection.

Returns:

None

Return type:

None

toggleActuation(isChecked: bool) None[source]

Toggles actuation in the remote to start output movement.

Parameters:

isChecked (bool) – Whether the “Enable Actuation” button has been checked to start actuation.

Returns:

None

Return type:

None

toggleDisabledConfigurationWidgets(disabled: bool) None[source]

Toggles the configuration of the widgets for the ones that are inactive when not connected to the remote.

Parameters:

disabled (bool) – Whether the widgets should be disabled or enabled.

Returns:

None

Return type:

None

toggleStreaming(isChecked: bool) None[source]

Enables the data streaming on the remote. Configuration widgets are disabled during this time to prevent unintentional changes.

Parameters:

isChecked (bool) – Whether the streaming button has been checked to start streaming.

Returns:

None

Return type:

None

toggleWidgetsWhenConnected(disabled: bool) None[source]

The widgets that are enabled on successful connection.

Parameters:

disabled (bool) – Whether the widgets should be enabled or disabled.

Returns:

None

Return type:

None

triggerPressSignal
warnSixMinuteStream() None[source]

Callback that warns the user that the stream has been run for at least 6 minutes with red bolded text in the textbox.

Returns:

None

Return type:

None

writeChangesToExoController() None[source]

Writes the changes of the current graph context to the remote. Changes will only be propagated if validated properly.

Returns:

None

Return type:

None

brace.example.zaber.MainWindow.onConnect(client, userdata, flags, reason_code, properties)[source]

brace.example.zaber.ProportionalUIConfiguration module

brace.example.zaber.ProportionalUIConfiguration.adjustProportionalPlotThresholdValues() None[source]

Not defined. No thresholds are defined in this example.

brace.example.zaber.ProportionalUIConfiguration.getProportionalConfigurationChanges(parent: ZaberMainWindow) dict[str, Any][source]

Gets the configuration in the GUI for this controller.

Parameters:

parent (ZaberMainWindow) – The main GUI where this function is being called.

Returns:

Dictionary containing the configuration values.

Return type:

dict[str, Any]

brace.example.zaber.ProportionalUIConfiguration.readProportionalConfigurationFromController(parent: ZaberMainWindow, configuration: dict[str, Any]) None[source]

Reads remote configuration values into the GUI fields.

Parameters:
  • parent (ZaberMainWindow) – The main GUI where this function is being called.

  • configuration (dict[str, Any]) – The configuration from the remote GUI.

Returns:

None

Return type:

None

brace.example.zaber.ProportionalUIConfiguration.readProportionalConfigurationFromSaveFile() None[source]

Not defined. No configuration is read from a save file in this example.

brace.example.zaber.ProportionalUIConfiguration.validateProportionalConfiguration(configuration: dict[str, Any]) bool[source]

Validates the configuration from the GUI before sending to the remote.

Parameters:

configuration (dict[str, Any]) – Configuration from the GUI that should be checked for errors.

Returns:

True if validated correctly, False otherwise

Return type:

bool

brace.example.zaber.ProportionalUIConfiguration.writeProportionalConfigurationChanges(parent: ZaberMainWindow, configurationChanges: dict[str, Any]) None[source]

Writes the control logic parameter values to the remote.

Parameters:
  • parent (ZaberMainWindow) – The main GUI where this function is being called.

  • configurationChanges (dict[str, Any]) – The dictionary of parameters that should be overridden in the remote.

Returns:

None

Return type:

None

brace.example.zaber.ZaberControlLogic module

class brace.example.zaber.ZaberControlLogic.ControlLogic[source]

Bases: object

ZaberController = 0
class brace.example.zaber.ZaberControlLogic.ZaberControlLogic(index: int)[source]

Bases: IControlLogic

DataClass

alias of ZaberData

exportMeasurementData(measurementLists: ZaberMeasurementLists, index: int, isActive: bool) dict[str, float | int][source]

Exports the MeasurementData for this cycle.

Parameters:
  • measurementLists (ZaberMeasurementLists) – The measurement lists for this robot whose data should be exported.

  • index (int) – The current index of this robot.

  • isActive (bool) – Whether or not this robot is active (or enabled). If disabled, should return NaN maps.

Returns:

A mapping of the attributes and the values for this current iteration.

Return type:

dict[str, float | int]

getConfigurationParameters(formatForConfiguration: bool) dict[str, float | dict][source]

Gets the current configuration parameters that were defined for this controller.

Parameters:

formatForConfiguration (bool) – Whether or not this should be formatted for file saving.

Returns:

Dictionary of parameters in this object.

Return type:

dict[str, float]

getDesiredOutputValues(enable: bool, timeData: deque[float], deltaTime: float, currentCycleMeasurementLists: list[ZaberMeasurementLists]) list[float][source]

Transforms the output values through a proportional response. Increased load cell response leads to increased actuation.

Parameters:
  • enable (bool) – Whether or not device is active and running.

  • timeData (deque[float]) – The time data for the the last set of cycles (the time values in s).

  • deltaTime (float) – The amount of time between this iteration and the last iteration.

  • currentCycleMeasurementLists (list[ZaberMeasurementLists]) – The set of ZaberMeasurementList that can be accessed to determine the output response.

Returns:

The list of output responses that should be run against the actuators.

Return type:

list[float]

setParameters(parameters: dict[str, float]) None[source]

Sets the parameters that are in the dictionary to the instance variables of this object.

Parameters:

parameters (dict[str, float]) – The dictionary of configuration values from a remote procedure call.

Returns:

None

Return type:

Nones

setup(**kwargs) None[source]

Initializes anything prior to running. :param kwargs: Keyword arguments :type kwargs: dict[str, All] :return: None :rtype: None

class brace.example.zaber.ZaberControlLogic.ZaberData(position, loadcell, t)[source]

Bases: NamedTuple

loadcell: float

Alias for field number 1

position: float

Alias for field number 0

t: float

Alias for field number 2

brace.example.zaber.ZaberInterface module

class brace.example.zaber.ZaberInterface.ZaberInterface(serialPort: str, axisNum: int)[source]

Bases: IInputCom, IOutputCom

The input and output nterface that reads input and writes output to the Zaber X-MCC.

isComOn() bool[source]

Returns whether or not this serial interface is enabled or disabled.

Returns:

Whether the serial interface is active.

Return type:

bool

printPosition() float | None[source]

Gets the position of the actuator in millimeters as a sensor input.

Returns:

The current actuator position for this axis.

Return type:

float

sendOutput(position: float) None[source]

Moves the position of the actuator in absolute values. This does not wait for the actuator to reach the final position before the next cycle is performed.

Parameters:

position (float) – The position after checks that should be input to the actuator.

Returns:

None

Return type:

None

turnOnOffComm(enable: bool) bool[source]

Enable or disables this interface during usage.

Parameters:

enable (bool) – Enables the device communication if true, disables if false.

Returns:

Whether or not this communication was successfully enabled or disabled.

Return type:

bool

brace.example.zaber.ZaberMeasurementList module

class brace.example.zaber.ZaberMeasurementList.ZaberMeasurementLists[source]

Bases: IMeasurementLists

Set of measurement lists that contains the sensor information for the mechanosensitive measurement device.

MAX_LEN = 15000
getLoadCellMeasurements() deque[float][source]

Gets the Load cell measurements from this deque. Measurements are rotated out after maximum capacity is hit.

Returns:

The load cell measurements (gf) from a deque.

Return type:

collections.deque[float]

getPosMeasurements() deque[float][source]

Gets the position measurements from this deque. Measurements are rotated out after maximum capacity is hit.

Returns:

The position measurements from a deque.

Return type:

collections.deque[float]

readMeasurements(inputComs: list[IInputCom]) tuple[float, float][source]

Reads the measurements from the list of input communications; getting the current actuator position from the Zaber actuator and the load cell value from the Arduino.

Parameters:

inputComs (list[IInputComs]) – The input communications interfaces used in this device.

Returns:

Tuple of values containing the current position and the load cell voltage.

Return type:

tuple[float, float]

recordOutputValues(outputDes: list[float], outputIn: list[float]) None[source]

Gets the output position values and stores them into the lists.

Parameters:
  • outputDes (list[float]) – The output position before any safety checks to be recorded.

  • outputIn (list[float]) – The output position after safety checks to be recorded.

Returns:

None

Return type:

None

runMeasurements(deltaTimeAll: list[float], inputComs: list[IInputCom]) None[source]

Gets the measurement, appends the values to the appropriate lists, also converts the load cell values to proper gram-force measurements.

Parameters:
  • deltaTimeAll (list[float]) – The list of times in between iteration cycles.

  • inputComs (list[IInputComs]) – The input communications interfaces used in this device.

Returns:

None

Return type:

None

setCalibrationOffset(inputComs: list[IInputCom]) None[source]

Sets a calibration value based on the current loadcell voltage that is measured at the instantaneous point in time.

Parameters:

inputComs (list[IInputComs]) – The input communications interfaces used in this device.

Returns:

None

Return type:

None

setupMeasurements(inputComs: list[IInputCom]) None[source]

Sets up the initial measurements at the beginning; avoids off-by-one error issues.

Parameters:

inputComs (list[IInputComs]) – The input communications interfaces used in this device.

Returns:

None

Return type:

None

brace.example.zaber.ZaberServerSide module

brace.example.zaber.ZaberServerSide.createControlLogics() dict[ControlLogic, IControlLogic][source]

Factory method for the control logic, creating a lambda that takes in the index for the single control law defined for this case.

Returns:

A dictionary containing the enum and the control logic defined.

Return type:

dict[Zaber.ControlLogic, IControlLogic]

brace.example.zaber.ZaberServerSide.handleException(excType, excValue, excTraceback)[source]
brace.example.zaber.ZaberServerSide.main()[source]
brace.example.zaber.ZaberServerSide.query_com() bidict[str, str][source]

Generates dictionary of available serial ports and their description

Returns:

Dictionary of available serial ports and descriptions

Return type:

dict[str, str]

brace.example.zaber.ZaberTransform module

class brace.example.zaber.ZaberTransform.ZaberTransform(invert: bool)[source]

Bases: ISafetyControl

static capPosition(positionIn: float, positionMaxValue: float, positionMinValue: float) float[source]

Caps the position of the actuator to the constrains, 0 and maximum 30.

Parameters:
  • positionIn (float) – The position to cap.

  • positionMaxValue (float) – The maximum position value

  • positionMinValue (float) – The minimum position value.

runOutputConversion(outputIn: list[float]) list[Any][source]

Converts the position to the desired form, inverting it as necessary.

Parameters:

outputIn (list[float]) – The raw output positions before any conversion.

Returns:

The converted values of the position

Return type:

list[Any]

runSafetyControl(measurementLists: ZaberMeasurementLists, deltaTimeAll: list[float], posDes: list[float]) list[float][source]

This runs the safety control, slewing the actuator to prevent overexceeding limits, and also caps the position of the actuator.

Parameters:
  • measurementLists (ZaberMeasurementLists) – The measured values in this robot.

  • deltaTimeAll (list[float]) – The list of times in between iterations.

  • posDes (list[float]) – The previous positions that this actuator has gone through.

Returns:

A list of actuator positions (in case of one, only one is in the list)

Return type:

list[float]

setExtActuationConvention(extTorquePositive: bool) None[source]

Inverts the actuation direction. Toggles between most extended is considered zero and the most retracted position being considered zero.

Parameters:

extTorquePositive (bool) – Toggles the invert position.

Returns:

None

Return type:

None

brace.example.zaber.ZaberWindow module

class brace.example.zaber.ZaberWindow.Ui_ZaberWindow[source]

Bases: object

retranslateUi(ZaberWindow)[source]
setupUi(ZaberWindow)[source]

brace.example.zaber.zaberMain module

brace.example.zaber.zaberMain.handleException(excType, excValue, excTraceback)[source]
brace.example.zaber.zaberMain.main()[source]

Module contents