The Thermoflex muscle is a current activated artificial muscle that is designed to have a low profile and simple activation and deactivation sequence. The purpose of this library is provide a universal python API for communicating with and directing ThermoFlex Node devices over USB and pyserial
.
To install our software, the most common method is through pip:
pip install thermoflex
You can install manually by downloading the files from our Github release page and installing the package with pip.
You can also install manually by cloning this repository and running the following commands. This is good if you want to contribute to the library or work with an older/prototype version.,
git clone https://github.com/Delta-Robotics-Inc/ThermoFlex-Python-API
cd ThermoFlex-Python-API
pip install .\python-serial\ # Use for normal installation (not for development)
pip install --editable .\python-serial\ # OR Install for developement (changes made to repository source code reflects in your `thermoflex` package
Import the thermoflex library and use .discover() to find our product.
import thermoflex as tf
netlist = tf.discover()
network1 = netlist[0]
This will return a list of NodeNet-objects. Each NodeNet contains a list of Node-objects connected at initialization as well as a broadcast Node and a self Node device. From here you will be able to assign nodes to variables using the .getDevice() command.
node0 = network1.node_list[0]
You can also assign the broadcast node and self node by calling a NodeNet's .broadcast_node and .self_node.
node_b = network1.broadcast_node
node_s = network1.self_node
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 objects
To create Muscle-class objects, start by calling tf.muscle(). Input the "idnum" which is the port on the Node controller that the muscle is plugged into.
muscle1 = tf.muscle(idnum = 0)
muscle2 = tf.muscle(idnum = 1)
Next, assign the muscle objects to a node object by calling the .setMuscle() command. This command takes the port number and the muscle object as arguments
node0.setMuscle(0, muscle1)
node0.setMuscle(1, muscle2)
These commands should be in the following format, either referencing a Muscle
object or a Node
object:
node0.enable(muscle1)
# or
muscle1.enable()
Full list of Muscle Commands: Muscle Commands
Program Function | Description |
---|---|
discover(prodid) | finds connected nodes from the product id (prodid) |
update() | updates all of the networks |
updatenet(network) | updates the network |
delay(time) | continuously calls update on all of the networks until time is called |
endsession(session) | Ends and deletes the session |
endAll() | Ends and deletes all sessions, nodes, and networks |
NodeNet Commands | Function |
---|---|
refreshDevices() | updates the status for all devices on a NodeNet |
addNode(nodeid) | creates a new Node with the given nodeid |
removeNode(nodeid) | removes a Node object with nodeid from the given NodeNet's internal node list |
getDevice(nodeid) | gets the Node object with nodeid and attaches it to the NodeNet |
openPort() | Opens the port associated with the network, Started upon initialization |
closePort() | Closes the port associated with the network |
start_serial() | starts the serial loop for sending and receiving commands. started upon initialization. |
Node Commands | Function |
---|---|
status() | Checks the status of the node and returns its status |
getStatus() | Returns the latest node status received |
reset() | Resets at the node level, can be extrapolated to reset the entire network |
setLogmode(mode) | Sets the logging mode of the node; mode:(0:'none', 1:'compact', 2:'dump', 3:'readable dump') |
setMode(conmode, device) | Sets the input mode of the node; conmode : (percent, volts, amps, ohms, train); device : (all,node,m1,m2,...,mn) |
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 |
setMuscle(idnum,muscle) | Assigns a muscle to the node; will have presets in the future |
enable(muscle) | Enables the selected muscle to act on the value set by setSetpoint(); enable : (muscle object) |
enableAll | Enables all connected muscles of the node |
disable(muscle) | Disables the selected muscle : (m1,m2,...,mn) |
disableAll | Disables all connected muscles of the node |
update | Sends and receives the packets to "update" the node state |
Muscle Command | Function |
---|---|
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; |
setMode(conmode) | Sets the data type that a given muscle receives for its setSetpoint() command; conmode : (percent, volts, amps, ohms, train) |
setSetpoint(setpoint:float) | Sets the setpoint of the muscle at the node. |
setEnable(bool) | Sets the enable status of the muscle in the node. |