Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alsaibie opened this issue Sep 27, 2024 · 1 comment
Open

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

alsaibie opened this issue Sep 27, 2024 · 1 comment
Assignees

Comments

@alsaibie
Copy link

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

@jcao-bdai
Copy link
Collaborator

jcao-bdai commented Sep 27, 2024

Thank you so much @alsaibie

We tested and implemented the fix in this PR: #138

@jcao-bdai jcao-bdai self-assigned this Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants