forked from UM-LoCoLab/NeuroLocoMiddleware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMBLUEmod.py
71 lines (52 loc) · 2.68 KB
/
MBLUEmod.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from GrayDemoCommon import *
# Offers conversions to output torque and position
class Big100NmFutek(ADC):
def __init__(self, csv_file_name=None):
super().__init__(csv_file_name=csv_file_name)
def get_torque(self):
return (self.volts-2.5)*40.
class Small50to1ActPack(ActPacMan):
def __init__(self, devttyACMport, baudRate, csv_file_name=None,
printingRate = 10, updateFreq = 1000, shouldLog = False, shouldAuto = 1):
super().__init__(devttyACMport, baudRate, csv_file_name=csv_file_name,
printingRate = printingRate, updateFreq = updateFreq,
shouldLog = shouldLog, shouldAuto = shouldAuto)
self.K_tau = 0.14 # Nm/A [LeePanRouse2019IROS]
self.gear_ratio = 50
self.R_phase = 3./2.*186e-3 # Ohms [LeePanRouse2019IROS]
def get_nominal_torque(self):
return self.get_current_qaxis()*self.K_tau*self.gear_ratio
def set_nominal_torque(self, torque):
self.des_current = torque/(self.K_tau*self.gear_ratio)
des_voltage = self.R_phase * self.des_current + self.get_phi_dot() * self.K_tau
self.set_voltage_qaxis(des_voltage)
def get_theta(self):
return self.get_phi()/self.gear_ratio
class Big9to1ActPack(ActPacMan):
def __init__(self, devttyACMport, baudRate, csv_file_name=None,
printingRate = 10, updateFreq = 1000, shouldLog = False, shouldAuto = 1):
super().__init__(devttyACMport, baudRate, csv_file_name=csv_file_name,
printingRate = printingRate, updateFreq = updateFreq,
shouldLog = shouldLog, shouldAuto = shouldAuto)
self.K_tau = 0.14 # Nm/A [LeePanRouse2019IROS]
self.R_phase = 3./2.*186e-3 # Ohms [LeePanRouse2019IROS]
self.gear_ratio = 9
def get_nominal_torque(self):
return self.get_current_qaxis()*self.K_tau*self.gear_ratio
def set_nominal_torque(self, torque):
self.des_current = torque/(self.K_tau*self.gear_ratio)
des_voltage = self.R_phase * self.des_current + self.get_phi_dot() * self.K_tau
self.set_voltage_qaxis(des_voltage)
def set_nominal_torque_i(self, torque):
self.des_current = torque/(self.K_tau*self.gear_ratio)
self.set_current_qaxis(self.des_current)
def get_phi_dot(self): # Override!
return self.get_motor_velocity()*np.pi/180.
def get_theta(self):
return self.get_phi()/self.gear_ratio
def get_current_qaxis(self):
return self.get_motor_current() * 1e-3 * .537/np.sqrt(2.)
def get_voltage_qaxis(self):
return self.get_motor_voltage() * 1e-3 * np.sqrt(3./2.)
def set_voltage_qaxis(self, voltage_qaxis):
self.set_voltage(voltage_qaxis/(1e-3 * np.sqrt(3./2.)))