{ "info": { "author": "Oleg Sinyavskiy", "author_email": "olegsinyavskiy@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Python bindings for Sparse-RRT planner\n\nThis package is based on Sparse-RRT project https://bitbucket.org/pracsys/sparse_rrt/.\nThe main purpose of this work is to allow running Sparse-RRT planner in python environment. \nHere are the main contributions:\n - C++ experiments from original package are executable from Python while preserving speed, SVG visualizations and statistics\n - Controllable systems for the planners can be completely written in Python, while planners are executed in C++. This is not so slow as it sounds - the average slowdown is only 2-3x for system propagation.\n - C++ code of planners, utilities and systems underwent a lot of refactoring using moder C++11 features. Python bindings are done using pybind11\n - C++ implementation of planners, utilities and systems used to contain many memory leaks that prevent running planning multiple times. This was fixed in the current implementation.\n\nThe original codebase or SST planner is small enough to be easily understood and customized as opposed to OMPL SST implementation.\n\n## INSTALLING\nTo install the package just run pip:\n\n```\npip install sparse-rrt\n```\n\n## STANDARD EXPERIMENTS\nTo run a standard prepackaged experiment without visualization:\n```python\nfrom sparse_rrt.experiments import run_standard_experiment\nrun_standard_experiment('sst_car', visualization=False)\n```\n\nThis will run SST planner for non-holonomic car system, implemented in C++ and print out statistics.\nRight now, the reported statistics are the number of iterations \nexecuted, the number of nodes stored, and the solution length in \nseconds.\n\nThere are many more pre-packaged experiments. Run the following to get a list of them:\n```python\nfrom sparse_rrt.experiments import run_standard_experiment\nfor exp in available_standard_experiments():\n print(exp)\n```\n\n## VISUALIZATION\n\nWhen running experiments, in addition to the terminal output,\nvisualization images can be displayed in the standalone window. This project inherits SVG-based visualization from original C++ codebase. There are few convenience functions\nto display SVG images, to convert them to RGB numpy arrays or to display them in a window.\nVisualization dependencies are not included in the package dependencies to ease installation. \nHere are the packages that you may need to install to run visualization:\n - `PySide` or `cairosvg` - to render SVG in python. `PySide` is considerably faster (to install run `pip install pyside` or `pip install cairosvg`)\n - `PySide` or `python-opencv` - to open windows and display numpy images (`show_image` function). To install opencv, you can follow https://www.learnopencv.com/install-opencv3-on-ubuntu/\n - `svgwrite` - to write SVG files from python. This is needed only if you use visualization of Systems written in python (to install run `pip install svgwrite`)\n\nThe simplest option is to just install `PySide`. Here is how you can run standard experiment with visualization.\n```python\nfrom sparse_rrt.experiments import run_standard_experiment\nrun_standard_experiment('sst_car', visualization=True)\n```\n\n## CUSTOM EXPERIMENTS\nExperiments are described using a python dictionary as a config. Examples of configs can be found in the `experiments` folder.\nYou can run custom experiment by creating your own config. For example, the following is going to run RRT planner with Point system with custom goal point:\n\n```python\nfrom sparse_rrt.experiments.experiment_utils import run_config\npoint_config = dict(\n system='point',\n planner='rrt',\n start_state=[9., 9.],\n goal_state=[-9., 9.],\n goal_radius=0.5,\n random_seed=100,\n integration_step=0.02,\n min_time_steps=2,\n max_time_steps=20,\n number_of_iterations=300000,\n display_type='tree'\n)\nrun_config(point_config)\n```\n\nExperiment configs have a parameter `display_type` that can be either\n - `None`: no display\n - `'tree'`: image window shows the resulting tree of the motion\nplanner along with the solution path.\n - `'nodes'`: image windo shows the cost at each node in the tree. Darker nodes represent lower cost (better)\nwhile lighter nodes denote higher cost.\n\n## CUSTOM SYSTEMS\nOne of the main goals of this project is ability to plan for custom systems written in python.\nIn order to implement a custom system, you need to implement `sparse_rrt.systems.system_interface.ISystem` interface.\nThe main function to implement is `propagate` that is responsible for system dynamics and collision detection.\nSee docstrings for detailed documentation. A helper base class `sparse_rrt.systems.system_interface.BaseSystem` is provided for easy\ncreation of the most common systems. Here is the simplest example of a free point in 2D:\n```python\nimport numpy as np\nfrom sparse_rrt.systems.system_interface import BaseSystem\n\nclass FreePoint(BaseSystem):\n '''\n A simple system implementing a 2d point. It's controls include velocity and direction.\n '''\n MIN_X, MAX_X = -10, 10 # min and max X coordinate of a point\n MIN_Y, MAX_Y = -10, 10 # min and max Y coordinate of a point\n MIN_V, MAX_V = 0., 10. # min and max control velocity\n MIN_THETA, MAX_THETA = -3.14, 3.14 # min and max control direction\n\n def propagate(self, start_state, control, num_steps, integration_step):\n '''\n Integrate system dynamics\n :param start_state: numpy array with the start state for the integration\n :param control: numpy array with constant controls to be applied during integration\n :param num_steps: number of steps to integrate\n :param integration_step: dt of integration\n :return: new state of the system\n '''\n control_v = np.array([control[0] * np.cos(control[1]), control[0] * np.sin(control[1])])\n trajectory = start_state + np.arange(num_steps)[:, None]*integration_step*control_v\n state = np.clip(trajectory[-1], [self.MIN_X, self.MIN_Y], [self.MAX_X, self.MAX_Y])\n return state\n\n def visualize_point(self, state):\n '''\n Project state space point to 2d visualization plane\n :param state: numpy array of the state point\n :return: x, y of visualization coordinates for this state point\n '''\n x = (state[0] - self.MIN_X) / (self.MAX_X - self.MIN_X)\n y = (state[1] - self.MIN_Y) / (self.MAX_Y - self.MIN_Y)\n return x, y\n\n def get_state_bounds(self):\n '''\n Return bounds for the state space\n :return: list of (min, max) bounds for each coordinate in the state space\n '''\n return [(self.MIN_X, self.MAX_X),\n (self.MIN_Y, self.MAX_Y)]\n\n def get_control_bounds(self):\n '''\n Return bounds for the control space\n :return: list of (min, max) bounds for each coordinate in the control space\n '''\n return [(self.MIN_V, self.MAX_V),\n (self.MIN_THETA, self.MAX_THETA)]\n\n def is_circular_topology(self):\n '''\n Indicate whether state system has planar or circular topology\n :return: boolean flag for each coordinate (False for planar topology)\n '''\n return [False, False]\n```\n\nIn order to plan with your custom system, you can pass it in a `config['system']` field.\n\nAlternatively, it is very easy to write a custom simulation completely from scratch:\n```python\nfrom sparse_rrt.planners import SST\n\n# Create custom system\nsystem = FreePoint()\n# Create SST planner \nplanner = SST(\n state_bounds=system.get_state_bounds(),\n control_bounds=system.get_control_bounds(),\n distance=system.distance_computer(),\n start_state=np.array([0., 0.]),\n goal_state=np.array([9., 9.]),\n goal_radius=0.5,\n random_seed=0,\n sst_delta_near=0.4,\n sst_delta_drain=0.2\n)\n\n# Run planning and print out solution is some statistics every few iterations.\nfor iteration in range(1000):\n planner.step(system, 2, 20, 0.1)\n if iteration % 100 == 0:\n solution = planner.get_solution()\n print(\"Solution: %s, Number of nodes: %s\" % (planner.get_solution(), planner.get_number_of_nodes()))\n\n```", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/olegsinyavskiy/sparse_rrt", "keywords": "", "license": "BSD License 2.0", "maintainer": "", "maintainer_email": "", "name": "sparse-rrt", "package_url": "https://pypi.org/project/sparse-rrt/", "platform": "", "project_url": "https://pypi.org/project/sparse-rrt/", "project_urls": { "Homepage": "https://github.com/olegsinyavskiy/sparse_rrt" }, "release_url": "https://pypi.org/project/sparse-rrt/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "Sparse stable trees planner", "version": "0.0.2" }, "last_serial": 3932834, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "bd3a4a5343dd886b13606342c5a8474b", "sha256": "a3e9c3182e9b8f8813f54dbaa4b05d4c40cfffd3c7f4e3bec06ad1d0bbd9365b" }, "downloads": -1, "filename": "sparse_rrt-0.0.2.tar.gz", "has_sig": false, "md5_digest": "bd3a4a5343dd886b13606342c5a8474b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 635562, "upload_time": "2018-06-05T16:16:05", "url": "https://files.pythonhosted.org/packages/82/e3/206210a604fd2cac0f965180512870d002041a52780aeb8370e43c633d69/sparse_rrt-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bd3a4a5343dd886b13606342c5a8474b", "sha256": "a3e9c3182e9b8f8813f54dbaa4b05d4c40cfffd3c7f4e3bec06ad1d0bbd9365b" }, "downloads": -1, "filename": "sparse_rrt-0.0.2.tar.gz", "has_sig": false, "md5_digest": "bd3a4a5343dd886b13606342c5a8474b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 635562, "upload_time": "2018-06-05T16:16:05", "url": "https://files.pythonhosted.org/packages/82/e3/206210a604fd2cac0f965180512870d002041a52780aeb8370e43c633d69/sparse_rrt-0.0.2.tar.gz" } ] }