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

Add Unitree H1 Walk task #336

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

AntoSave
Copy link

@AntoSave AntoSave commented Aug 4, 2024

This PR adds a new task to make the Unitree H1 humanoid robot walk towards a given setpoint with MJPC. Some remarks on this PR:

  • As for the robot model, I used the one provided by Menagerie
  • The obtained results are moderately satisfying as the robot successfully completes the task without "strange" behaviors overall, however there is still room from improvement
  • Goal is given with a marker (a body with disabled collisions) similarly to the QuadrupedFlat task
  • I am getting good results with up to 20% real-time on my machine (Ryzen 9 7950x), and I would like suggestions on how to further reduce the planning time

Here is a video that showcases the agent's performances:

h1_walk_3.mp4

I would like to get some feedback on the overall implementation as well as any modification needed to merge this PR.
Thanks for your time!

Copy link

google-cla bot commented Aug 4, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the file links to your machine. You can replace them with something generic like the other .patch files.

</actuator>
-</mujoco>
+</mujoco>
\ No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The xml file should have a new line at the end.

diaginertia="0.0490211 0.0445821 0.00824619"/>
<freejoint/>
<geom class="visual" mesh="pelvis"/>
- <body name="left_hip_yaw_link" pos="0 0.0875 -0.1742">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check to see if this diff can be smaller?

<custom>
<!-- agent -->
<numeric name="agent_planner" data="2" />
<numeric name="agent_horizon" data="0.6" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly reduce the planning horizon.

mju_scl3(&residual[counter], &residual[counter], 0.1 * standing);
counter += 3;
// ----- posture up ----- //
mju_copy(&residual[counter], data->qpos + 17, model->nq - 17); //First 7 are freejoint coord, the other 10 are lower body joints
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space after '//'.

mju_copy(&residual[counter], data->qpos + 17, model->nq - 17); //First 7 are freejoint coord, the other 10 are lower body joints
counter += model->nq - 17;
// ----- posture down ----- //
mju_copy(&residual[counter], data->qpos + 7, model->nq - 16); //First 7 are freejoint coord, the other 10 are lower body joints
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space after '//'.

mju_sub(forward_target, goal_point, torso_position, 2);
mju_normalize(forward_target, 2);

// com vel
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't use this term, let's remove it.

return mju_abs(value) < 1e-6 ? 0.0 : value;
}

} // namespace mjpc::h1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please format this file, see this reference.

p.start()
while True:
action = agent.get_action()
q.put(action)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please format: pyink h1_walk.py --pyink-indentation 2 --line-length 80

@thowell
Copy link
Collaborator

thowell commented Aug 4, 2024

This is a great task, thanks for the contribution!

Things to improve performance:

  • shorten the planning horizon: <numeric name="agent_horizon" data="0.35" />
  • change the integrator to implicitfast: <numeric name="agent_integrator" data="3"/>
  • modify the model (see the MJX humanoid example)

Additionally, can you please sign the CLA? Thanks!

@thowell thowell self-assigned this Aug 4, 2024
@thowell
Copy link
Collaborator

thowell commented Aug 4, 2024

Have you tried this task with the G1 model?

@AntoSave
Copy link
Author

AntoSave commented Aug 9, 2024

Thank you for the time you spent on reviewing the PR, I really appreciate it.

This is a great task, thanks for the contribution!

Things to improve performance:

  • shorten the planning horizon: <numeric name="agent_horizon" data="0.35" />

  • change the integrator to implicitfast: <numeric name="agent_integrator" data="3"/>

  • modify the model (see the MJX humanoid example)

I managed to get a ~30% speed gain by moving to the implicitfast integrator and reducing the agent's horizon to 0.4s. I am reluctant to go lower as I experienced some instability, but I will surely try to reduce the number of contatcts to see if that helps.

Additionally, can you please sign the CLA? Thanks!

Signed it

Have you tried this task with the G1 model?

Not yet, but I'm going to. However, for the time being I will focus on H1 tasks as it is part of my master's thesis.

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