# RL-Locomotion-Mujoco **Repository Path**: momaoto/rl-locomotion-mujoco ## Basic Information - **Project Name**: RL-Locomotion-Mujoco - **Description**: 四足机器人强化学习的mujoco仿真demo - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://momaoto.github.io/posts/2137251158/ - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 0 - **Created**: 2025-02-15 - **Last Updated**: 2025-10-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: RL, 强化学习, MuJoCo, quadruped ## README # 🦾Training Quadruped Locomotion using Reinforcement Learning in Mujoco A custom gymnasium environment for training quadruped locomotion using reinforcement learning in the Mujoco simulator. The environment has been set up for the Unitree Go1 and Petoi Bittle robot, however, it can be easily extended to train other robots as well. 🚀 ![](https://gitee.com/momaoto/rl-locomotion-mujoco/raw/master/bittle/bittle_walk.webp) ## ⛏Setup ```bash git clone https://gitee.com/momaoto/rl-locomotion-mujoco.git cd rl-locomotion-mujoco conda create -n rl python=3.10 conda activate rl python -m pip install -r requirements.txt ``` ❗ **Important:** Then find "mujoco_rendering.py" under gymnasium's envs, replace `solver_iter` with `solver_niter` in line 593 to fix [this bug](https://momaoto.github.io/posts/1644944583/#3-mujoco%E6%8A%A5%E9%94%99%EF%BC%9AValueError-XML-Error-Schema-violation-unrecognized-attribute-%E2%80%98kv%E2%80%99). The path of the file looks like this: `/home/momaoto/miniconda3/envs/rl/lib/python3.10/site-packages/gymnasium/envs/mujoco/mujoco_rendering.py"` . ## 🏋️‍♂️Train To train a model, run: ```bash python train.py --run train [--model_path ] ``` - If `--model_path` is **not specified**, a new model will be trained from scratch. - If `--model_path` is **specified**, the training will continue from the given pretrained model. ## 🎮Display Trained Models To test a model, run: ```bash python train.py --run test [--model_path ] ``` - If `--model_path` is **not specified**, the script will **automatically find the most recent model** based on the latest date in the model filename and test it. - If `--model_path` is **specified**, it will test the model from the given path. For example, to run a pretrained model which the robot has a y-axis desired velocity , you can run: ```bash python train.py --run test --model_path models/2025-02-21_20-47-23_only_vy/final_model.zip ```
Additional arguments for customizing training and testing usage: train.py [-h] --run {train,test} [--run_name RUN_NAME] [--num_parallel_envs NUM_PARALLEL_ENVS] [--num_test_episodes NUM_TEST_EPISODES] [--record_test_episodes] [--total_timesteps TOTAL_TIMESTEPS] [--eval_frequency EVAL_FREQUENCY] [--model_path MODEL_PATH] [--seed SEED] Train or test PPO on Bittle Mujoco environment. options: -h, --help show this help message and exit --run {train,test} Select training or testing mode --run_name RUN_NAME The name of the training run, used for saving models and logs --num_parallel_envs NUM_PARALLEL_ENVS Number of parallel environments during training --total_timesteps TOTAL_TIMESTEPS Total number of training timesteps --eval_frequency EVAL_FREQUENCY Frequency (in timesteps) for evaluating the model --num_test_episodes NUM_TEST_EPISODES Number of episodes to run during testing --record_test_episodes Whether to record test episodes as videos --model_path MODEL_PATH Path to the model (for continuing training or testing) --ctrl_type {torque,position} Robot control type: torque control or position control --seed SEED Random seed
## Note This repository serves for education purposes and is by no means finalized. 💡