{"id":31201419,"url":"https://github.com/colgreen/cartpole-physics","last_synced_at":"2025-09-20T12:59:01.004Z","repository":{"id":144223459,"uuid":"231137910","full_name":"colgreen/cartpole-physics","owner":"colgreen","description":"C# source code for simulation of the cart and pole balancing task.","archived":false,"fork":false,"pushed_at":"2025-02-01T21:18:02.000Z","size":1753,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T22:23:30.040Z","etag":null,"topics":["ai","cart-pole","inverted-pendulum","physics-simulation","reinforcement-learning"],"latest_commit_sha":null,"homepage":"","language":"C#","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/colgreen.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}},"created_at":"2019-12-31T19:24:29.000Z","updated_at":"2025-02-01T21:18:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"021ae74c-da69-4566-89cf-8e16e2277ef1","html_url":"https://github.com/colgreen/cartpole-physics","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/colgreen/cartpole-physics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colgreen%2Fcartpole-physics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colgreen%2Fcartpole-physics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colgreen%2Fcartpole-physics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colgreen%2Fcartpole-physics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colgreen","download_url":"https://codeload.github.com/colgreen/cartpole-physics/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colgreen%2Fcartpole-physics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276099102,"owners_count":25584935,"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","status":"online","status_checked_at":"2025-09-20T02:00:10.207Z","response_time":63,"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":["ai","cart-pole","inverted-pendulum","physics-simulation","reinforcement-learning"],"created_at":"2025-09-20T12:58:58.827Z","updated_at":"2025-09-20T12:59:01.000Z","avatar_url":"https://github.com/colgreen.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cartpole-physics\n\nC# source code for simulation of the cart and pole balancing task.\n\nFor details of this task, including derivations of the equations of motion, see the following technical research paper:\n\n[Equations of Motion for the Cart and Pole Control Task](https://sharpneat.sourceforge.io/research/cart-pole/cart-pole-equations.html)\n\nThe source code in this reposistory can be considered to be supplementary material for that paper.\n\n\n## Repository Overview\n\nThis repository contains C# source code (src folder) for the cart-pole balancing task, and some R/ggplot2 scripts (r-ggplot2 folder) for creating plots for the above linked research paper.\n\n## Source Code Overview\n\nThe source is written in C# and targets .NET Standard 2.1 and .NET Core 3.1. However, the physics/maths code should be easy to port to\nany other language.\n\nVisual Studio 2019 was used to author the code, and thus the source code is structured as a containing Visual Studio 'solution' (CartPolePhysics.sln),\nwith three projects within it. These are:\n\n\n### CartPolePhysics\nThis project contains the maths/physics source code. The project targets .NET Standard 2.1 as this provides a MathF class that is used for\nthe code that operates with single precision floating point variables, most notably MathF.Sin() and Cos().\n\n  * Double\n    * CartSinglePoleEquations.cs\n      * Contains the equations of motion for the cart-pole model, giving the horizontal acceleration of the cart and the angular acceleration \n      of the pole for a given model state and external force f (a horizontal force pushing the cart left or right).\n    * CartSinglePolePhysics.cs\n      * Contains an instance of CartSinglePoleEquations, and applies Euler's method to update the model state from one timestep to the next.\n      This is also the base class for CartSinglePolePhysicsRK2 and CartSinglePolePhysicsRK4.\n    * CartSinglePolePhysicsRK2.cs\n      * Contains an instance of CartSinglePoleEquations, and applies the standard second-order Runge-Kutta method to update the model\n      state from one timestep to the next.\n    * CartSinglePolePhysicsRK4.cs\n      * Contains an instance of CartSinglePoleEquations, and applies the classic fourth-order Runge-Kutta method to update the model\n      state from one timestep to the next.\n\n  * Single\n    * The classes in this folder/namespace mirror exactly those of the 'Double' folder, but provide physics calculation based on\n    single precision floating point maths.\n\n\n### CartPoleConsole\nA small console app that can be used to run a simulation and save a CSV fiel containing the model state at each timestep. These CSV files\ncan then be used to make plots, e.g. with R and ggplot2.\n\n\n### CartPoleWinForms\nA small Windows Forms app that targets .NET Core 3.1. The ability to run Winforms apps in .NET Core is a recent addition to that platform,\nand this is only possible when the app is running on Microsoft Windows.\n\nThis app runs a simulation and shows a graph on screen of pole angle, cart position, and pole angular velocity over time.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolgreen%2Fcartpole-physics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolgreen%2Fcartpole-physics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolgreen%2Fcartpole-physics/lists"}