{ "info": { "author": "Radek Szamrej", "author_email": "rstechnology@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# rstoys\n\nCross platform lightweight python library to help creating interactive real-time, remote controlled toys (typically based on Raspberry Pi). Library provides set of independent reusable modules described below.\n\nSource code can be found at [https://github.com/rstgh/rstoys](https://github.com/rstgh/rstoys)\n\nPlease use pip to install this package:\n\n```sh\npip install rstoys\npip install flask # if you plan to use rstoys.touchy\npip install arcade # if you plan to use rstoys.maps\n```\n\n## rstoys.realtime\n\nRealtime module provides some functions related to realtime main loop processing functionality.\nAll time or interval values are expressed in `seconds`.\n\n### `realtime.loop(callback, update_interval=0.020)`\n\nthis function enters an infinite loop calling your `callback` function with two parameters `(elapsed_time, delta_time)` at specified update_interval.\n\n- `elapsed_time` - is an absolute elapsed time in seconds starting with 0 at the beginning\n- `delta_time` - is a delta time in seconds since last execution of your callback function, can be used to scale your robot actions to make it more cpu load independent.\n\nIt is an equivalent of:\n\n```python\nwhile True:\n callback(elapsed_time, delta_time)\n sleep(update_interval)\n```\n\nUsing the realtime.loop() has an advantage that it dynamically adjusts the sleep time to compensate for the time spent in your callback, trying to provide as stable `callback` calling interval as possible.\n\nSo far the only way to exit this loop is by pressing `CTRL+C`.\n\nExample usage:\n\n```python\nfrom rstoys import realtime\n\ndef update(elapsed_time, delta_time):\n print(\"elapsed=%08.3fs | dt=%06.3fms\" % (elapsed_time, delta_time * 1000))\n\n# initialize my hardware here\n\n# enter the loop that calls update function every 100ms\nrealtime.loop(update, 0.1)\n```\n\n### `realtime.Interval(interval = 1.0)`\n\nSimplifies periodic execution with given interval.\n\nUsage:\n\n```python\nfrom rstoys import realtime\n\nevery1s = realtime.Interval(1.0)\nevery3s = realtime.Interval(3.0)\n\ndef update(elapsed_time, delta_time):\n\n print(\"Every 100ms\")\n\n if every1s.should(delta_time):\n print(\"Once per second\")\n\n if every3s.should(delta_time):\n print(\"Once every 3 seconds\")\n\n\nrealtime.loop(update, 0.1)\n``` \n\n### `realtime.Mapper(value)`\n\nProvides fluent interface to map given input value via following methods, all methods are symmetrical for negative values.\n\n`.copy()` # creates a copied instance\n\n`.value()` # returns final value\n\n`.add(o = 0.0)` # value = value + o\n\n`.mul(s = 1.0)` # value = value * s\n\n`.trim(min = -1.0, max = -1.0)` # trims a value into given min max range\n\n`.exp(e = math.e)` # value = e ^ value\n\n`.pow(p = 1.0)` # value = value ^ p\n\n`.gap(g = 0.0)` # returns value if value <= -g or value >= g else 0.0\n\n`.gaplin(g = 0.0, m = 1.0)` # similar to gap, but then over g interpolates linearly from 0 to m\n\n\n## rstoys.touchy\n\nThis module provides a mobile friendly web interface with basic touch stick controller for (x, y) values that can be easily read in your python code for controlling your robot.\n\n### `touchy.start_server(port=80)`\n\nStarts simple flask webserver instance on a given port that is running in a separate thread this webserver can be reached:\n\nLocally `http://127.0.0.1:/` or remotely by using your IP address of the RPi instead of 127.0.0.1\n\n### `touchy.stop_server()`\n\nStops touchy webserver and terminates its thread.\n\n### `(x, y) = touchy.controller.getStick()`\n\nThis function returns (x, y) tupple representing touch stick controller position.\nvalues are in range of `[-1...0...1]`.\n\nExample code:\n\n```python\nfrom rstoys import touchy\nfrom rstoys import realtime\n\ndef update(elapsed_time, delta_time):\n (x, y) = touchy.controller.getStick()\n print(\"elapsed=%08.3fs | dt=%06.3fms | X=%6.3f | Y=%6.3f\" % (elapsed_time, delta_time * 1000, x, y))\n\ntouchy.start_server(port=5000)\nrealtime.loop(update)\ntouchy.stop_server()\n```\n... then open `http://:5000/` in your mobile browser and move the on-screen stick to see the changes.\n\n## rstoys.geo\n\nThis module provides simple geo location related functionality to help building location aware navigation based on bearing adjustments. It properly calculates absolute bearing between two geo locations, provides correct `average_bearing()` method as well as simple `WebMercatorProjection` implementation. \n\nPlease check out [example-geo.py](https://github.com/rstgh/rstoys/blob/master/example-geo.py) file for more usage examples. \n\n### `geo.LatLon(lat, lon)`\n\ngeo location point with latitude and longitude\n\n```python\nmunich = geo.LatLon(48.133333, 11.566667)\n# accepts also lat lon as string comma separated\nmunich = geo.LatLon('48.133333,11.566667')\n```\n\n\n## rstoys.maps\n\nProvides basic open-maps window rendering using arcade framework to provide visualization of geo data.\n\nPlease check out [example-maps-sailing.py](https://github.com/rstgh/rstoys/blob/master/example-maps-sailing.py) file for some usage examples. \n\n\n### Development\n\nWant to contribute? Just send me an e-mail: `rstechnology@gmail.com`\n\n## License\n\nMIT\n\nUse at your own risk and have fun.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/rstgh/rstoys", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "rstoys", "package_url": "https://pypi.org/project/rstoys/", "platform": "", "project_url": "https://pypi.org/project/rstoys/", "project_urls": { "Homepage": "https://github.com/rstgh/rstoys" }, "release_url": "https://pypi.org/project/rstoys/1.1.3/", "requires_dist": null, "requires_python": "", "summary": "Library for simple real-time control of robotic toys.", "version": "1.1.3", "yanked": false, "yanked_reason": null }, "last_serial": 6076157, "releases": { "1.0.7": [ { "comment_text": "", "digests": { "md5": "148a68133ac3214f9c2cb5ac90495481", "sha256": "4dd3185e37aac9718c0d468b92e9c5ad4d57f64eadf4e110efdf95aefc3af0a1" }, "downloads": -1, "filename": "rstoys-1.0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "148a68133ac3214f9c2cb5ac90495481", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 86243, "upload_time": "2019-10-23T15:54:40", "upload_time_iso_8601": "2019-10-23T15:54:40.274348Z", "url": "https://files.pythonhosted.org/packages/c5/d0/c787884fed0166a1cfcb19eb1819960a031b2989402b4cddef4836d56c1c/rstoys-1.0.7-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "0662fef4d7dbc9fdb7cd020c09e4c9b9", "sha256": "88a00045e8a53c56a001bef5c638d4f7a2f2946997cc2a0119241bd0f0851240" }, "downloads": -1, "filename": "rstoys-1.0.7.tar.gz", "has_sig": false, "md5_digest": "0662fef4d7dbc9fdb7cd020c09e4c9b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 87492, "upload_time": "2019-10-23T15:54:42", "upload_time_iso_8601": "2019-10-23T15:54:42.098907Z", "url": "https://files.pythonhosted.org/packages/d3/f4/cd06941a2dfad963db99495476913cdb7532c19e8d9d5d3d60c78759ae50/rstoys-1.0.7.tar.gz", "yanked": false, "yanked_reason": null } ], "1.0.9": [ { "comment_text": "", "digests": { "md5": "9bc71034e96fa8a892d6428c9d9eb14a", "sha256": "3379545eb98a1c1c4cc8f56de861fe7f496a35ad79251cb389764a242ac8e72b" }, "downloads": -1, "filename": "rstoys-1.0.9-py3-none-any.whl", "has_sig": false, "md5_digest": "9bc71034e96fa8a892d6428c9d9eb14a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 75820, "upload_time": "2019-10-23T20:50:15", "upload_time_iso_8601": "2019-10-23T20:50:15.005469Z", "url": "https://files.pythonhosted.org/packages/3e/49/c2c792a0fe2c99b1256b6afc4014f45e7b572c0b9a498492a7670be87da1/rstoys-1.0.9-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "7ceb130d98af61651855d9ca8500aa8f", "sha256": "f9b2f1a17cc6cd54b5b8cb689375c49588b419da6ef42c6bee0f9253f3a5596e" }, "downloads": -1, "filename": "rstoys-1.0.9.tar.gz", "has_sig": false, "md5_digest": "7ceb130d98af61651855d9ca8500aa8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 77329, "upload_time": "2019-10-23T20:50:16", "upload_time_iso_8601": "2019-10-23T20:50:16.902713Z", "url": "https://files.pythonhosted.org/packages/0a/69/44258654ae6cc12a1630d8f73f7af10f8a945f00d932bc7d0f80c24159f1/rstoys-1.0.9.tar.gz", "yanked": false, "yanked_reason": null } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "aad40ac8fb91edefe07a4fb983773931", "sha256": "eaa033c0391203f581fc7cd9b2ff7c7b282933b12a487481e52eadab055915e4" }, "downloads": -1, "filename": "rstoys-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "aad40ac8fb91edefe07a4fb983773931", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 77176, "upload_time": "2019-10-28T11:10:40", "upload_time_iso_8601": "2019-10-28T11:10:40.264754Z", "url": "https://files.pythonhosted.org/packages/8a/d8/3d59b2e020319d64d13a169d0203259c6f79344326ce027371bf863bb1ee/rstoys-1.1.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "b05fec45dbc162708e1c477d92eb5ee9", "sha256": "89649ff5a1f0930267fb53ad74102917864ccf9fdbaa48f65786d5c8216ffc6f" }, "downloads": -1, "filename": "rstoys-1.1.0.tar.gz", "has_sig": false, "md5_digest": "b05fec45dbc162708e1c477d92eb5ee9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 79090, "upload_time": "2019-10-28T11:10:42", "upload_time_iso_8601": "2019-10-28T11:10:42.146952Z", "url": "https://files.pythonhosted.org/packages/97/7f/b66f0ce76e6c62af849b410839b34391e48544093a5a48586402f16ba0fc/rstoys-1.1.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "68e09a0ec9c5579b1a0838fbf127fb8a", "sha256": "ab219f5f27d1255a39692bfee36076568f1e0170d63810b8aa6817353b24fc88" }, "downloads": -1, "filename": "rstoys-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "68e09a0ec9c5579b1a0838fbf127fb8a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 77320, "upload_time": "2019-10-28T13:07:37", "upload_time_iso_8601": "2019-10-28T13:07:37.714877Z", "url": "https://files.pythonhosted.org/packages/df/1f/21bcc704f6b43693de8dc730e7f041a05007d9aabb89fc907cc4d5173e4a/rstoys-1.1.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "d59d36275514e3247708d87cb2803dc8", "sha256": "a844ea31e20099d5f29c7c4ed495c24e98205f814afd3200391029a89bc2fb53" }, "downloads": -1, "filename": "rstoys-1.1.1.tar.gz", "has_sig": false, "md5_digest": "d59d36275514e3247708d87cb2803dc8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 79249, "upload_time": "2019-10-28T13:07:39", "upload_time_iso_8601": "2019-10-28T13:07:39.367701Z", "url": "https://files.pythonhosted.org/packages/ba/37/38659b391256bcc34975d9435a2c268ee5b8b1ba284e087e0f0c9833e334/rstoys-1.1.1.tar.gz", "yanked": false, "yanked_reason": null } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "d1a2fc4978975cb745408d8b4346afde", "sha256": "d9c7a48d21ca61b34561e46adc909f5a917fd2443aa9235a9a5731078ea97ba5" }, "downloads": -1, "filename": "rstoys-1.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "d1a2fc4978975cb745408d8b4346afde", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 77729, "upload_time": "2019-10-29T13:44:06", "upload_time_iso_8601": "2019-10-29T13:44:06.639465Z", "url": "https://files.pythonhosted.org/packages/7c/ed/55fc3082eff98c5e71fe7f3296492dfcce4297901f30a9176e685c054fc8/rstoys-1.1.2-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "4a8957dd6c8faaef8fbd690896dacc21", "sha256": "ea2f23f0428a7a505a56a913e5b9f726093d71053242c659953c260e7c928817" }, "downloads": -1, "filename": "rstoys-1.1.2.tar.gz", "has_sig": false, "md5_digest": "4a8957dd6c8faaef8fbd690896dacc21", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 79724, "upload_time": "2019-10-29T13:44:08", "upload_time_iso_8601": "2019-10-29T13:44:08.438763Z", "url": "https://files.pythonhosted.org/packages/da/da/d0d78a7d75c7775198287ef4b99b18dde1d7f55f1147a069c5785a043945/rstoys-1.1.2.tar.gz", "yanked": false, "yanked_reason": null } ], "1.1.3": [ { "comment_text": "", "digests": { "md5": "9f1b103cbe70c4b3746008f0b6e988c3", "sha256": "2130024afcf6e9e61e65742ea9e42ec1736cd3e54ee2793c6b7eba6f556a1623" }, "downloads": -1, "filename": "rstoys-1.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "9f1b103cbe70c4b3746008f0b6e988c3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 110215, "upload_time": "2019-11-04T15:29:24", "upload_time_iso_8601": "2019-11-04T15:29:24.142325Z", "url": "https://files.pythonhosted.org/packages/d6/9b/c307006f12a4eea1aebd9b2dcfd622bac6c9485f6b9e587d897d0ef9ce27/rstoys-1.1.3-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "bf978fd17194bd59e50956d75b424c38", "sha256": "b6b381d3f9e522b3e657824ac4ea9141ab484809032272aff0d1a8e7aacda108" }, "downloads": -1, "filename": "rstoys-1.1.3.tar.gz", "has_sig": false, "md5_digest": "bf978fd17194bd59e50956d75b424c38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 112226, "upload_time": "2019-11-04T15:29:26", "upload_time_iso_8601": "2019-11-04T15:29:26.190282Z", "url": "https://files.pythonhosted.org/packages/03/31/36a146affd68f662533a7404da64fb84d519fafe10ccab0fd9adbc71a663/rstoys-1.1.3.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9f1b103cbe70c4b3746008f0b6e988c3", "sha256": "2130024afcf6e9e61e65742ea9e42ec1736cd3e54ee2793c6b7eba6f556a1623" }, "downloads": -1, "filename": "rstoys-1.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "9f1b103cbe70c4b3746008f0b6e988c3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 110215, "upload_time": "2019-11-04T15:29:24", "upload_time_iso_8601": "2019-11-04T15:29:24.142325Z", "url": "https://files.pythonhosted.org/packages/d6/9b/c307006f12a4eea1aebd9b2dcfd622bac6c9485f6b9e587d897d0ef9ce27/rstoys-1.1.3-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "bf978fd17194bd59e50956d75b424c38", "sha256": "b6b381d3f9e522b3e657824ac4ea9141ab484809032272aff0d1a8e7aacda108" }, "downloads": -1, "filename": "rstoys-1.1.3.tar.gz", "has_sig": false, "md5_digest": "bf978fd17194bd59e50956d75b424c38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 112226, "upload_time": "2019-11-04T15:29:26", "upload_time_iso_8601": "2019-11-04T15:29:26.190282Z", "url": "https://files.pythonhosted.org/packages/03/31/36a146affd68f662533a7404da64fb84d519fafe10ccab0fd9adbc71a663/rstoys-1.1.3.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }