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

Mujoco environment is reset while using position command interface #7

Open
sangteak601 opened this issue Jun 22, 2024 · 3 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@sangteak601
Copy link
Member

Experienced resetting issue with position control. It seems that directly manipulating position is not stable and causes the issue but not sure and need to investigate this further

@dyackzan
Copy link
Collaborator

dyackzan commented Jul 7, 2024

I was able to reproduce and spent some time investigating. It seems like there is some sort of a race condition we're encountering when we attempt to change the mj_data_->qpos array directly that causes the position values to explode sometimes so I don't think it's really supported. I also recorded the joint_state.position values that come across from the command interface and verified that they are reasonable so it doesn't appear that the issue is from your code commanding any bad values here.

But I think it does make sense why MuJoCo wouldn't support directly setting the joint positions: Setting the position value of a joint directly ignores physics and negates the whole purpose of MuJoCo. If we want to simulate a trajectory without physics then we don't need to incorporate a physics simulator.

Looking at the MuJoCo Simulation loop docs, it looks like in between mj_step1() and mj_step2() the only things we should be setting directly in the mjData struct are ctrl, qfrc_applied, or xfrc_applied.

So I think a good solution here is probably just to remove this direct position control functionality and replace it with the PID position control method you've implemented.

@dyackzan
Copy link
Collaborator

dyackzan commented Jul 7, 2024

I'll paste some details here from my investigation:

You can see here that values coming across the position command interface from panda_joint1 are reasonable ~[-.002, 0.055]:
Screenshot from 2024-07-07 14-53-50

But when I include qpos on the plot, you can see the values shoot off at some point beyond the limits of the actuator ~[-8.25, 6.25]:
Screenshot from 2024-07-07 14-57-39

I'll also attach the mcap file of the recorded data if you want to take a look. You can unzip it and drag and drop it into Plotjuggler if you want to view. (You can install the version of plotjuggler that supports mcaps from the snap store snap install plotjuggler)
mujoco_system_debugging.zip

@sangteak601
Copy link
Member Author

@dyackzan Thanks for the investigation. It looks insightful. I will also take another look with the data you shared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants