Skip to content

Commit 5a78b88

Browse files
committed
Added generic robot
1 parent db546cb commit 5a78b88

File tree

4 files changed

+173
-10
lines changed

4 files changed

+173
-10
lines changed

examples/plot.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
# Plot the joint trajectory with a 50ms delay between configurations
1919
# panda.plot(q=q, backend='pyplot', dt=0.050, vellipse=True, fellipse=True)
2020
panda.plot(q=q, backend='pyplot', dt=0.050, vellipse=False, fellipse=False)
21-
# # q = panda.qr
21+
22+
# r = rp.models.ETS.GenericSeven()
23+
24+
# q = r.qr
2225

2326
# env = rp.backends.PyPlot()
2427
# env.launch()
2528

26-
# env.add(panda)
27-
# print(panda)
29+
# env.add(r)
30+
# print(r)
2831

2932
# env.hold()

examples/swifty.py

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
import numpy as np
99
import numpy.testing as nt
1010

11+
import matplotlib
12+
import matplotlib.pyplot as plt
13+
14+
matplotlib.rcParams['pdf.fonttype'] = 42
15+
matplotlib.rcParams['ps.fonttype'] = 42
16+
plt.style.use('ggplot')
17+
matplotlib.rcParams['font.size'] = 4.5
18+
matplotlib.rcParams['lines.linewidth'] = 0.5
19+
matplotlib.rcParams['xtick.major.size'] = 1.5
20+
matplotlib.rcParams['ytick.major.size'] = 1.5
21+
matplotlib.rcParams['axes.labelpad'] = 1
22+
plt.rc('grid', linestyle="-", color='#dbdbdb')
23+
1124
# Launch the simulator Swift
1225
# env = rtb.backends.Swift()
1326
# env.launch()
@@ -76,15 +89,15 @@
7689
# env.add(r)
7790
# env.hold()
7891

79-
r = rtb.models.ETS.Panda()
80-
r.q = r.qr
92+
# r = rtb.models.ETS.Panda()
93+
# r.q = r.qr
8194

82-
q2 = [1, 2, -1, -2, 1, 1, 2]
83-
Tep = r.fkine(q2)
84-
Tep = sm.SE3(0.7, 0.2, 0.1) * sm.SE3.OA([0, 1, 0], [0, 0, -1])
95+
# q2 = [1, 2, -1, -2, 1, 1, 2]
96+
# Tep = r.fkine(q2)
97+
# Tep = sm.SE3(0.7, 0.2, 0.1) * sm.SE3.OA([0, 1, 0], [0, 0, -1])
8598

86-
import cProfile
87-
cProfile.run('qp = r.ikine_mmc(Tep)')
99+
# import cProfile
100+
# cProfile.run('qp = r.ikine_mmc(Tep)')
88101

89102

90103

@@ -160,3 +173,64 @@
160173

161174
# import cProfile
162175
# cProfile.run('runner()')
176+
177+
178+
fig, ax = plt.subplots()
179+
fig.set_size_inches(8, 8)
180+
181+
ax.set(xlabel='Manipulability', ylabel='Condition')
182+
ax.grid()
183+
plt.grid(True)
184+
# ax.set_xlim(xmin=0, xmax=3.1)
185+
# ax.set_ylim(ymin=0, ymax=0.11)
186+
187+
plt.ion()
188+
plt.show()
189+
190+
rng = np.random.default_rng(1)
191+
r = rtb.models.ETS.GenericSeven()
192+
193+
194+
def randn(a, b, size):
195+
return (b - a) * rng.random(size) + a
196+
197+
198+
def rand_q():
199+
return randn(np.pi / 2, -np.pi / 2, (7,))
200+
201+
202+
def rand_v():
203+
# return randn(0, 1, (6,))
204+
return np.array([0.1, 0.1, 0.1, 0.0, 0.0, 0.0])
205+
206+
207+
for i in range(100000):
208+
209+
q = rand_q()
210+
v = rand_v()
211+
212+
J = r.jacob0(q)
213+
cond = np.linalg.cond(J[:3, :])
214+
m = r.manipulability(J=J, axes='trans')
215+
216+
qd = np.linalg.pinv(J) @ v
217+
218+
print(np.linalg.norm(np.abs(qd)))
219+
220+
qd_norm = np.linalg.norm(np.abs(qd))
221+
222+
223+
# if cond > 1000:
224+
# print(np.round(q, 2), np.round(cond), np.round(r.manipulability(q), 3))
225+
226+
# ax.plot(m, np.log10(cond), 'o', color='black')
227+
ax.plot(m, np.log10(qd_norm), 'o', color='black')
228+
# ax.plot(1, 0.002, 'o', color='black')
229+
plt.pause(0.001)
230+
231+
# if m > 3 and cond > 30:
232+
# print(np.round(q, 2), np.round(cond), np.round(m, 3))
233+
234+
235+
plt.ioff()
236+
plt.show()
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env python
2+
3+
import numpy as np
4+
from roboticstoolbox.robot.ETS import ETS
5+
from roboticstoolbox.robot.ERobot import ERobot
6+
from roboticstoolbox.robot.ELink import ELink
7+
8+
9+
class GenericSeven(ERobot):
10+
"""
11+
Create model of a generic seven degree-of-freedom robot
12+
13+
robot = GenericSeven() creates a robot object. This robot is represented
14+
using the elementary transform sequence (ETS).
15+
16+
"""
17+
def __init__(self):
18+
19+
deg = np.pi/180
20+
mm = 1e-3
21+
tool_offset = (103)*mm
22+
23+
link_length = 0.5
24+
25+
l0 = ELink(
26+
ETS.tz(link_length) * ETS.rz(),
27+
name='link0',
28+
parent=None
29+
)
30+
31+
l1 = ELink(
32+
ETS.ry(),
33+
name='link1',
34+
parent=l0
35+
)
36+
37+
l2 = ELink(
38+
ETS.tz(link_length) * ETS.rz(),
39+
name='link2',
40+
parent=l1
41+
)
42+
43+
l3 = ELink(
44+
ETS.ry(),
45+
name='link3',
46+
parent=l2
47+
)
48+
49+
l4 = ELink(
50+
ETS.tz(link_length) * ETS.rz(),
51+
name='link4',
52+
parent=l3
53+
)
54+
55+
l5 = ELink(
56+
ETS.ry(),
57+
name='link5',
58+
parent=l4
59+
)
60+
61+
l6 = ELink(
62+
ETS.tx(link_length) * ETS.rz(),
63+
name='link6',
64+
parent=l5
65+
)
66+
67+
ee = ELink(
68+
ETS.tz(-link_length),
69+
name='ee',
70+
parent=l6
71+
)
72+
73+
elinks = [l0, l1, l2, l3, l4, l5, l6, ee]
74+
# elinks = [l0, l1, l2, l3, l4, l5, ee]
75+
76+
super(GenericSeven, self).__init__(
77+
elinks,
78+
name='Generic Seven',
79+
manufacturer="Jesse's Imagination")
80+
81+
# self.addconfiguration(
82+
# "qz", np.array([0, 0, 0, 0, 0, 0, 0]))
83+
# self.addconfiguration(
84+
# "qr", np.array([0, -0.3, 0, -2.2, 0, 2.0, np.pi/4]))

roboticstoolbox/models/ETS/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
from roboticstoolbox.models.ETS.Frankie import Frankie
33
from roboticstoolbox.models.ETS.Puma560 import Puma560
44
from roboticstoolbox.models.ETS.Planar_Y import Planar_Y
5+
from roboticstoolbox.models.ETS.GenericSeven import GenericSeven
56

67

78
__all__ = [
89
'Panda',
910
'Frankie',
1011
'Puma560',
1112
'Planar_Y',
13+
'GenericSeven'
1214
]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy