|
1 |
| -''' |
2 |
| -This is a simple example of how to use the ThermoFlex library to control a muscle. |
3 |
| -The ThermoFlex library and install instructions can be found here: |
4 |
| -https://github.com/Delta-Robotics-Inc/TF-Python-Serial |
5 |
| -
|
6 |
| -To run this example, you will need to have a ThermoFlex network set up with at least |
7 |
| -one node connected to a muscle. |
8 |
| -
|
9 |
| -In other words, connect a ThermoFlex Node Controller to your computer via USB, and |
10 |
| -connect a muscle to the Node Controller. For more a complicated newtwork setup using |
11 |
| -multiple nodes connected over CAN, see the other examples in this folder. |
12 |
| -
|
13 |
| -**NOTE: Be ready to hit the left button on the controller to stop the muscle from moving** |
14 |
| -- In the future, a safety feature will be added to prevent the muscle from overheating. |
15 |
| -- This safety feature will utilize the resistance of the muscle to determine if it is overheating. |
16 |
| -- For now, be ready to stop the muscle from moving if it gets too hot. |
17 |
| -''' |
18 |
| -import thermoflex as tf |
19 |
| -import time |
20 |
| - |
21 |
| -node_net = tf.discover([105])[0] # Discover networks over USB and get the first one |
22 |
| - |
23 |
| -node_net.refreshDevices() # Discover all Node devices on the selected network |
24 |
| -time.sleep(1) # Wait for the devices to be discovered |
25 |
| - |
26 |
| -node = node_net.node_list[0] # Get the first connected Node |
27 |
| - |
28 |
| -muscle = tf.Muscle(idnum = 0) # Match idnum to the muscle port number 0=M1, 1=M2 |
29 |
| -node.setMuscle(0, muscle) # Assign the muscle to the Node at port 0 |
30 |
| - |
31 |
| -# Move the Muscle |
32 |
| -muscle.setMode("percent") |
33 |
| -muscle.setSetpoint("percent", 0.1) |
34 |
| -muscle.setEnable(True) |
35 |
| -tf.delay(2) |
36 |
| -muscle.setSetpoint("percent", 0.3) |
37 |
| -tf.delay(2) |
38 |
| -muscle.setSetpoint("percent", 0.4) |
39 |
| -tf.delay(2) |
40 |
| -muscle.setSetpoint("percent", 0.5) |
41 |
| - |
42 |
| -tf.delay(15) # Increase if needed but be careful! There is no safegaurd to prevent the muscle from overheating |
43 |
| - |
44 |
| -node.disableAll() |
45 |
| - |
46 |
| -time.sleep(1) |
47 |
| -tf.endAll() |
48 |
| - |
| 1 | +''' |
| 2 | +This is a simple example of how to use the ThermoFlex library to control a muscle. |
| 3 | +The ThermoFlex library and install instructions can be found here: |
| 4 | +https://github.com/Delta-Robotics-Inc/TF-Python-Serial |
| 5 | +
|
| 6 | +To run this example, you will need to have a ThermoFlex network set up with at least |
| 7 | +one node connected to a muscle. |
| 8 | +
|
| 9 | +In other words, connect a ThermoFlex Node Controller to your computer via USB, and |
| 10 | +connect a muscle to the Node Controller. For more a complicated newtwork setup using |
| 11 | +multiple nodes connected over CAN, see the other examples in this folder. |
| 12 | +
|
| 13 | +**NOTE: Be ready to hit the left button on the controller to stop the muscle from moving** |
| 14 | +- In the future, a safety feature will be added to prevent the muscle from overheating. |
| 15 | +- This safety feature will utilize the resistance of the muscle to determine if it is overheating. |
| 16 | +- For now, be ready to stop the muscle from moving if it gets too hot. |
| 17 | +''' |
| 18 | +import thermoflex as tf |
| 19 | +import time |
| 20 | + |
| 21 | +# tf.set_debug_level("DEBUG") # Use for debug if needed |
| 22 | + |
| 23 | +node_net = tf.discover([105])[0] # Discover networks over USB and get the first one |
| 24 | + |
| 25 | +node_net.refreshDevices() # Discover all Node devices on the selected network |
| 26 | +tf.delay(1) # Wait for the devices to be discovered |
| 27 | + |
| 28 | +node = node_net.node_list[0] # Get the first connected Node |
| 29 | + |
| 30 | +muscle = tf.Muscle(idnum = 0) # Match idnum to the muscle port number 0=M1, 1=M2 |
| 31 | +node.setMuscle(0, muscle) # Assign the muscle to the Node at port 0 |
| 32 | + |
| 33 | +# Move the Muscle |
| 34 | +muscle.setMode("percent") |
| 35 | +muscle.setSetpoint("percent", 0.1) |
| 36 | +muscle.setEnable(True) |
| 37 | +tf.delay(2) |
| 38 | +muscle.setSetpoint("percent", 0.3) |
| 39 | +tf.delay(2) |
| 40 | +muscle.setSetpoint("percent", 0.4) |
| 41 | +tf.delay(2) |
| 42 | +muscle.setSetpoint("percent", 0.5) |
| 43 | + |
| 44 | +tf.delay(4) # Increase if needed but be careful! There is no safegaurd to prevent the muscle from overheating |
| 45 | + |
| 46 | +node.disableAll() |
| 47 | + |
| 48 | +tf.delay(1) |
| 49 | +tf.endAll() |
0 commit comments