General description
The “SerialPortBridgeGeneric” component is used to send data (force, displacement, pressure…) through the usb port. Usally used to send data to an Arduino card to control the real robot.
How to use the component
To learn how to create a SOFA scene, please refer to the tutorial provided by the SOFA Modeler or this documentation.
Here is an example where we use a PythonScriptController to fill the sentData field of the SerialPortBridgeGeneric component:
rootNode.createObject('PythonScriptController', classname="interface", filename="interface/DiamondRobotInterface.py") rootNode.createObject('SerialPortBridgeGeneric', name="serial", port="/dev/ttyACM0", baudRate="115200", size="5", listening="true")
The python script gets each cable displacement and constructs the arrow expected by the Arduino card. This example can be found in the “examples/DiamondRobot” repository of the plugin.
Data field
Input data
port : Serial port name.
baudRate : Transmission speed.
sentData : Data to send.
size : Size of the arrow to send. Allows to control the size of the input data. Useful when sentData is filled by a python interface.
precise : If true, will send the data in the format [MSB,LSB]*size
Output data
No output data