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-toyPress 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.
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
Zto toggle force applicationQto toggle torque applicationVto toggle frame visualizationRto reset the simulationWto toggle WireframeSto toggle Shading- Many more
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.