Skip to content

Check type-check for NDArray under Animate-Run-Update #137

Closed
@alsaibie

Description

@alsaibie

In animate.py

The frame type check is done against NDArray, which gives an error when passing a Rotation matrix for example. It works if changd to np.ndarray

Error

elif isinstance(frame, NDArray):

fix

elif isinstance(frame, np.ndarray):

Here

Is this an error in animate.py or I need to fix something in my example?

Example

# imports
ax = plotvol3(new=True)
J = np.array([[ 2, -1, 0],
              [-1,  4, 0],
              [ 0,  0, 3]]);
orientation = UnitQuaternion();  # identity quaternion
w = 0.2 * np.array([1, 2, 2]);
dt = 0.05;  # time step
def update():
  global orientation, w
  for t in np.arange(0, 10, dt):
     wd = -np.linalg.inv(J) @ (np.cross(w, J @ w))  # (3.12)
     w += wd * dt
     orientation *= UnitQuaternion.EulerVec(w * dt)
     print(type(orientation.R))
     yield NDArray[orientation.R]

ani = tranimate(update(), ax=ax, frame='A', color='green');

plt.show()

NumPy version: 1.26.4
Matplotlib version: 3.8.4
Spatialmath version: 1.1.11

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions