8000 Fixed python import errors · ZombyDogs/spatialmath-python@4f30368 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f30368

Browse files
committed
Fixed python import errors
1 parent 964dac4 commit 4f30368

File tree

4 files changed

+56
-51
lines changed

4 files changed

+56
-51
lines changed

spatialmath/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
from spatialmath.pose2d import *
22
from spatialmath.pose3d import *
33
from spatialmath.quaternion import *
4+
from spatialmath.super_pose import *
5+
from spatialmath import base

spatialmath/base/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
from spatialmath.base.transformsNd import *
44
from spatialmath.base.vectors import *
55
from spatialmath.base.quaternions import *
6+
from spatialmath.base.animate import *

spatialmath/base/animate.py

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,30 @@
1515
import matplotlib.pyplot as plt
1616
from mpl_toolkits.mplot3d import Axes3D
1717
from matplotlib import animation
18-
import spatialmath.base as tr
18+
from spatialmath import base as tr
1919
import numpy as np
2020
import math
2121

2222

2323
class Animate:
2424
"""
2525
Animate objects for matplotlib 3d
26-
26+
2727
An instance of this class behaves like an Axes3D and supports proxies for
28-
28+
2929
- ``plot``
3030
- ``quiver``
3131
- ``text``
32-
33-
which renders them and also places corresponding objects into a display list.
34-
These objects are ``Line``, ``Quiver`` and ``Text``. Only these primitives will
35-
be animated.
36-
37-
The objects are all drawn relative to the origin, and will be transformed according
38-
to the transform that is being animated.
39-
32+
33+
which renders them and also places corresponding objects into a display
34+
list. These objects are ``Line``, ``Quiver`` and ``Text``. Only these
35+
primitives will be animated.
36+
37+
The objects are all drawn relative to the origin, and will be transformed
38+
according to the transform that is being animated.
39+
4040
Example::
41-
41+
4242
anim = animate.Animate(dims=[0,2]) # set up the 3D axes
4343
anim.trplot(T, frame='A', color='green') # draw the frame
4444
anim.run(loop=True) # animate it
@@ -50,14 +50,15 @@ def __init__(self, axes=None, dims=None, projection='ortho', labels=['X', 'Y', '
5050
5151
:param axes: the axes to plot into, defaults to current axes
5252
:type axes: Axes3D reference
53-
:param dims: dimension of plot volume as [xmin, xmax, ymin, ymax,zmin, zmax].
54-
If dims is [min, max] those limits are applied to the x-, y- and z-axes.
53+
:param dims: dimension of plot volume as [xmin, xmax, ymin, ymax,
54+
zmin, zmax]. If dims is [min, max] those limits are applied
55+
to the x-, y- and z-axes.
5556
:type dims: array_like
5657
:param projection: 3D projection: ortho [default] or persp
5758
:type projection: str
5859
:param labels: labels for the axes, defaults to X, Y and Z
5960
:type labels: 3-tuple of strings
60-
61+
6162
Will setup to plot into an existing or a new Axes3D instance.
6263
6364
"""
@@ -88,17 +89,17 @@ def __init__(self, axes=None, dims=None, projection='ortho', labels=['X', 'Y', '
8889
self.ax = axes
8990

9091
# set flag for 2d or 3d axes, flag errors on the methods called later
91-
92+
9293
def trplot(self, T, **kwargs):
9394
"""
9495
Define the transform to animate
95-
96+
9697
:param T: an SO(3) or SE(3) pose to be displayed as coordinate frame
9798
:type: numpy.ndarray, shape=(3,3) or (4,4)
98-
99-
Is polymorphic with ``base.trplot`` and accepts the same parameters. This sets
100-
up the animation but doesn't execute it.
101-
99+
100+
Is polymorphic with ``base.trplot`` and accepts the same parameters.
101+
This sets up the animation but doesn't execute it.
102+
102103
:seealso: :func:`run`
103104
104105
"""
@@ -113,7 +114,7 @@ def trplot(self, T, **kwargs):
113114
def run(self, movie=None, axes=None, repeat=True, interval=50, nframes=100, **kwargs):
114115
"""
115116
Run the animation
116-
117+
117118
:param interval: number of steps in the animation [defaault 100]
118119
:type interval: int
119120
:param repeat: animate in endless loop [default False]
@@ -122,17 +123,19 @@ def run(self, movie=None, axes=None, repeat=True, interval=50, nframes=100, **kw
122123
:type interval: int
123124
:param movie: name of file to write MP4 movie into
124125
:type movie: str
125-
126-
Animates a 3D coordinate frame moving from the world frame to a frame represented by the SO(3) or SE(3) matrix to the current axes.
127-
126+
127+
Animates a 3D coordinate frame moving from the world frame to a frame
128+
represented by the SO(3) or SE(3) matrix to the current axes.
129+
128130
Notes:
129-
130-
- the ``movie`` option requires the ffmpeg package to be installed: ``conda install -c conda-forge ffmpeg``
131+
132+
- the ``movie`` option requires the ffmpeg package to be installed:
133+
``conda install -c conda-forge ffmpeg``
131134
- invokes the draw() method of every object in the display list
132135
"""
133-
136+
134137
def update(frame, a):
135-
T = tr.trinterp(self.T, s = frame / nframes)
138+
T = tr.trinterp(self.T, s=frame / nframes)
136139
a._draw(T)
137140
return a.artists()
138141

@@ -170,14 +173,12 @@ def artists(self):
170173
:rtype: list
171174
"""
172175
return [x.h for x in self.displaylist]
173-
174176

175177
def _draw(self, T):
176178
for x in self.displaylist:
177179
x.draw(T)
178180

179-
180-
#------------------- plot()
181+
# ------------------- plot()
181182

182183
class _Line:
183184

@@ -196,25 +197,25 @@ def draw(self, T):
196197
def plot(self, x, y, z, *args, **kwargs):
197198
"""
198199
Plot a polyline
199-
200+
200201
:param x: list of x-coordinates
201202
:type x: array_like
202203
:param y: list of y-coordinates
203204
:type y: array_like
204205
:param z: list of z-coordinates
205206
:type z: array_like
206-
207+
207208
Other arguments as accepted by the matplotlib method.
208-
209+
209210
All arrays must have the same length.
210-
211+
211212
:seealso: :func:`matplotlib.pyplot.plot`
212213
"""
213214

214215
h, = self.ax.plot(x, y, z, *args, **kwargs)
215216
self.displaylist.append(Animate._Line(self, h, x, y, z))
216217

217-
#------------------- quiver()
218+
# ------------------- quiver()
218219

219220
class _Quiver:
220221

@@ -243,7 +244,7 @@ def draw(self, T):
243244
def quiver(self, x, y, z, u, v, w, *args, **kwargs):
244245
"""
245246
Plot a quiver
246-
247+
247248
:param x: list of base x-coordinates
248249
:type x: array_like
249250
:param y: list of base y-coordinates
@@ -256,19 +257,19 @@ def quiver(self, x, y, z, u, v, w, *args, **kwargs):
256257
:type v: array_like
257258
:param w: list of vector z-coordinates
258259
:type w: array_like
259-
260-
Draws a series of arrows, the bases defined by corresponding elements of
261-
(x,y,z) and the vector has components defined by corresponding elements of
262-
(u,v,w).
263-
260+
261+
Draws a series of arrows, the bases defined by corresponding elements
262+
of (x,y,z) and the vector has components defined by corresponding
263+
elements of (u,v,w).
264+
264265
Other arguments as accepted by the matplotlib method.
265-
266+
266267
:seealso: :func:`matplotlib.pyplot.quiver`
267268
"""
268269
h = self.ax.quiver(x, y, z, u, v, w, *args, **kwargs)
269270
self.displaylist.append(Animate._Quiver(self, h))
270271

271-
#------------------- text()
272+
# ------------------- text()
272273

273274
class _Text:
274275 10BC0

@@ -280,30 +281,31 @@ def __init__(self, anim, h, x, y, z):
280281

281282
def draw(self, T):
282283
p = T @ self.p
283-
# x2, y2, _ = proj3d.proj_transform(p[0], p[1], p[2], self.anim.ax.get_proj())
284+
# x2, y2, _ = proj3d.proj_transform(
285+
# p[0], p[1], p[2], self.anim.ax.get_proj())
284286
# self.h.set_position((x2, y2))
285287
self.h.set_position((p[0], p[1]))
286288
self.h.set_3d_properties(z=p[2], zdir='x')
287289

288290
def text(self, x, y, z, *args, **kwargs):
289291
"""
290292
Plot text
291-
293+
292294
:param x: x-coordinate
293295
:type x: float
294296
:param y: float
295297
:type y: array_like
296298
:param z: z-coordinate
297299
:type z: float
298-
300+
299301
Other arguments as accepted by the matplotlib method.
300-
302+
301303
:seealso: :func:`matplotlib.pyplot.text`
302304
"""
303305
h = self.ax.text3D(x, y, z, *args, **kwargs)
304306
self.displaylist.append(Animate._Text(self, h, x, y, z))
305307

306-
#------------------- scatter()
308+
# ------------------- scatter()
307309

308310
def scatter(self, **kwargs):
309311
pass

spatialmath/base/plot_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
tr.trplot(tr.transl(1, 2, 3), frame='A', rviz=True, width=1)
55
tr.trplot(tr.transl(3, 1, 2), color='red', width=3, frame='B')
6-
tr.trplot(tr.transl(4, 3, 1)@ tr.trotx(60, 'deg'), color='green', frame='c')
6+
tr.trplot(tr.transl(4, 3, 1) @ tr.trotx(60, 'deg'), color='green', frame='c')
77

88
plt.show()

0 commit comments

Comments
 (0)
0