Skip to the content.

Documentation

Getting started

Extension graphical user interface

The GUI extension offers the following capabilities:

Details about Slicer integration

SlicerArduino creates a vtkMRMLScriptedModuleNode() and use it for storing data coming from the board. In this way will be possible to take advantage of the notify mechanism already implemented into the vtkMRMLNode. The user has just to observe the node and so it will be possible to execute a custom function when a node parameter changes (because it contains a new valure arrived from the board).

Without this system the data read from Arduino would be almost useless, and the integration/cooperation with the Slicer environment strongly limited.

Receive and send data via python code

Once the device has been connected by using the extension GUI, data can be received and sent via python code. A template class is:

class ArduinoAppTemplate():
  def __init__(self):

    self.ArduinoNode = slicer.mrmlScene.GetFirstNodeByName("arduinoNode")
    sceneModifiedObserverTag = self.ArduinoNode.AddObserver(vtk.vtkCommand.ModifiedEvent, self.doSomethingWhenNewDataIsRead)

  def doSomethingWhenNewDataIsRead(self, caller, event):
    #EXAMPLE TO PRINT THE RECEIVED VALUE:
    print("FIRED! %s" % (self.ArduinoNode.GetParameter("Data")))

  def sendDataToArduino(self, message):
    messageSent = slicer.modules.arduinoconnect.widgetRepresentation().self().logic.sendMessage(message)