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

Fix projected gravity calculation in legged_robot.py #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

curieuxjy
Copy link

(Update legged_robot.py)

The misfunction for calculating projected gravity should be resolved by changing quat_rotate_inverse to the quat_rotate function for calculating the projected_gravity vector.

@SUZ-tsinghua
Copy link

No. It is quat_rotate_inverse.

@curieuxjy
Copy link
Author

No. It is quat_rotate_inverse.

@SUZ-tsinghua, I wanted to bring your attention to a specific line of code in the NVIDIA-Omniverse IsaacGymEnvs repository. Have you had a chance to review it?

Here is the link for reference: https://github.com/NVIDIA-Omniverse/IsaacGymEnvs/blob/aeed298638a1f7b5421b38f5f3cc2d1079b6d9c3/isaacgymenvs/tasks/anymal.py#L372.

In this updated version of the repository, you'll notice that the function quat_rotate_inverse has been changed to quat_rotate. Additionally, if you implement a visualization for the projected gravity vector and observe the rendering window, the error becomes evident. This observation suggests that the initial implementation using quat_rotate_inverse was wrong.

@SUZ-tsinghua
Copy link

No. It is quat_rotate_inverse.

@SUZ-tsinghua, I wanted to bring your attention to a specific line of code in the NVIDIA-Omniverse IsaacGymEnvs repository. Have you had a chance to review it?

Here is the link for reference: https://github.com/NVIDIA-Omniverse/IsaacGymEnvs/blob/aeed298638a1f7b5421b38f5f3cc2d1079b6d9c3/isaacgymenvs/tasks/anymal.py#L372.

In this updated version of the repository, you'll notice that the function quat_rotate_inverse has been changed to ``quat_rotate. Additionally, if you implement a visualization for the projected gravity vector and observe the rendering window, the error becomes evident. This observation suggests that the initial implementation using quat_rotate_inverse` was wrong.

@curieuxjy But you can directly verify the correctness of the code by running
`from isaacgym.torch_utils import *

base_quat = torch.tensor([[0.0, 0.7071, 0.0, 0.7071]])
gravity_vec = torch.tensor([[0.0, 0.0, -1.]])

projected_gravity_inverse = quat_rotate_inverse(base_quat, gravity_vec)
projected_gravity = quat_rotate(base_quat, gravity_vec)

print("projected gravity inverse",projected_gravity_inverse)
print("projected gravity", projected_gravity)``

It rotates the base frame so the x axis of the base frame is the -z axis of the env frame. And projected_gravity_inverse is [1,0,0] but projected_gravity is [-1,0,0].

屏幕截图 2024-01-29 095749

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

Successfully merging this pull request may close these issues.

2 participants