-
Notifications
You must be signed in to change notification settings - Fork 1
/
interface.py
193 lines (169 loc) · 9.12 KB
/
interface.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
from ipywidgets import interact_manual, FloatText
import ipywidgets as widgets
from graphGeneratorWithDefault import graphRatio
style = {'description_width': 'initial'}
layout_hidden=widgets.Layout(visibility="visible") # visible or hidden
disabled_true = True
distance_min_w = widgets.FloatText(value=0.3, description='Min Distance (m): ', style=style)
distance_max_w = widgets.FloatText(value=0.8, description='Max Distance (m): ', style=style)
mass_w = widgets.FloatText(value=30, description='Robot Mass (lbs): ', style=style)
motor_num_w = FloatText(value=4, description='Number of Motors: ', style=style)
# motor type
motor_type_w = widgets.Dropdown(options=[("AndyMark NeveRest", "nr"),
("CIM", "cim"),
("775pro", "775"),
("other (input all parameters)", "other_m")],
description="Motor Type: ",
value="nr", style=style)
def update_widget_m(w, d):
if motor_type_w.value == "other_m":
w.disabled = False
else:
w.value = d[motor_type_w.value]
w.disabled = True
# motor data from https://motors.vex.com
free_speed_default = {"nr" : 5476, "cim" : 5330, "775" : 18730, "other_m": 1}
no_load_current_default = {"nr" : 0.355, "cim" : 2.7, "775" : 0.7, "other_m": 1}
stall_torque_default = {"nr" : 0.173, "cim" : 2.41, "775" : 0.71, "other_m": 1}
stall_current_default = {"nr" : 9.801, "cim" : 131, "775" : 134, "other_m": 1}
# values whose default are set by motor type
#free speed
free_speed_w = FloatText(value=free_speed_default["nr"], description = '---- Free Speed (rpm): ',
style=style, layout=layout_hidden, disabled=disabled_true)
def update_free_speed(*args):
update_widget_m(free_speed_w, free_speed_default)
motor_type_w.observe(update_free_speed, 'value')
# no load current
no_load_current_w = FloatText(value=no_load_current_default["nr"], description='---- Free Current (Amps): ',
style=style, layout=layout_hidden, disabled=disabled_true)
def update_no_load_current(*args):
update_widget_m(no_load_current_w, no_load_current_default)
motor_type_w.observe(update_no_load_current, 'value')
# stall torque
stall_torque_w = FloatText(value=stall_torque_default["nr"], description='---- Stall Torque (Nm): ',
style=style, layout=layout_hidden, disabled=disabled_true)
def update_stall_torque(*args):
update_widget_m(stall_torque_w, stall_torque_default)
motor_type_w.observe(update_stall_torque, 'value')
# stall current
stall_current_w = FloatText(value=stall_current_default["nr"], description='---- Stall Current (Amps): ',
style=style, layout=layout_hidden, disabled=disabled_true)
def update_stall_current(*args):
update_widget_m(stall_current_w, stall_current_default)
motor_type_w.observe(update_stall_current, 'value')
minRatio_w = FloatText(value=5, description='Minimum Ratio: ', style=style)
maxRatio_w = FloatText(value=40, description='Maximum Ratio: ', style=style)
nominal_voltage_w = FloatText(value=12, description='Motor Nominal Voltage (V): ', style=style)
battery_resistance_w = FloatText(value=0.1, description = 'Battery Internal Resistance (Ohms): ', style=style)
operating_voltage_w = FloatText(value=12.7, description='Operating Voltage (v): ', style=style)
# wheel type
wheel_type_w = widgets.Dropdown(options=[("AndyMark Standard Mecanum 4in", "am_sm4"),
("AndyMark HD Mecanum Wheels 4in", "am_hdm4"),
("AndyMark Duraomni Omniwheel 4in", "am_do4"),
("AndyMark Stealth Wheel 4in", "am_sw4"),
("Nexus Mecanum Wheel 4in", "n_m4"),
("VexPro Mecanum 4in", "vp_m4"),
("VexPro Colson 4/0.85in", "vp_c48"),
("VexPro Colson 4/1.5in", "vp_c415"),
("VexPro Colson 4/1.5in", "vp_c415"),
("VexPro Colson 3.5/1.5in", "vp_c3515"),
("VexPro Colson 3/0.8in", "vp_c38"),
("VexPro Colson 3/1.5in", "vp_c315"),
("VexPro Omni 3.25in", "vp_o325"),
("VexPro Omni 4in", "vp_o4"),
("BaneBot T80 3.75in", "bb_t8375"),
("Others (input all parameters)", "other_w")],
description="Wheel Type: ",
value="am_sm4", style=style)
def update_widget_w(w, d):
if wheel_type_w.value == "other_w":
w.disabled = False
else:
w.value = d[wheel_type_w.value]
w.disabled = True
def compute_inertia(diameter, mass): # gr and inch -> kg and meter
return (0.5 * (mass/1000) * ((diameter/2)*0.0254) * ((diameter/2)*0.0254))
diameter_default = {"am_sm4": 4,
"am_hdm4": 4,
"am_do4": 4,
"am_sw4": 4,
"n_m4": 3.94,
"vp_m4": 4,
"vp_c48": 4,
"vp_c415": 4,
"vp_c3515": 3.5,
"vp_c38": 3,
"vp_c315": 3,
"vp_o325": 3.25,
"vp_o4": 4,
"bb_t8375": 3.75,
"other_w": 4}
wheel_efficiency_default = {"am_sm4" : 0.7,
"am_hdm4": 0.7,
"am_do4": 1,
"am_sw4": 1,
"n_m4": 0.7,
"vp_m4": 0.7,
"vp_c48": 1,
"vp_c415": 1,
"vp_c3515": 1,
"vp_c38": 1,
"vp_c315": 1,
"vp_o325": 1,
"vp_o4": 1,
"bb_t8375": 1,
"other_w": 1}
intertia_default = {"am_sm4" : compute_inertia(4, 158),
"am_hdm4": compute_inertia(4, 400),
"am_do4": compute_inertia(4, 268),
"am_sw4": compute_inertia(4, 108),
"n_m4": compute_inertia(3.94, 400),
"vp_m4": compute_inertia(4, 249),
"vp_c48": compute_inertia(4, 118),
"vp_c415": compute_inertia(4, 240),
"vp_c3515": compute_inertia(3.5, 145),
"vp_c38": compute_inertia(3, 72),
"vp_c315": compute_inertia(3, 150),
"vp_o325": compute_inertia(3.25, 177),
"vp_o4": compute_inertia(4, 236),
"bb_t8375": compute_inertia(3.75, 113),
"other_w": compute_inertia(4, 100)}
diameter_w = FloatText(value=diameter_default["am_sm4"], description='---- Diameter (in): ',
style=style, layout=layout_hidden, disabled=disabled_true)
def update_diameter(*args):
update_widget_w(diameter_w, diameter_default);
wheel_type_w.observe(update_diameter, 'value')
wheel_efficiency_w = FloatText(value=wheel_efficiency_default["am_sm4"], description='---- Efficiency: ',
style=style, layout=layout_hidden, disabled=disabled_true)
def update_wheel_efficiency(*args):
update_widget_w(wheel_efficiency_w, wheel_efficiency_default)
wheel_type_w.observe(update_wheel_efficiency, 'value')
intertia_w = FloatText(value=intertia_default["am_sm4"], description='---- Rotational Inertia (kg m^2): ',
style=style, layout=layout_hidden, disabled=disabled_true)
def update_intertia(*args):
update_widget_w(intertia_w, intertia_default);
wheel_type_w.observe(update_intertia, 'value')
intertia_drivetrain_w = FloatText(value=0, description='---- Add. Drivetrain Inertia (kg m^2): ',
style=style)
interact_manual(graphRatio,
distance_min = distance_min_w,
distance_max = distance_max_w,
mass = mass_w,
motor_num = motor_num_w,
motor_type = motor_type_w,
stall_torque = stall_torque_w,
stall_current = stall_current_w,
free_speed = free_speed_w,
wheel_type = wheel_type_w,
diameter = diameter_w,
inertia = intertia_w,
intertia_drivetrain = intertia_drivetrain_w,
wheel_efficiency = wheel_efficiency_w,
minRatio = minRatio_w,
maxRatio = maxRatio_w,
no_load_current = no_load_current_w,
nominal_voltage = nominal_voltage_w,
batery_resistance = battery_resistance_w,
operating_voltage = operating_voltage_w,
)
print()