Skip to content

Repository files navigation

mujoco-toy

Welcome to the mujoco-toy project!

To get started, create a virtual environment and install the package:

python -m venv .venv
source .venv/bin/activate
pip install -e .

If you're using VSCode or VSCode forks, you should also set your interpreter to the virtual environment:

  • Open the Command Palette (Ctrl+Shift+P)
  • Type "Python: Select Interpreter"
  • Select the virtual environment you created (should be .venv)

You should now be able to run the package:

mujoco-toy

Press Z to toggle force application and Q to toggle torque application.

You can get it to swing by timing your Z presses.

I've also added an example of applying torque with a motor. You can see this by running with the argument: --sinusoidal. Which applies a sinusoidal torque.

Where do I start looking to understand the code?

When you run mujoco-toy, it runs the mujoco_toy.cli.main function. This is the main function in mujoco_toy/cli.py.

Go there to see how it works.

MuJoCo sim commands:

  • Scroll to zoom in / out
  • Z to toggle force application
  • Q to toggle torque application
  • V to toggle frame visualization
  • R to reset the simulation
  • W to toggle Wireframe
  • S to toggle Shading
  • Many more

What should you do once you understand the code?

Try to make the dummy quadraped controllable QWOP-style.

  • Figure out a good interface to do this. One (bad) example is:
    • Have 2 keys assigned to each joint that can modify the position target of the joint and then use PD control to compute the torque required to keep/move the joint to the target position.
    • Really you should just use 4 keys: 2 to control which joint to move and then 2 to control the target position of the joint.

PD control: Torque = kp * (target position - current position) + kd * (target velocity - current velocity) where kp and kd are the proportional and derivative gains (constants). Use kp=120 and kd=10 for each joint.

Things to keep in mind:

  • Units of motor position are radians.

Some things to watch out for:

  • Some keys are already assigned by MuJoCo -- you should test what keys are available by printing every key event.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages