{"id":17741617,"url":"https://leggedrobotics.github.io/legged_gym/","last_synced_at":"2025-03-14T18:30:58.212Z","repository":{"id":36972517,"uuid":"418499474","full_name":"leggedrobotics/legged_gym","owner":"leggedrobotics","description":"Isaac Gym Environments for Legged Robots","archived":false,"fork":false,"pushed_at":"2024-08-02T10:52:49.000Z","size":36965,"stargazers_count":1333,"open_issues_count":45,"forks_count":376,"subscribers_count":39,"default_branch":"master","last_synced_at":"2024-10-29T15:38:50.925Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leggedrobotics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-18T12:50:04.000Z","updated_at":"2024-10-29T13:42:50.000Z","dependencies_parsed_at":"2022-07-12T16:12:54.432Z","dependency_job_id":"7b9afe8d-f19f-405b-b7ad-f171d3e3fc90","html_url":"https://github.com/leggedrobotics/legged_gym","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leggedrobotics%2Flegged_gym","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leggedrobotics%2Flegged_gym/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leggedrobotics%2Flegged_gym/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leggedrobotics%2Flegged_gym/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leggedrobotics","download_url":"https://codeload.github.com/leggedrobotics/legged_gym/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243625062,"owners_count":20321223,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-26T04:01:48.327Z","updated_at":"2025-03-14T18:30:58.206Z","avatar_url":"https://github.com/leggedrobotics.png","language":"Python","funding_links":[],"categories":["📑 Research Papers"],"sub_categories":["Localization \u0026 Control"],"readme":"# Isaac Gym Environments for Legged Robots #\nThis repository provides the environment used to train ANYmal (and other robots) to walk on rough terrain using NVIDIA's Isaac Gym.\nIt includes all components needed for sim-to-real transfer: actuator network, friction \u0026 mass randomization, noisy observations and random pushes during training.  \n\n**Maintainer**: Nikita Rudin  \n**Affiliation**: Robotic Systems Lab, ETH Zurich  \n**Contact**: rudinn@ethz.ch  \n\n---\n\n### :bell: Announcement (09.01.2024) ###\n\nWith the shift from Isaac Gym to Isaac Sim at NVIDIA, we have migrated all the environments from this work to [Isaac Lab](https://github.com/isaac-sim/IsaacLab). Following this migration, this repository will receive limited updates and support. We encourage all users to migrate to the new framework for their applications.\n\nInformation about this work's locomotion-related tasks in Isaac Lab is available [here](https://isaac-sim.github.io/IsaacLab/source/features/environments.html#locomotion).\n\n---\n\n### Useful Links ###\n\nProject website: https://leggedrobotics.github.io/legged_gym/   \nPaper: https://arxiv.org/abs/2109.11978\n\n### Installation ###\n1. Create a new python virtual env with python 3.6, 3.7 or 3.8 (3.8 recommended)\n2. Install pytorch 1.10 with cuda-11.3:\n    - `pip3 install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio==0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html`\n3. Install Isaac Gym\n   - Download and install Isaac Gym Preview 3 (Preview 2 will not work!) from https://developer.nvidia.com/isaac-gym\n   - `cd isaacgym/python \u0026\u0026 pip install -e .`\n   - Try running an example `cd examples \u0026\u0026 python 1080_balls_of_solitude.py`\n   - For troubleshooting check docs `isaacgym/docs/index.html`)\n4. Install rsl_rl (PPO implementation)\n   - Clone https://github.com/leggedrobotics/rsl_rl\n   -  `cd rsl_rl \u0026\u0026 git checkout v1.0.2 \u0026\u0026 pip install -e .` \n5. Install legged_gym\n    - Clone this repository\n   - `cd legged_gym \u0026\u0026 pip install -e .`\n\n### CODE STRUCTURE ###\n1. Each environment is defined by an env file (`legged_robot.py`) and a config file (`legged_robot_config.py`). The config file contains two classes: one containing  all the environment parameters (`LeggedRobotCfg`) and one for the training parameters (`LeggedRobotCfgPPo`).  \n2. Both env and config classes use inheritance.  \n3. Each non-zero reward scale specified in `cfg` will add a function with a corresponding name to the list of elements which will be summed to get the total reward.  \n4. Tasks must be registered using `task_registry.register(name, EnvClass, EnvConfig, TrainConfig)`. This is done in `envs/__init__.py`, but can also be done from outside of this repository.  \n\n### Usage ###\n1. Train:  \n  ```python legged_gym/scripts/train.py --task=anymal_c_flat```\n    -  To run on CPU add following arguments: `--sim_device=cpu`, `--rl_device=cpu` (sim on CPU and rl on GPU is possible).\n    -  To run headless (no rendering) add `--headless`.\n    - **Important**: To improve performance, once the training starts press `v` to stop the rendering. You can then enable it later to check the progress.\n    - The trained policy is saved in `issacgym_anymal/logs/\u003cexperiment_name\u003e/\u003cdate_time\u003e_\u003crun_name\u003e/model_\u003citeration\u003e.pt`. Where `\u003cexperiment_name\u003e` and `\u003crun_name\u003e` are defined in the train config.\n    -  The following command line arguments override the values set in the config files:\n     - --task TASK: Task name.\n     - --resume:   Resume training from a checkpoint\n     - --experiment_name EXPERIMENT_NAME: Name of the experiment to run or load.\n     - --run_name RUN_NAME:  Name of the run.\n     - --load_run LOAD_RUN:   Name of the run to load when resume=True. If -1: will load the last run.\n     - --checkpoint CHECKPOINT:  Saved model checkpoint number. If -1: will load the last checkpoint.\n     - --num_envs NUM_ENVS:  Number of environments to create.\n     - --seed SEED:  Random seed.\n     - --max_iterations MAX_ITERATIONS:  Maximum number of training iterations.\n2. Play a trained policy:  \n```python legged_gym/scripts/play.py --task=anymal_c_flat```\n    - By default, the loaded policy is the last model of the last run of the experiment folder.\n    - Other runs/model iteration can be selected by setting `load_run` and `checkpoint` in the train config.\n\n### Adding a new environment ###\nThe base environment `legged_robot` implements a rough terrain locomotion task. The corresponding cfg does not specify a robot asset (URDF/ MJCF) and has no reward scales. \n\n1. Add a new folder to `envs/` with `'\u003cyour_env\u003e_config.py`, which inherit from an existing environment cfgs  \n2. If adding a new robot:\n    - Add the corresponding assets to `resources/`.\n    - In `cfg` set the asset path, define body names, default_joint_positions and PD gains. Specify the desired `train_cfg` and the name of the environment (python class).\n    - In `train_cfg` set `experiment_name` and `run_name`\n3. (If needed) implement your environment in \u003cyour_env\u003e.py, inherit from an existing environment, overwrite the desired functions and/or add your reward functions.\n4. Register your env in `isaacgym_anymal/envs/__init__.py`.\n5. Modify/Tune other parameters in your `cfg`, `cfg_train` as needed. To remove a reward set its scale to zero. Do not modify parameters of other envs!\n\n\n### Troubleshooting ###\n1. If you get the following error: `ImportError: libpython3.8m.so.1.0: cannot open shared object file: No such file or directory`, do: `sudo apt install libpython3.8`. It is also possible that you need to do `export LD_LIBRARY_PATH=/path/to/libpython/directory` / `export LD_LIBRARY_PATH=/path/to/conda/envs/your_env/lib`(for conda user. Replace /path/to/ to the corresponding path.).\n\n### Known Issues ###\n1. The contact forces reported by `net_contact_force_tensor` are unreliable when simulating on GPU with a triangle mesh terrain. A workaround is to use force sensors, but the force are propagated through the sensors of consecutive bodies resulting in an undesirable behaviour. However, for a legged robot it is possible to add sensors to the feet/end effector only and get the expected results. When using the force sensors make sure to exclude gravity from the reported forces with `sensor_options.enable_forward_dynamics_forces`. Example:\n```\n    sensor_pose = gymapi.Transform()\n    for name in feet_names:\n        sensor_options = gymapi.ForceSensorProperties()\n        sensor_options.enable_forward_dynamics_forces = False # for example gravity\n        sensor_options.enable_constraint_solver_forces = True # for example contacts\n        sensor_options.use_world_frame = True # report forces in world frame (easier to get vertical components)\n        index = self.gym.find_asset_rigid_body_index(robot_asset, name)\n        self.gym.create_asset_force_sensor(robot_asset, index, sensor_pose, sensor_options)\n    (...)\n\n    sensor_tensor = self.gym.acquire_force_sensor_tensor(self.sim)\n    self.gym.refresh_force_sensor_tensor(self.sim)\n    force_sensor_readings = gymtorch.wrap_tensor(sensor_tensor)\n    self.sensor_forces = force_sensor_readings.view(self.num_envs, 4, 6)[..., :3]\n    (...)\n\n    self.gym.refresh_force_sensor_tensor(self.sim)\n    contact = self.sensor_forces[:, :, 2] \u003e 1.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/leggedrobotics.github.io%2Flegged_gym%2F","html_url":"https://awesome.ecosyste.ms/projects/leggedrobotics.github.io%2Flegged_gym%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/leggedrobotics.github.io%2Flegged_gym%2F/lists"}