{"id":15910488,"url":"https://github.com/goktug97/dynamicwindowapproach","last_synced_at":"2025-05-07T10:11:16.484Z","repository":{"id":53331385,"uuid":"229786824","full_name":"goktug97/DynamicWindowApproach","owner":"goktug97","description":"The Dynamic Window Approach (DWA) planning algorithm written in C with Python Bindings","archived":false,"fork":false,"pushed_at":"2023-01-29T08:25:42.000Z","size":3622,"stargazers_count":97,"open_issues_count":0,"forks_count":24,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-12-27T05:05:48.046Z","etag":null,"topics":["bindings","c","collision-avoidance","cython","dwa","dynamic-window-approach","mobile-robots","motion-planning","planning-algorithm","position-control","python","python-bindings","robot-control","robotics"],"latest_commit_sha":null,"homepage":"https://goktug97.github.io/dwa/","language":"Cython","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goktug97.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}},"created_at":"2019-12-23T16:25:39.000Z","updated_at":"2024-12-26T18:41:04.000Z","dependencies_parsed_at":"2023-02-15T21:45:54.823Z","dependency_job_id":null,"html_url":"https://github.com/goktug97/DynamicWindowApproach","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goktug97%2FDynamicWindowApproach","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goktug97%2FDynamicWindowApproach/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goktug97%2FDynamicWindowApproach/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goktug97%2FDynamicWindowApproach/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goktug97","download_url":"https://codeload.github.com/goktug97/DynamicWindowApproach/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231439063,"owners_count":18376836,"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":["bindings","c","collision-avoidance","cython","dwa","dynamic-window-approach","mobile-robots","motion-planning","planning-algorithm","position-control","python","python-bindings","robot-control","robotics"],"created_at":"2024-10-06T15:06:49.875Z","updated_at":"2024-12-27T05:05:52.548Z","avatar_url":"https://github.com/goktug97.png","language":"Cython","funding_links":[],"categories":[],"sub_categories":[],"readme":"Dynamic Window Approach\n===================================\n\n2D Dynamic Window Approach [\u003ccite\u003e[1]\u003c/cite\u003e](#ref1) Motion Planning algorithm written in C with Python Bindings.\n\n![Python Demo](https://raw.githubusercontent.com/goktug97/DynamicWindowApproach/master/dwa.gif)\n\n\u003c!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --\u003e\n**Table of Contents**\n\n- [Dynamic Window Approach](#dynamic-window-approach)\n    - [Online Demo](#online-demo)\n    - [Requirements](#requirements)\n        - [Python](#python)\n        - [C Libraries (Optional for the Demo)](#c-libraries-optional-for-the-demo)\n    - [Installation](#installation)\n        - [Compile and Install C Library](#compile-and-install-c-library)\n        - [Install Python Bindings](#install-python-bindings)\n            - [PyPI](#pypi)\n            - [Source](#source)\n    - [Usage](#usage)\n    - [Documentation](#documentation)\n        - [Structs and Classes](#structs-and-classes)\n            - [Rect](#rect)\n            - [Config](#config)\n            - [Velocity](#velocity)\n            - [Point](#point)\n            - [PointCloud](#pointcloud)\n            - [Pose](#pose)\n            - [DynamicWindow](#dynamicwindow)\n        - [Functions](#functions)\n            - [planning](#planning)\n            - [createDynamicWindow](#createdynamicwindow)\n            - [freeDynamicWindow](#freedynamicwindow)\n            - [motion](#motion)\n            - [calculateVelocityCost](#calculatevelocitycost)\n            - [calculateHeadingCost](#calculateheadingcost)\n            - [calculateClearanceCost](#calculateclearancecost)\n            - [createPointCloud](#createpointcloud)\n            - [freePointCloud](#freepointcloud)\n    - [References](#references)\n    - [License](#license)\n\n\u003c!-- markdown-toc end --\u003e\n\n## Online Demo\n\nhttps://goktug97.github.io/dwa/\n\n## Requirements\n\n### Python\n\n* Python \u003e= 3.6\n* cython\n* numpy\n* cv2 (Optional for the demo)\n\n### C Libraries (Optional for the Demo)\n\n* SDL\n* OpenGL\n\n## Installation\n\nYou can directly install Python bindings without compiling the library.\n\n### Compile and Install C Library\n\n```bash\ngit clone https://github.com/goktug97/DynamicWindowApproach\ncd DynamicWindowApproach\nmkdir build\ncd build\ncmake ..\nmake\nmake install\n# Optional: Build Demo\nmake demo\n```\n\n### Install Python Bindings\n\n#### PyPI\n\n```bash\npip3 install dynamic-window-approach --user\n```\n\n#### Source\n\n```bash\ngit clone https://github.com/goktug97/DynamicWindowApproach\ncd DynamicWindowApproach\npython3 setup.py install --user\n```\n\n## Usage\n\n- Only function you need to run to plan the next move is the\n[planning](#planning) function.  Rest of the code for both C and\nPython examples are just to create simulation environment and GUI.\nThe 2 examples that you can find in\n[examples](https://github.com/goktug97/DynamicWindowApproach/blob/master/examples/)\nfolder is the same demo but implemented using different libraries for\nvisualization.\n\n- The Python example uses OpenCV and you can run it by executing `python3 demo.py`\nin the examples folder.\n\n- The C example uses OpenGL and SDL and you can run it by executing `./demo` in\nbin folder. The bin folder is created after the compile so if you didn't \ncompile the demo while installing the library. Go to `build` directory and run\n`make demo`.\n\n## Documentation\n\nWhile the [planning](#planning) function is the only function that a user needs\nto call for the planning, all of the functions are exposed to the user\nfor both C and Python for no reasons.\n\n### Structs and Classes\nIf you are using Python bindings, you don't need to use any of these\nclasses except [Config](#config). The functions accept built-in or\nnumpy types. The functions create required classes inside for easy\nusage. For example a snippet from the [planning](#planning) function;\n\n``` cython\ncdef float x, y, yaw, v , w, gx, gy\ncdef PointCloud _point_cloud = PointCloud(point_cloud)\nx, y, yaw = pose\nv, w = velocity\ngx, gy = goal\ncdef Pose _pose = Pose(Point(x, y), yaw)\ncdef Velocity _velocity = Velocity(v, w)\ncdef Point _goal = Point(gx, gy)\n```\n\n- Structs are for C\n- Classes are for Python\n\n#### Rect\n\n- *struct* Rect\n\n    * Given center of the robot is (0, 0)\n    * **Parameters**:\n      - **xmin** - floating-point minimum x-coordinate of the robot.\n      - **ymin** - floating-point minimum y-coordinate of the robot.\n      - **xmax** - floating-point maximum x-coordinate of the robot.\n      - **ymax** - floating-point maximum y-coordinate of the robot.\n\n#### Config\n\n- *struct* Config\n\n    * **Parameters**:\n        - **maxSpeed** - floating-point maximum linear speed robot can reach [m/s]\n        - **minSpeed** - floating-point minimum linea speed robot can fall [m/s]\n        - **maxYawrate** - floating-point maximum angular speed robot can reach [yaw/s]\n        - **maxAccel** - floating-point maximum linear acceleration robot can reach [m/ss]\n        - **maxdYawrate** - floating-point maximum angular acceleration robot can reach [yaw/ss]\n        - **velocityResolution** - floating-point linear speed resolution [m/s]\n        - **yawrateResolution** - floating-point angular speed resolution [m/s]\n        - **dt** - floating-point time change [s]\n        - **predictTime** - floating-point simulation time [s]\n        - **heading** - floating-point heading cost weight\n        - **clearance** - floating-point clearance cost weight\n        - **velocity** - floating-point velocity cost weight\n        - **base** - [Rect](#rect)\n\n- *class* Config\n\n    ``` python\n    Config(float max_speed, float min_speed,\n           float max_yawrate, float max_accel, float max_dyawrate,\n           float velocity_resolution, float yawrate_resolution, float dt,\n           float predict_time, float heading, float clearance, float velocity,\n           list base)\n    ```\n\n#### Velocity\n\n- *struct* Velocity\n\n    * **Parameters**:\n        - **linearVelocity** - floating-point linear velocity of the robot [m/s]\n        - **angularVelocity** - floating-point angular velocity of the robot [yaw/s]\n\n- *class* Velocity\n\n    ``` python\n    Velocity(float linear_velocity, float angular_velocity)\n    ```\n\n#### Point\n\n- *struct* Point\n\n    * **Parameters**:\n        - **x** – floating-point x-coordinate of the point.\n        - **y** – floating-point y-coordinate of the point.\n\n- *class* Point\n\n    ``` python\n    Point(float x, float y)\n    ```\n\n#### PointCloud\n\n- *struct* PointCloud\n\n  * int **size**\n    - Number of points.\n  * Point ***points**\n    - Array of [points](#point).\n\n- *class* PointCloud\n\n    ``` python\n    PointCloud(np.ndarray[np.float32_t, ndim=2] point_cloud)\n    ```\n\n#### Pose\n\n- *struct* Pose\n  * Point **point**\n    - Coordinate of the robot.\n  * float **yaw**\n    - Angle of the robot.\n\n- *class* Pose\n\n    ``` python\n    Pose(Point point, float yaw)\n    ```\n\n#### DynamicWindow\n\n- *struct* DynamicWindow\n  * int **nPossibleV**:\n    - Number of linear velocities in the Dynamic Window.\n  * float ***possibleV**:\n    - Array of linear velocities with resolution of [Config.velocityResolution](#config)\n  * int **nPossibleW**:\n    - Number of angular velocities in the Dynamic Window\n  * float ***possibleW**:\n    - Array of angular velocities with resolution of [Config.yawrateResolution](#config)\n\n- *class* DynamicWindow\n\n    ```python\n    DynamicWindow(tuple velocity, Config config)\n    ```\n\n### Functions\n\n#### planning\n\nCalculates best linear and angular velocities given the state. Only\nrequired function to use this library.\n\n- C\n\n    ``` c++\n    Velocity planning (Pose pose, Velocity velocity, Point goal, PointCloud *pointCloud, Config config);\n    ```\n\n    * **Parameters:**\n        - **pose:** [Pose](#pose)\n        - **velocity:** [Velocity](#velocity)\n        - **goal:** [Point](#point)\n        - **pointCloud:** [PointCloud](#pointcloud)\n        - **config:** [Config](#config)\n\n- Python\n\n    ``` python\n    linear_velocity, angular_velocity = planning(pose, velocity, goal, point_cloud, config)\n    ```\n\n    * **Parameters:**\n        - **pose:** tuple: (x, y, yaw)\n        - **velocity:** tuple: (Linear Velocity, Angular Velocity)\n        - **goal:** tuple: (x, y)\n        - **point_cloud:** Numpy Array of shape (N, 2) and type np.float32\n        - **config:** [Config](#config)\n\n#### createDynamicWindow\n\nGiven robot configuration and current velocities, calculates [DynamicWindow](#dynamicwindow).\nThe memory is allocated dynamically inside of the function and must be freed using \n[freeDynamicWindow](#freedynamicwindow) function.\n\n- C\n\n    ``` c++\n    void createDynamicWindow(Velocity velocity, Config config, DynamicWindow **dynamicWindow);\n    ```\n\n    * **Parameters:**\n        - **velocity:** [Velocity](#velocity)\n        - **config:** [Config](#config)\n        - **dynamicWindow:** [DynamicWindow](#dynamicwindow)\n\n- Python\n\n    [DynamicWindow](#dynamicwindow) class is used to create a DynamicWindow instance.\n\n    ``` python\n    dw = dwa.DynamicWindow(velocity, config):\n    print(dw.possible_v, dw.possible_w)\n    ```\n\n    * **Parameters:**\n        - **velocity:** tuple: (Linear Velocity, Angular Velocity)\n        - **config:** [Config](#config) class\n\n![Dynamic Window \u003ccite\u003e[2]\u003c/cite\u003e](https://raw.githubusercontent.com/goktug97/DynamicWindowApproach/master/img/dynamic_window.jpg)\n\n#### freeDynamicWindow\n\nFree dynamically allocated memory.\n\n- C\n\n    ``` c++\n    void freeDynamicWindow(DynamicWindow *dynamicWindow);\n    ```\n\n    * **Parameters:**\n        - **dynamicWindow:** [DynamicWindow](#dynamicwindow)\n\n- Python\n\n    Handled by the [DynamicWindow](#dynamicwindow) class. See below.\n\n    ``` python\n    def __dealloc__(self):\n        if self.thisptr is not NULL:\n            cdwa.freeDynamicWindow(self.thisptr)\n\n    ```\n\n#### motion\n\nGiven current position and velocities, calculates next position after\ngiven dt using differential drive motion model. Can be used to\nsimulate motion in a simulated environment.\n\n- C\n\n    ``` c++\n    Pose motion(Pose pose, Velocity velocity, float dt);\n    ```\n\n    * **Parameters:**\n        - **pose:** [Pose](#pose)\n        - **velocity:** [Velocity](#velocity)\n        - **dt:** float (seconds)\n\n- Python\n\n    ``` python\n    x, y, yaw = motion(pose, velocity, dt)\n    ```\n\n    * **Parameters:**\n        - **pose:** tuple: (x, y, yaw)\n        - **velocity:** tuple: (Linear Velocity, Angular Velocity)\n\n#### calculateVelocityCost\n\n- C\n\n    ``` c++\n    float calculateVelocityCost(Velocity velocity, Config config);\n    ```\n\n    * **Parameters:**\n        - **velocity:** [Velocity](#velocity)\n        - **config:** [Config](#config)\n\n- Python\n\n    ``` python\n    velocity_cost = calculate_velocity_cost(velocity, config)\n    ```\n\n    * **Parameters:**\n        - **velocity:** tuple: (Linear Velocity, Angular Velocity)\n        - **config:** [Config](#config)\n\n#### calculateHeadingCost\n\n- C\n\n    ``` c++\n    float calculateHeadingCost(Pose pose, Point goal);\n    ```\n\n    * **Parameters:**\n        - **pose:** [Pose](#pose)\n        - **goal:** [Point](#point)\n\n- Python\n\n    ``` python\n    heading_cost = calculate_heading_cost(pose, goal)\n    ```\n\n    * **Parameters:**\n        - **pose:** tuple: (x, y, yaw)\n        - **goal:** tuple: (x, y)\n\n#### calculateClearanceCost\n\n- C\n\n    ``` c++\n    float calculateClearanceCost(Pose pose, Velocity velocity, PointCloud *pointCloud, Config config);\n    ```\n\n    * **Parameters:**\n        - **pose:** [Pose](#pose)\n        - **velocity:** [Velocity](#velocity)\n        - **pointCloud:** [PointCloud](#pointcloud)\n        - **config:** [Config](#config)\n\n- Python\n\n    ``` python\n    clearance_cost = calculate_clearance_cost(pose, velocity, point_cloud, config)\n    ```\n\n    * **Parameters:**\n        - **pose:** tuple: (x, y, yaw) \n        - **velocity:** tuple: (Linear Velocity, Angular Velocity)\n        - **point_cloud:** Numpy Array of shape (N, 2) and type np.float32\n        - **config:** [Config](#config)\n\n#### createPointCloud\n\nGiven a size, creates a [PointCloud](#pointcloud). Must be freed using [freePointCloud](#freepointcloud).\n\n- C\n\n    ``` c++\n    PointCloud* createPointCloud(int size);\n    ```\n\n    ``` c++\n    for (int i = 0; i \u003c pointCloud-\u003esize; ++i) {\n      pointCloud-\u003epoints[i].x = 0.0\n      pointCloud-\u003epoints[i].y = 0.0\n    }\n    ```\n\n    * **Parameters:**\n        - **size:** int\n\n- Python\n\n    [PointCloud](#pointcloud) class is used to create a PointCloud instance. All\n    functions in python accepts numpy array instead of PointCloud instance. The\n    PointCloud instance is created inside of the function.\n\n    ``` python\n    size = 600\n    point_cloud = np.zeros((size, 2), dtype=np.float32)\n    point_cloud = dwa.PointCloud(point_cloud)\n    ```\n\n#### freePointCloud\n\n- C\n\n    ``` c++\n    void freePointCloud(PointCloud* pointCloud);\n    ```\n\n    * **Parameters:**\n        - **pointCloud:** [PointCloud](#pointcloud)\n\n- Python\n\n    Handled by the [PointCloud](#pointcloud) class. See below.\n\n    ``` python\n    def __dealloc__(self):\n        if self.thisptr is not NULL:\n            cdwa.freePointCloud(self.thisptr)\n    ```\n\n## References\n\n\u003ca name=\"ref1\"/\u003e\n\n1. D. Fox, W. Burgard and S. Thrun, \"The dynamic window approach to\ncollision avoidance,\" in IEEE Robotics \u0026 Automation Magazine, vol. 4,\nno. 1, pp. 23-33, March 1997.  doi: 10.1109/100.580977 URL:\nhttp://ieeexplore.ieee.org/stamp/stamp.jsp?tp=\u0026arnumber=580977\u0026isnumber=12589\n\n\u003ca name=\"ref2\"/\u003e\n\n2. http://ais.informatik.uni-freiburg.de/teaching/ss19/robotics/slides/19-pathplanning-long.pdf\n\n## License\nMIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoktug97%2Fdynamicwindowapproach","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoktug97%2Fdynamicwindowapproach","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoktug97%2Fdynamicwindowapproach/lists"}