Skip to content

Commit 76bd2fa

Browse files
committed
Formatted
1 parent fc9ca19 commit 76bd2fa

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

roboticstoolbox/backends/PyPlot/EllipsePlot.py

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
import matplotlib.pyplot as plt
1010

1111

12-
class EllipsePlot():
13-
14-
def __init__(self, robot, q, etype, opt='trans', centre=[0, 0, 0], scale=1):
12+
class EllipsePlot:
13+
def __init__(self, robot, q, etype, opt="trans", centre=[0, 0, 0], scale=1):
1514

1615
super(EllipsePlot, self).__init__()
1716

@@ -21,10 +20,10 @@ def __init__(self, robot, q, etype, opt='trans', centre=[0, 0, 0], scale=1):
2120
centre = base.getvector(centre, 2)
2221
centre = np.array([centre[0], centre[1], 0])
2322
except TypeError:
24-
if centre != 'ee':
23+
if centre != "ee":
2524
raise ValueError(
26-
'Centre must be a three vector or \'ee\' meaning'
27-
'end-effector')
25+
"Centre must be a three vector or 'ee' meaning" "end-effector"
26+
)
2827

2928
self.ell = None
3029
self.robot = robot
@@ -38,12 +37,12 @@ def __init__(self, robot, q, etype, opt='trans', centre=[0, 0, 0], scale=1):
3837
else:
3938
self.q = q
4039

41-
if etype == 'v':
40+
if etype == "v":
4241
self.vell = True
43-
self.name = 'Velocity Ellipse'
44-
elif etype == 'f':
42+
self.name = "Velocity Ellipse"
43+
elif etype == "f":
4544
self.vell = False
46-
self.name = 'Force Ellipse'
45+
self.name = "Force Ellipse"
4746

4847
def draw(self):
4948
self.make_ellipsoid()
@@ -52,33 +51,32 @@ def draw(self):
5251
self.ax.collections.remove(self.ell)
5352

5453
self.ell = self.ax.plot_wireframe(
55-
self.x, self.y, self.z, rstride=6,
56-
cstride=6, color='#2980b9', alpha=0.2)
54+
self.x, self.y, self.z, rstride=6, cstride=6, color="#2980b9", alpha=0.2
55+
)
5756

5857
def draw2(self):
5958
self.make_ellipsoid2()
6059

6160
if self.ell is not None:
6261
self.ell[0].set_data(self.x, self.y)
6362
else:
64-
self.ell = self.ax.plot(
65-
self.x, self.y, color='#2980b9')
63+
self.ell = self.ax.plot(self.x, self.y, color="#2980b9")
6664

6765
def plot(self, ax=None):
6866
if ax is None:
6967
ax = self.ax
70-
68+
7169
if ax is None:
7270
fig = plt.figure()
73-
ax = plt.axes(projection='3d')
71+
ax = plt.axes(projection="3d")
7472
self.ax = ax
75-
73+
7674
self.draw()
7775

7876
def plot2(self, ax=None):
7977
if ax is None:
8078
ax = self.ax
81-
79+
8280
if ax is None:
8381
ax = plt.axes()
8482
self.ax = ax
@@ -91,18 +89,18 @@ def make_ellipsoid(self):
9189
9290
"""
9391

94-
if self.opt == 'trans':
92+
if self.opt == "trans":
9593
J = self.robot.jacobe(self.q)[3:, :]
9694
A = J @ J.T
97-
elif self.opt == 'rot':
95+
elif self.opt == "rot":
9896
J = self.robot.jacobe(self.q)[:3, :]
9997
A = J @ J.T
10098

10199
if not self.vell:
102100
# Do the extra step for the force ellipse
103101
A = np.linalg.inv(A)
104102

105-
if isinstance(self.centre, str) and self.centre == 'ee':
103+
if isinstance(self.centre, str) and self.centre == "ee":
106104
centre = self.robot.fkine(self.q).t
107105
else:
108106
centre = self.centre
@@ -121,8 +119,9 @@ def make_ellipsoid(self):
121119
# transform points to ellipsoid
122120
for i in range(len(x)):
123121
for j in range(len(x)):
124-
[x[i, j], y[i, j], z[i, j]] = \
125-
np.dot([x[i, j], y[i, j], z[i, j]], rotation)
122+
[x[i, j], y[i, j], z[i, j]] = np.dot(
123+
[x[i, j], y[i, j], z[i, j]], rotation
124+
)
126125

127126
self.x = x * self.scale + centre[0]
128127
self.y = y * self.scale + centre[1]
@@ -134,13 +133,13 @@ def make_ellipsoid2(self):
134133
135134
"""
136135

137-
if self.opt == 'trans':
136+
if self.opt == "trans":
138137
J = self.robot.jacob0(self.q)[:2, :]
139138
A = J @ J.T
140-
elif self.opt == 'rot':
139+
elif self.opt == "rot":
141140
raise ValueError(
142-
"Can not do rotational ellipse for a 2d robot plot."
143-
" Set opt='trans'")
141+
"Can not do rotational ellipse for a 2d robot plot." " Set opt='trans'"
142+
)
144143

145144
# if not self.vell:
146145
# # Do the extra step for the force ellipse
@@ -149,7 +148,7 @@ def make_ellipsoid2(self):
149148
# except:
150149
# A = np.zeros((2,2))
151150

152-
if isinstance(self.centre, str) and self.centre == 'ee':
151+
if isinstance(self.centre, str) and self.centre == "ee":
153152
centre = self.robot.fkine(self.q).t
154153
else:
155154
centre = self.centre
@@ -158,7 +157,7 @@ def make_ellipsoid2(self):
158157
theta = np.linspace(0.0, 2.0 * np.pi, 50)
159158
y = np.array([np.cos(theta), np.sin(theta)])
160159
# RVC2 p 602
161-
x = sp.linalg.sqrtm(A) @ y
160+
# x = sp.linalg.sqrtm(A) @ y
162161

163162
x, y = base.ellipse(A, inverted=True, centre=centre[:2], scale=self.scale)
164163
self.x = x

0 commit comments

Comments
 (0)