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

[Question] How are the .npy and .pickle files that contain the grasping poses structured? #63

Open
Polterino opened this issue Aug 23, 2023 · 0 comments

Comments

@Polterino
Copy link

Hi, I successfully generated some grasping poses of a model but I want to rotate and translate them. I have the rotation matrix and the translation vector, so I tried something like this:

import pickle
import numpy as np

poses_npy = np.load('003_cracker_box_2.npy')

transformation_matrix = np.eye(4)
rotation_matrix = np.array([[0.866, -0.5, 0, 0],
                            [0.5, 0.866, 0, 0],
                            [0, 0, 1, 0],
                            [0, 0, 0, 1]])
translation_vector = np.array([0.1, 0.2, 0.05, 1])
transformation_matrix[:3, :3] = rotation_matrix[:3, :3]
transformation_matrix[:3, 3] = translation_vector[:3]

transformed_poses_npy = []
for pose in poses_npy:
    pose_matrix = np.array(pose).reshape(3, 4)  # Assuming that it's a 1D array of length 12
    pose_matrix = np.vstack([pose_matrix, [0, 0, 0, 1]])  # Adding [0, 0, 0, 1] to the last row
    transformed_pose = np.dot(transformation_matrix, pose_matrix)
    transformed_poses_npy.append(transformed_pose)

np.save('transformed_poses.npy', transformed_poses_npy)

The program compiles, but when I try to display the transformed poses using read_grasps_from_file.py I get this error:
error

IndexError: index 6 is out of bounds for axis 0 with size 4

First of all, I'm not sure if I need to transorm both the .npy and the .pickle files or only the .npy.
And then I don't understand how the data in these files is structured, am I supposed to use a 3x3 rotation matrix and a 3D translation vector or a 4x4 rotation matrix and a 4D translation vector like in the code above?

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

1 participant