8000 custom elements back in · hzyjerry/robotics-toolbox-python@cfa4563 · GitHub
[go: up one dir, main page]

Skip to content

Commit cfa4563

Browse files
committed
custom elements back in
1 parent 46c56c9 commit cfa4563

File tree

2 files changed

+269
-82
lines changed

2 files changed

+269
-82
lines changed

examples/swift2.py

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,64 @@
108108
# k.base = sm.SE3(0.7, 1, 0) * sm.SE3.Rz(np.pi/2)
109109
# env.add(k)
110110

111-
env = Swift.Swift()
111+
env = Swift.Swift(_dev=True)
112112
env.launch()
113113

114114

115+
def slidercb(e):
116+
print(e)
117+
118+
119+
def selectcb(e):
120+
print(e)
121+
122+
123+
def checkcb(e):
124+
print(e)
125+
# select.value = e
126+
127+
128+
label = Swift.Label('Demo')
129+
slider = Swift.Slider(slidercb, 10, 95, 5, 15, 'slider this is', ' d')
130+
select = Swift.Select(selectcb, 'selec', [
131+
'on', 'tw', 'three'], 2)
132+
133+
check = Swift.Checkbox(checkcb, 'checkbox', [
134+
'on', 'tw', 'three'], [False, True, True])
135+
136+
137+
def buttoncb(e):
138+
print('BUTTON')
139+
# check.checked = [True, True, False]
140+
# check.desc = 'new desc'
141+
slider.value = 60
142+
143+
144+
button = Swift.Button(buttoncb, 'button')
145+
146+
147+
def radiocb(e):
148+
print(e)
149+
select.value = e
150+
151+
152+
radio = Swift.Radio(radiocb, 'radio', [
153+
'on', 'tw', 'three'], 2)
154+
155+
# env.add(label)
156+
# env.add(slider)
157+
# env.add(button)
158+
# env.add(select)
159+
# env.add(radio)
160+
# env.add(check)
161+
162+
# while True:
163+
# env.step(0.05)
164+
# time.sleep(0.001)
165+
166+
# env.hold()
167+
168+
115169
panda = rtb.models.Panda()
116170
panda.q = panda.qr
117171
# panda.base = sm.SE3(1.2, 1, 0) * sm.SE3.Rz(np.pi/2)
@@ -120,7 +174,7 @@
120174

121175
ev = [0.01, 0, 0, 0, 0, 0]
122176
panda.qd = np.linalg.pinv(panda.jacob0(panda.q, fast=True)) @ ev
123-
env.step(0.01)
177+
env.step(0.001)
124178

125179

126180
def stepper():
@@ -130,9 +184,42 @@ def stepper():
130184
env.step(0.001)
131185

132186

133-
cProfile.run('stepper()')
187+
# box = rtb.Box([0.8, 0.1, 0.1])
188+
# env.add(box)
189+
190+
# stepper()
191+
# env.remove(panda)
192+
193+
194+
# r = rtb.models.LBR()
195+
# r.q = r.qr
196+
# r.qd = [0.01, 0.01, 0.01, 0, 0, 0, 0]
197+
# env.add(r)
198+
# for i in range(10000):
199+
# panda.qd = np.linalg.pinv(panda.jacob0(panda.q, fast=True)) @ ev
200+
# env.step(0.001)
201+
202+
# # env.remove(box)
203+
# cProfile.run('stepper()')
204+
205+
# env._run_thread = False
206+
# env.restart()
207+
208+
# r = rtb.models.LBR()
209+
# r.q = r.qr
210+
# r.qd = [0.01, 0.01, 0.01, 0, 0, 0, 0]
211+
# env.add(r)
212+
# for i in range(1000000):
213+
# panda.qd = np.linalg.pinv(panda.jacob0(panda.q, fast=True)) @ ev
214+
# env.step(0.001)
215+
216+
# env.reset()
217+
# env.add(r)
218+
# env.close()
219+
220+
# cProfile.run('stepper()')
134221

135222
# print(panda.fkine(panda.q))
136223
# print(panda.fkine_fast(panda.q))
137224

138-
# env.hold()
225+
env.hold()

0 commit comments

Comments
 (0)
0