|
| 1 | + |
| 2 | + |
| 3 | +# Thermoflex API |
| 4 | + |
| 5 | + |
| 6 | +#### System Requirements |
| 7 | + |
| 8 | +- Python 3.12 or greater |
| 9 | +- Pyserial 3.5 or greater |
| 10 | + |
| 11 | +### Introduction |
| 12 | + |
| 13 | +The Thermoflex muscle is a current activated artificial muscle that is designed to have a low profile usage and simple activation and deactivation sequence. The purpose of this library is 2-fold; to become the working backend of the Delta hardware application and to allow for open-source development of the Nitinol muscle. |
| 14 | + |
| 15 | +### Download and Installation |
| 16 | + |
| 17 | + |
| 18 | +To install our software, you can use the pip and package methods |
| 19 | + |
| 20 | +`pip install thermoflex` |
| 21 | + |
| 22 | +or you can install manually by downloading the files from our Github release page and installing the package with pip. |
| 23 | + |
| 24 | +[Github](https://github.com/Delta-Robotics-Inc/ThermoFlex-Python-API/releases) |
| 25 | + |
| 26 | +### Launch and Use |
| 27 | + |
| 28 | + Import the thermoflex library and use .discover() to find our product. |
| 29 | + |
| 30 | +```python |
| 31 | +import thermoflex as tf |
| 32 | + |
| 33 | +netlist = tf.discover() |
| 34 | +network1 = netlist[0] |
| 35 | +``` |
| 36 | + |
| 37 | +This will return a list of [NodeNet](#nodenet-commands)-objects. Each [NodeNet](#nodenet-commands) contains a list of [Node](#node-commands)-objects connected at initialization as well as a broadcast [Node](#node-commands) and a self [Node](#node-commands) device. From here you will be able to assign nodes to variables using the .getDevice() command. |
| 38 | + |
| 39 | +``` Python |
| 40 | +node0 = network1.node_list[0] |
| 41 | +``` |
| 42 | + |
| 43 | +You can also assign the broadcast node and self node by calling a [NodeNet](#nodenet-commands)'s .broadcast_node and .self_node. |
| 44 | + |
| 45 | +``` Python |
| 46 | +node_b = network1.broadcast_node |
| 47 | +node_s = network1.self_node |
| 48 | +``` |
| 49 | + |
| 50 | +Once you have your connected node bound, you can call its status, reset and logging commands. To use the muscles, you need to create [Muscle](#muscle-commands) objects |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +To create [Muscle](#muscle-commands)-class objects, start by calling tf.muscle(). This is where you need input your *idnum*, *resistance*, *length*, and *diameter* values if you have them. |
| 55 | + |
| 56 | + |
| 57 | +``` Python |
| 58 | +muscle1 = tf.muscle(idnum = 0, resist= 300, diam= 2, length= 150) |
| 59 | +muscle2 = tf.muscle(idnum = 1, resist= 290, diam= 2, length= 145) |
| 60 | +``` |
| 61 | + |
| 62 | +Note that the *idnum* field is the only field that is neccesary for creating the [Muscle](#muscle-commands)-object. |
| 63 | + |
| 64 | +Next, assign the muscle objects to a node object by calling the .setMuscle() command. This command takes the identification number and the muscle object as arguments |
| 65 | + |
| 66 | +```Python |
| 67 | +node0.setMuscle(0, muscle1) |
| 68 | +node0.setMuscle(1, muscle2) |
| 69 | +``` |
| 70 | + |
| 71 | +Sessions are automatically created and create a filesystem that exports to a higher level folder. Sessions track the incoming and outgoing serial data and saves it to a .ses file and a .txt file. The .txt files are generated as plain messages, where as the .ses files have serialized messages. |
| 72 | + |
| 73 | +```Python |
| 74 | +sessionl = tf.Session.sessionl |
| 75 | +session1 = session[0] |
| 76 | +``` |
| 77 | + |
| 78 | +From here, you can add commands to your command buffer. [Node Commands](#node-commands) |
| 79 | + |
| 80 | +These commands should be in the format, |
| 81 | + |
| 82 | +```Python |
| 83 | +node0.enable(muscle1) |
| 84 | +``` |
| 85 | + |
| 86 | +The muscle objects also have their own commands that are passed to their commanding node.[Muscle Commands](#muscle-commands) |
| 87 | + |
| 88 | +Developer install instructions |
| 89 | + |
| 90 | +for testing purposes, use the command |
| 91 | +``` |
| 92 | +pip install -e $SRC |
| 93 | +``` |
| 94 | +with $SRC being the path to the [python-serial](python-serial/) folder. This will install the files as a test library. |
| 95 | + |
| 96 | +## Program Commands |
| 97 | + |
| 98 | +| **Program Commands** | **Function** | |
| 99 | +| --------------------- | ----------------------------------------------------------------------- | |
| 100 | +| discover(*prodid*) | finds connected nodes from the product id (*prodid*) | |
| 101 | +| update() | updates all of the networks | |
| 102 | +| updatenet(*network*) | updates the *network* | |
| 103 | +| delay(*time*) | continuously calls update on all of the networks until *time* is called | |
| 104 | +| endsession(*session*) | Ends and deletes the *session* | |
| 105 | +| endAll() | Ends and deletes all sessions, nodes, and networks | |
| 106 | + |
| 107 | +[Program Glossary](/docs/Thermoflex%20Glossary.md#program) |
| 108 | + |
| 109 | +## NodeNet Commands |
| 110 | + |
| 111 | +| **NodeNet Commands** | **Function** | |
| 112 | +| -------------------- | --------------------------------------------------------------------------------------- | |
| 113 | +| refreshDevices() | updates the status for all devices on a NodeNet | |
| 114 | +| addNode(*nodeid*) | creates a new Node with the given *nodeid* | |
| 115 | +| removeNode(*nodeid*) | removes a Node object with *nodeid* from the given NodeNet's internal node list | |
| 116 | +| getDevice(*nodeid*) | gets the Node object with *nodeid* and attaches it to the NodeNet | |
| 117 | +| openPort() | Opens the port associated with the network, Started upon initialization | |
| 118 | +| closePort() | Closes the port associated with the network | |
| 119 | +| start_serial() | starts the serial loop for sending and receiving commands. started upon initialization. | |
| 120 | + |
| 121 | +[NodeNet Glossary](/docs/Thermoflex%20Glossary.md#nodenet) |
| 122 | + |
| 123 | +## Node Commands |
| 124 | + |
| 125 | +| **Node Commands** | **Function** | |
| 126 | +| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | |
| 127 | +| status() | Checks the status of the node and returns its status | |
| 128 | +| getStatus() | Returns the latest node status received | |
| 129 | +| reset() | Resets at the node level, can be extrapolated to reset the entire network | |
| 130 | +| setLogmode(mode) | Sets the logging mode of the node; mode:(0:'none', 1:'compact', 2:'dump', 3:'readable dump') | |
| 131 | +| setMode(conmode, device) | Sets the input mode of the node; conmode : (percent, volts, amps, ohms, train); device : (all,node,m1,m2,...,m*n*) | |
| 132 | +| setSetpoint(musc, conmode, setpoint) | Sets the point at which the node actuates to; musc: *muscle id number*; conmode : (percent, volts, amps, ohms, train); setpoint : *float* | |
| 133 | +| setMuscle(idnum,muscle) | Assigns a muscle to the node; will have presets in the future | |
| 134 | +| enable(muscle) | Enables the selected muscle to act on the value set by setSetpoint(); enable : (*muscle object*) | |
| 135 | +| enableAll | Enables all connected muscles of the node | |
| 136 | +| disable(muscle) | Disables the selected muscle : (m1,m2,...,m*n*) | |
| 137 | +| disableAll | Disables all connected muscles of the node | |
| 138 | +| update | Sends and receives the packets to "update" the node state | |
| 139 | + |
| 140 | +[Node Glossary](/docs/Thermoflex%20Glossary.md#node) |
| 141 | + |
| 142 | +## Muscle Commands |
| 143 | + |
| 144 | +| **Muscle Command** | **Function** | |
| 145 | +| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | |
| 146 | +| changeMusclemos(*mosfetnum*:int) | Manually changes the mosfet number of the selected muscle. The mosfet number is set automatically when the muscle is assigned to a node; | |
| 147 | +| setMode(conmode) | Sets the data type that a given muscle receives for its setSetpoint() command; conmode : (percent, volts, amps, ohms, train) | |
| 148 | +| setSetpoint(setpoint:float) | Sets the setpoint of the muscle at the node. | |
| 149 | +| setEnable(bool) | Sets the enable status of the muscle in the node. | |
| 150 | + |
| 151 | +[Muscle](/docs/Thermoflex%20Glossary.md#muscle) |
0 commit comments