forked from thomasfla/solopython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_solo12.py
44 lines (35 loc) · 1.58 KB
/
main_solo12.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# coding: utf8
import argparse
import math
from time import clock, sleep
from utils.slider_box import SliderBox
from solo12 import Solo12
def example_script(name_interface):
slider_box = SliderBox()
device = Solo12(name_interface,dt=0.001)
nb_motors = device.nb_motors
device.init(calibrateEncoders=True)
#CONTROL LOOP ***************************************************
while ((not device.hardware.IsTimeout()) and (clock() < 200) and not slider_box.get_e_stop()):
device.UpdateMeasurment()
device.SetDesiredJointTorque([0]*nb_motors)
device.SendCommand(WaitEndOfCycle=True)
if ((device.cpt % 100) == 0):
device.Print()
#****************************************************************
# Whatever happened we send 0 torques to the motors.
device.SetDesiredJointTorque([0]*nb_motors)
device.SendCommand(WaitEndOfCycle=True)
if device.hardware.IsTimeout():
print("Masterboard timeout detected.")
print("Either the masterboard has been shut down or there has been a connection issue with the cable/wifi.")
device.hardware.Stop() # Shut down the interface between the computer and the master board
def main():
parser = argparse.ArgumentParser(description='Example masterboard use in python.')
parser.add_argument('-i',
'--interface',
required=True,
help='Name of the interface (use ifconfig in a terminal), for instance "enp1s0"')
example_script(parser.parse_args().interface)
if __name__ == "__main__":
main()