{"id":45924939,"url":"https://github.com/gregwar/mjlab_cartpole","last_synced_at":"2026-02-28T09:02:00.664Z","repository":{"id":321588300,"uuid":"1086332202","full_name":"Gregwar/mjlab_cartpole","owner":"Gregwar","description":"Cartpole minimal example using mjlab as external dependency","archived":false,"fork":false,"pushed_at":"2026-01-30T16:27:56.000Z","size":619,"stargazers_count":13,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-31T09:40:42.041Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gregwar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-30T09:19:51.000Z","updated_at":"2026-01-30T16:28:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"1cc265dd-393b-46c1-befe-4c386d65d287","html_url":"https://github.com/Gregwar/mjlab_cartpole","commit_stats":null,"previous_names":["gregwar/mjlab_cartpole"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Gregwar/mjlab_cartpole","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2Fmjlab_cartpole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2Fmjlab_cartpole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2Fmjlab_cartpole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2Fmjlab_cartpole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gregwar","download_url":"https://codeload.github.com/Gregwar/mjlab_cartpole/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2Fmjlab_cartpole/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29929117,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"online","status_checked_at":"2026-02-28T02:00:07.010Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2026-02-28T09:01:59.799Z","updated_at":"2026-02-28T09:02:00.649Z","avatar_url":"https://github.com/Gregwar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mjlab Cartpole example\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"imgs/cartpoles.gif\" width=\"400\" /\u003e\n\u003c/p\u003e\n\nThis is an example of a simple CartPole environment using [mjlab](https://github.com/mujocolab/mjlab/) for training. This repository is both a pedagogical example using mjlab and an example of organization using mjlab as an external dependency.\n\n## Installing\n\nSimply run:\n\n```\nuv sync\n```\n\n## Running the training\n\nTo run the training, use:\n\n```\nuv run train Mjlab-Cartpole\n```\n\n## Playing the environment\n\nRun:\n\n```\nuv run play Mjlab-Cartpole --checkpoint-file [path-to-checkpoint]\n```\n\nThe checkpoint will typically appear in `logs/rsl_rl/exp1/[date]/model_499.pt` \n\n## Organization\n\nThe structure is as follow:\n\n* `src/mjlab_cartpole/`\n  * `robot/`: Robot model\n    * `xmls/cartpole.xml`: MuJoCo MJCF spec\n    * `cartpole_constants.py`: Describing how to load the robot entity (mostly loading the XML spec here)\n  * `tasks/`: Task definition\n    * `__init__.py`: Environments are registered here\n    * `cartpole_env_cfg.py`: Environment configurations (actions, rewards, termination, reset etc.)\n\nHere, mjlab is used as an external dependency. \n\n## Environment\n\n### Action\n\nActions is the force $f$ applied to the cart (Newton).\n\n## Observation\n\nAgent observation is the pole angle and velocity and the cart position and velocity.\n\n### Reward\n\nThe goal is for the pole not to fall, while navigating the cart to the center, the reward is as follows:\n\n$$\nr = 5 \\times cos(\\theta) + exp(-\\frac{x^2}{\\sigma^2}) - 10^{-2} ({\\frac{f}{20}})^2\n$$\n\nWhere:\n\n* $\\theta$ is the pole angle (0 is upright)\n* $x$ is the cart position\n* $\\sigma = 0.3$ is a deviation to the center\n* $f$ is the applied cart force (command)\n\n### Termination \u0026 truncation\n\nA termination is issued when $|\\theta| \u003e 30 \\space deg$ and a timeout happens after 10s.\n\n## References\n\n* This is inspired by the [Creating a New Task](https://github.com/mujocolab/mjlab/blob/main/docs/create_new_task.md) markdown from mjlab\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregwar%2Fmjlab_cartpole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregwar%2Fmjlab_cartpole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregwar%2Fmjlab_cartpole/lists"}