From c889fb41bb7aa56716364f0ae593219cb146a823 Mon Sep 17 00:00:00 2001 From: Roberto Date: Sat, 9 Jul 2022 00:28:33 +0200 Subject: [PATCH] prepare v4.1 (#163) - tf 2.7 - fix 4.1 bugs - Update wifi.py => changed approach: the daemons (hostapd, dhcpcd, wpa_supplicant) are started by systemd, wify.py is used to change config and verify connectivity in client mode. - add CONTRIBUTING.md (#162) Co-authored-by: previ Co-authored-by: Antonio Vivace --- CONTRIBUTING.md | 336 ++++++++++++++++++++++++++++++++ api.py | 2 +- camera.py | 13 -- coderbot.cfg | 47 ++++- coderbot.py | 19 +- data/activities.json | 1 - data/defaults/config.json | 80 ++++---- main.py | 11 +- static/js/blockly/blocks.js | 21 -- static/media/coderdojo-logo.png | Bin 3937 -> 0 bytes templates/blocks_adv.xml | 1 - templates/blocks_std.xml | 1 - wifi.py | 76 ++++---- 13 files changed, 490 insertions(+), 118 deletions(-) create mode 100644 CONTRIBUTING.md delete mode 100644 data/activities.json delete mode 100644 static/media/coderdojo-logo.png diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..31ed3caa --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,336 @@ +That's correct, at least for linking existing material and, overall, providing and overview of the project and the (now many) components. + +As for the "CONTRIBUTING" document, I will prepare something inspired by [this](), according to these [general guidelines](https://mozillascience.github.io/working-open-workshop/contributing/). + +# Contributing to CoderBot + +:+1::robot: Thanks for your interest in the CoderBot project! :robot::+1: + +The following is a set of guidelines for contributing to CoderBot and its modules, which are hosted in the [CoderBot Organization](https://github.com/CoderBotOrg) on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. + +#### Table Of Contents + +[Code of Conduct](#code-of-conduct) + +[What should I know before I get started?](#what-should-i-know-before-i-get-started) + * [CoderBot project description](#coderbot-project-description) + * [CoderBot architecture](#coderbot-architecture) + +[How Can I Contribute?](#how-can-i-contribute) + * [Reporting Bugs](#reporting-bugs) + * [Suggesting Enhancements](#suggesting-enhancements) + * [Your First Code Contribution](#your-first-code-contribution) + * [Pull Requests](#pull-requests) + +[Styleguides](#styleguides) + * [Git Commit Messages](#git-commit-messages) + * [JavaScript Styleguide](#javascript-styleguide) + * [CoffeeScript Styleguide](#coffeescript-styleguide) + * [Specs Styleguide](#specs-styleguide) + * [Documentation Styleguide](#documentation-styleguide) + +[Additional Notes](#additional-notes) + * [Issue and Pull Request Labels](#issue-and-pull-request-labels) + +## Code of Conduct + +This project and everyone participating in it is governed by the [CoderBot Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [info@coderbot.org](info@coderbot.org). + +## What should I know before I get started? + +### CoderBot project description + +CoderBot is an open source project with the objective of providing the hardware and software used in the educational robot with the same name. + +It is composed by several [repositories](https://github.com/CoderBotOrg). When you initially consider contributing to CoderBot, you might be unsure about which of those repositories implements the functionality you want to change or report a bug for. This section should help you with that. + +#### Package Conventions + +### CoderBot architecture + +## How Can I Contribute? + +### Reporting Bugs + +This section guides you through submitting a bug report for CoderBot. Following these guidelines helps maintainers and the community understand your report :pencil:, reproduce the behavior :computer: :computer:, and find related reports :mag_right:. + +Before creating bug reports, please check [this list](#before-submitting-a-bug-report) as you might find out that you don't need to create one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). Fill out [the required template](https://github.com/CoderBotOrg/.github/blob/master/.github/ISSUE_TEMPLATE/bug_report.md), the information it asks for helps us resolve issues faster. + +> **Note:** If you find a **Closed** issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one. + +#### Before Submitting A Bug Report + +* TODO + +#### How Do I Submit A (Good) Bug Report? + +Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you've determined [which repository](#coderbot-and-repos) your bug is related to, create an issue on that repository and provide the following information by filling in [the template](https://github.com/CoderBotOrg/.github/blob/master/.github/ISSUE_TEMPLATE/bug_report.md). + +Explain the problem and include additional details to help maintainers reproduce the problem: + +* **Use a clear and descriptive title** for the issue to identify the problem. +* **Describe the exact steps which reproduce the problem** in as many details as possible. + +Provide more context by answering these questions: + +° TODO + +### Suggesting Enhancements + +This section guides you through submitting an enhancement suggestion for CoderBot, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion :pencil: and find related suggestions :mag_right:. + +Before creating enhancement suggestions, please check [this list](#before-submitting-an-enhancement-suggestion) as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-a-good-enhancement-suggestion). Fill in [the template](https://github.com/CoderBotOrg/.github/blob/master/.github/ISSUE_TEMPLATE/feature_request.md), including the steps that you imagine you would take if the feature you're requesting existed. + +#### Before Submitting An Enhancement Suggestion + +#### How Do I Submit A (Good) Enhancement Suggestion? + +Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you've determined [which repository](#coderbot-and-repos) your enhancement suggestion is related to, create an issue on that repository and provide the following information: + +* **Use a clear and descriptive title** for the issue to identify the suggestion. +* **Provide a step-by-step description of the suggested enhancement** in as many details as possible. +* **Provide specific examples to demonstrate the steps**. Include copy/pasteable snippets which you use in those examples, as [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines). +* **Describe the current behavior** and **explain which behavior you expected to see instead** and why. +* **Explain why this enhancement would be useful** to most CoderBot users and isn't something that can or should be implemented as a [community package](#coderbot-and-repos). +* **List some other text editors or applications where this enhancement exists.** + +### Your First Code Contribution + +Unsure where to begin contributing to CoderBot? You can start by looking through these `beginner` and `help-wanted` issues: + +* [Beginner issues][beginner] - issues which should only require a few lines of code, and a test or two. +* [Help wanted issues][help-wanted] - issues which should be a bit more involved than `beginner` issues. + +Both issue lists are sorted by total number of comments. While not perfect, number of comments is a reasonable proxy for impact a given change will have. + +#### Local development + +* TODO + +### Pull Requests + +The process described here has several goals: + +- Maintain CoderBot's quality +- Fix problems that are important to users +- Engage the community in working toward the best possible CoderBot +- Enable a sustainable system for CoderBot's maintainers to review contributions + +Please follow these steps to have your contribution considered by the maintainers: + +1. Follow all instructions in [the template](PULL_REQUEST_TEMPLATE.md) +2. Follow the [styleguides](#styleguides) +3. After you submit your pull request, verify that all [status checks](https://help.github.com/articles/about-status-checks/) are passing
What if the status checks are failing?If a status check is failing, and you believe that the failure is unrelated to your change, please leave a comment on the pull request explaining why you believe the failure is unrelated. A maintainer will re-run the status check for you. If we conclude that the failure was a false positive, then we will open an issue to track that problem with our status check suite.
+ +While the prerequisites above must be satisfied prior to having your pull request reviewed, the reviewer(s) may ask you to complete additional design work, tests, or other changes before your pull request can be ultimately accepted. + +## Styleguides + +### Git Commit Messages + +* Use the present tense ("Add feature" not "Added feature") +* Use the imperative mood ("Move cursor to..." not "Moves cursor to...") +* Limit the first line to 72 characters or less +* Reference issues and pull requests liberally after the first line +* When only changing documentation, include `[ci skip]` in the commit title + +### JavaScript Styleguide + +All JavaScript code is linted with [Prettier](https://prettier.io/). + +* Prefer the object spread operator (`{...anotherObj}`) to `Object.assign()` +* Inline `export`s with expressions whenever possible + ```js + // Use this: + export default class ClassName { + + } + + // Instead of: + class ClassName { + + } + export default ClassName + ``` +* Place requires in the following order: + * Built in Node Modules (such as `path`) + * Local Modules (using relative paths) +* Place class properties in the following order: + * Class methods and properties (methods starting with `static`) + * Instance methods and properties + +### Documentation Styleguide + +* Use [Markdown](https://daringfireball.net/projects/markdown). +* Reference methods and classes in markdown with the custom `{}` notation: + * Reference classes with `{ClassName}` + * Reference instance methods with `{ClassName::methodName}` + * Reference class methods with `{ClassName.methodName}` + +#### Example + +* TODO + +## Additional Notes + +### Issue and Pull Request Labels + +This section lists the labels we use to help us track and manage issues and pull requests. Most labels are used across all CoderBot repositories. + +[GitHub search](https://help.github.com/articles/searching-issues/) makes it easy to use labels for finding groups of issues or pull requests you're interested in. +The labels are loosely grouped by their purpose, but it's not required that every issue has a label from every group or that an issue can't have more than one label from the same group. + +#### Type of Issue and Issue State + +| Label name | `CoderBotOrg` :mag_right: | `CoderBot`‑org :mag_right: | Description | +| --- | --- | --- | --- | +| `enhancement` | [search][search-coderbot-repo-label-enhancement] | [search][search-coderbot-org-label-enhancement] | Feature requests. | +| `bug` | [search][search-coderbot-repo-label-bug] | [search][search-coderbot-org-label-bug] | Confirmed bugs or reports that are very likely to be bugs. | +| `question` | [search][search-coderbot-repo-label-question] | [search][search-coderbot-org-label-question] | Questions more than bug reports or feature requests (e.g. how do I do X). | +| `feedback` | [search][search-coderbot-repo-label-feedback] | [search][search-coderbot-org-label-feedback] | General feedback more than bug reports or feature requests. | +| `help-wanted` | [search][search-coderbot-repo-label-help-wanted] | [search][search-coderbot-org-label-help-wanted] | The CoderBot core team would appreciate help from the community in resolving these issues. | +| `beginner` | [search][search-coderbot-repo-label-beginner] | [search][search-coderbot-org-label-beginner] | Less complex issues which would be good first issues to work on for users who want to contribute to CoderBot. | +| `more-information-needed` | [search][search-coderbot-repo-label-more-information-needed] | [search][search-coderbot-org-label-more-information-needed] | More information needs to be collected about these problems or feature requests (e.g. steps to reproduce). | +| `needs-reproduction` | [search][search-coderbot-repo-label-needs-reproduction] | [search][search-coderbot-org-label-needs-reproduction] | Likely bugs, but haven't been reliably reproduced. | +| `blocked` | [search][search-coderbot-repo-label-blocked] | [search][search-coderbot-org-label-blocked] | Issues blocked on other issues. | +| `duplicate` | [search][search-coderbot-repo-label-duplicate] | [search][search-coderbot-org-label-duplicate] | Issues which are duplicates of other issues, i.e. they have been reported before. | +| `wontfix` | [search][search-coderbot-repo-label-wontfix] | [search][search-coderbot-org-label-wontfix] | The CoderBot core team has decided not to fix these issues for now, either because they're working as intended or for some other reason. | +| `invalid` | [search][search-coderbot-repo-label-invalid] | [search][search-coderbot-org-label-invalid] | Issues which aren't valid (e.g. user errors). | +| `package-idea` | [search][search-coderbot-repo-label-package-idea] | [search][search-coderbot-org-label-package-idea] | Feature request which might be good candidates for new packages, instead of extending CoderBot or core CoderBot packages. | +| `wrong-repo` | [search][search-coderbot-repo-label-wrong-repo] | [search][search-coderbot-org-label-wrong-repo] | | + +#### Topic Categories + +| Label name | `CoderBotOrg/backend` :mag_right: | `CoderBotOrg`‑org :mag_right: | Description | +| --- | --- | --- | --- | +| `windows` | [search][search-coderbot-repo-label-windows] | [search][search-coderbot-org-label-windows] | Related to CoderBot running on Windows. | +| `linux` | [search][search-coderbot-repo-label-linux] | [search][search-coderbot-org-label-linux] | Related to CoderBot running on Linux. | +| `mac` | [search][search-coderbot-repo-label-mac] | [search][search-coderbot-org-label-mac] | Related to CoderBot running on macOS. | +| `documentation` | [search][search-coderbot-repo-label-documentation] | [search][search-coderbot-org-label-documentation] | Related to any type of documentation (e.g. [API documentation]() and the [flight manual]()). | +| `performance` | [search][search-coderbot-repo-label-performance] | [search][search-coderbot-org-label-performance] | Related to performance. | +| `security` | [search][search-coderbot-repo-label-security] | [search][search-coderbot-org-label-security] | Related to security. | +| `ui` | [search][search-coderbot-repo-label-ui] | [search][search-coderbot-org-label-ui] | Related to visual design. | +| `api` | [search][search-coderbot-repo-label-api] | [search][search-coderbot-org-label-api] | Related to CoderBot's public APIs. | +| `uncaught-exception` | [search][search-coderbot-repo-label-uncaught-exception] | [search][search-coderbot-org-label-uncaught-exception] | Issues about uncaught exceptions. | +| `crash` | [search][search-coderbot-repo-label-crash] | [search][search-coderbot-org-label-crash] | Reports of CoderBot completely crashing. | +| `auto-indent` | [search][search-coderbot-repo-label-auto-indent] | [search][search-coderbot-org-label-auto-indent] | Related to auto-indenting text. | +| `encoding` | [search][search-coderbot-repo-label-encoding] | [search][search-coderbot-org-label-encoding] | Related to character encoding. | +| `network` | [search][search-coderbot-repo-label-network] | [search][search-coderbot-org-label-network] | Related to network problems or working with remote files (e.g. on network drives). | +| `git` | [search][search-coderbot-repo-label-git] | [search][search-coderbot-org-label-git] | Related to Git functionality (e.g. problems with gitignore files or with showing the correct file status). | + +#### `CoderBotOrg/backend` Topic Categories + +| Label name | `CoderBotOrg/backend` :mag_right: | `CoderBotOrg`‑org :mag_right: | Description | +| --- | --- | --- | --- | +| `editor-rendering` | [search][search-coderbot-repo-label-editor-rendering] | [search][search-coderbot-org-label-editor-rendering] | Related to language-independent aspects of rendering text (e.g. scrolling, soft wrap, and font rendering). | +| `build-error` | [search][search-coderbot-repo-label-build-error] | [search][search-coderbot-org-label-build-error] | Related to problems with building CoderBot from source. | +| `error-from-pathwatcher` | [search][search-coderbot-repo-label-error-from-pathwatcher] | [search][search-coderbot-org-label-error-from-pathwatcher] | | +| `error-from-save` | [search][search-coderbot-repo-label-error-from-save] | [search][search-coderbot-org-label-error-from-save] | Related to errors thrown when saving files. | +| `error-from-open` | [search][search-coderbot-repo-label-error-from-open] | [search][search-coderbot-org-label-error-from-open] | Related to errors thrown when opening files. | +| `installer` | [search][search-coderbot-repo-label-installer] | [search][search-coderbot-org-label-installer] | Related to the CoderBot installers for different OSes. | +| `auto-updater` | [search][search-coderbot-repo-label-auto-updater] | [search][search-coderbot-org-label-auto-updater] | Related to the auto-updater for different OSes. | +| `deprecation-help` | [search][search-coderbot-repo-label-deprecation-help] | [search][search-coderbot-org-label-deprecation-help] | Issues for helping package authors remove usage of deprecated APIs in packages. | +| `electron` | [search][search-coderbot-repo-label-electron] | [search][search-coderbot-org-label-electron] | | + +#### Pull Request Labels + +| Label name | `CoderBotOrg/backend` :mag_right: | `CoderBotOrg`‑org :mag_right: | Description +| --- | --- | --- | --- | +| `work-in-progress` | [search][search-coderbot-repo-label-work-in-progress] | [search][search-coderbot-org-label-work-in-progress] | Pull requests which are still being worked on, more changes will follow. | +| `needs-review` | [search][search-coderbot-repo-label-needs-review] | [search][search-coderbot-org-label-needs-review] | Pull requests which need code review, and approval from maintainers or CoderBot core team. | +| `under-review` | [search][search-coderbot-repo-label-under-review] | [search][search-coderbot-org-label-under-review] | Pull requests being reviewed by maintainers or CoderBot core team. | +| `requires-changes` | [search][search-coderbot-repo-label-requires-changes] | [search][search-coderbot-org-label-requires-changes] | Pull requests which need to be updated based on review comments and then reviewed again. | +| `needs-testing` | [search][search-coderbot-repo-label-needs-testing] | [search][search-coderbot-org-label-needs-testing] | Pull requests which need manual testing. | + +[search-coderbot-repo-label-enhancement]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aenhancement +[search-coderbot-org-label-enhancement]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aenhancement +[search-coderbot-repo-label-bug]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Abug +[search-coderbot-org-label-bug]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Abug +[search-coderbot-repo-label-question]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aquestion +[search-coderbot-org-label-question]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aquestion +[search-coderbot-repo-label-feedback]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Afeedback +[search-coderbot-org-label-feedback]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Afeedback +[search-coderbot-repo-label-help-wanted]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Ahelp-wanted +[search-coderbot-org-label-help-wanted]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Ahelp-wanted +[search-coderbot-repo-label-beginner]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Abeginner +[search-coderbot-org-label-beginner]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Abeginner +[search-coderbot-repo-label-more-information-needed]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Amore-information-needed +[search-coderbot-org-label-more-information-needed]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Amore-information-needed +[search-coderbot-repo-label-needs-reproduction]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aneeds-reproduction +[search-coderbot-org-label-needs-reproduction]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aneeds-reproduction +[search-coderbot-repo-label-triage-help-needed]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Atriage-help-needed +[search-coderbot-org-label-triage-help-needed]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Atriage-help-needed +[search-coderbot-repo-label-windows]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Awindows +[search-coderbot-org-label-windows]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Awindows +[search-coderbot-repo-label-linux]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Alinux +[search-coderbot-org-label-linux]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Alinux +[search-coderbot-repo-label-mac]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Amac +[search-coderbot-org-label-mac]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Amac +[search-coderbot-repo-label-documentation]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Adocumentation +[search-coderbot-org-label-documentation]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Adocumentation +[search-coderbot-repo-label-performance]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aperformance +[search-coderbot-org-label-performance]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aperformance +[search-coderbot-repo-label-security]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Asecurity +[search-coderbot-org-label-security]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Asecurity +[search-coderbot-repo-label-ui]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aui +[search-coderbot-org-label-ui]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aui +[search-coderbot-repo-label-api]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aapi +[search-coderbot-org-label-api]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aapi +[search-coderbot-repo-label-crash]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Acrash +[search-coderbot-org-label-crash]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Acrash +[search-coderbot-repo-label-auto-indent]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aauto-indent +[search-coderbot-org-label-auto-indent]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aauto-indent +[search-coderbot-repo-label-encoding]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aencoding +[search-coderbot-org-label-encoding]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aencoding +[search-coderbot-repo-label-network]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Anetwork +[search-coderbot-org-label-network]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Anetwork +[search-coderbot-repo-label-uncaught-exception]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Auncaught-exception +[search-coderbot-org-label-uncaught-exception]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Auncaught-exception +[search-coderbot-repo-label-git]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Agit +[search-coderbot-org-label-git]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Agit +[search-coderbot-repo-label-blocked]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Ablocked +[search-coderbot-org-label-blocked]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Ablocked +[search-coderbot-repo-label-duplicate]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aduplicate +[search-coderbot-org-label-duplicate]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aduplicate +[search-coderbot-repo-label-wontfix]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Awontfix +[search-coderbot-org-label-wontfix]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Awontfix +[search-coderbot-repo-label-invalid]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Ainvalid +[search-coderbot-org-label-invalid]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Ainvalid +[search-coderbot-repo-label-package-idea]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Apackage-idea +[search-coderbot-org-label-package-idea]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Apackage-idea +[search-coderbot-repo-label-wrong-repo]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Awrong-repo +[search-coderbot-org-label-wrong-repo]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Awrong-repo +[search-coderbot-repo-label-editor-rendering]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aeditor-rendering +[search-coderbot-org-label-editor-rendering]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aeditor-rendering +[search-coderbot-repo-label-build-error]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Abuild-error +[search-coderbot-org-label-build-error]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Abuild-error +[search-coderbot-repo-label-error-from-pathwatcher]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aerror-from-pathwatcher +[search-coderbot-org-label-error-from-pathwatcher]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aerror-from-pathwatcher +[search-coderbot-repo-label-error-from-save]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aerror-from-save +[search-coderbot-org-label-error-from-save]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aerror-from-save +[search-coderbot-repo-label-error-from-open]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aerror-from-open +[search-coderbot-org-label-error-from-open]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aerror-from-open +[search-coderbot-repo-label-installer]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Ainstaller +[search-coderbot-org-label-installer]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Ainstaller +[search-coderbot-repo-label-auto-updater]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Aauto-updater +[search-coderbot-org-label-auto-updater]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aauto-updater +[search-coderbot-repo-label-deprecation-help]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3ACoderBotOrg%2Fbackend+label%3Adeprecation-help +[search-coderbot-org-label-deprecation-help]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Adeprecation-help +[search-coderbot-repo-label-electron]: https://github.com/search?q=is%3Aissue+repo%3ACoderBotOrg%2Fbackend+is%3Aopen+label%3Aelectron +[search-coderbot-org-label-electron]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3ACoderBotOrg+label%3Aelectron +[search-coderbot-repo-label-work-in-progress]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3ACoderBotOrg%2Fbackend+label%3Awork-in-progress +[search-coderbot-org-label-work-in-progress]: https://github.com/search?q=is%3Aopen+is%3Apr+user%3ACoderBotOrg+label%3Awork-in-progress +[search-coderbot-repo-label-needs-review]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3ACoderBotOrg%2Fbackend+label%3Aneeds-review +[search-coderbot-org-label-needs-review]: https://github.com/search?q=is%3Aopen+is%3Apr+user%3ACoderBotOrg+label%3Aneeds-review +[search-coderbot-repo-label-under-review]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3ACoderBotOrg%2Fbackend+label%3Aunder-review +[search-coderbot-org-label-under-review]: https://github.com/search?q=is%3Aopen+is%3Apr+user%3ACoderBotOrg+label%3Aunder-review +[search-coderbot-repo-label-requires-changes]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3ACoderBotOrg%2Fbackend+label%3Arequires-changes +[search-coderbot-org-label-requires-changes]: https://github.com/search?q=is%3Aopen+is%3Apr+user%3ACoderBotOrg+label%3Arequires-changes +[search-coderbot-repo-label-needs-testing]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3ACoderBotOrg%2Fbackend+label%3Aneeds-testing +[search-coderbot-org-label-needs-testing]: https://github.com/search?q=is%3Aopen+is%3Apr+user%3ACoderBotOrg+label%3Aneeds-testing + +[beginner]:https://github.com/search?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+label%3Abeginner+label%3Ahelp-wanted+user%3ACoderBotOrg+sort%3Acomments-desc +[help-wanted]:https://github.com/search?q=is%3Aopen+is%3Aissue+label%3Ahelp-wanted+user%3ACoderBotOrg+sort%3Acomments-desc+-label%3Abeginner +[contributing-to-official-coderbot-packages]: todo +[hacking-on-coderbot-core]: todo + diff --git a/api.py b/api.py index c03cf5b0..f7035e3c 100644 --- a/api.py +++ b/api.py @@ -23,7 +23,7 @@ bot_config = Config.get() bot = CoderBot.get_instance( motor_trim_factor=float(bot_config.get("move_motor_trim", 1.0)), - encoder=bool(bot_config.get("encoder")) + hw_version=bot_config.get("hw_version") ) def get_serial(): diff --git a/camera.py b/camera.py index 48ef2f16..e56af812 100644 --- a/camera.py +++ b/camera.py @@ -49,7 +49,6 @@ class Camera(object): # pylint: disable=too-many-public-methods _instance = None - _img_template = image.Image.load("static/media/coderdojo-logo.png") @classmethod def get_instance(cls): @@ -252,18 +251,6 @@ def find_line(self): self.set_image_cv(img) return coords - def find_signal(self): - angle = None - ts = time.time() - img = self.get_image() - signals = img.find_template(self._img_template) - - logging.info("signal: %s", str(time.time() - ts)) - if signals: - angle = signals[0].angle - - return angle - def find_face(self): face_x = face_y = face_size = None img = self.get_image() diff --git a/coderbot.cfg b/coderbot.cfg index 5f44f821..93b4a617 100644 --- a/coderbot.cfg +++ b/coderbot.cfg @@ -1 +1,46 @@ -{"move_power_angle_3": "60", "cnn_default_model": "generic_fast_low", "prog_maxblocks": "-1", "camera_jpeg_quality": "5", "show_page_control": "true", "camera_framerate": "30", "prog_scrollbars": "true", "move_fw_speed": "100", "prog_level": "adv", "move_motor_trim": "1", "move_motor_mode": "dc", "cv_image_factor": "2", "move_power_angle_1": "45", "camera_path_object_size_min": "4000", "button_func": "none", "camera_color_object_size_min": "4000", "camera_jpeg_bitrate": "1000000", "move_fw_elapse": "1", "show_control_move_commands": "true", "camera_color_object_size_max": "160000", "show_page_prefs": "true", "camera_exposure_mode": "auto", "ctrl_tr_elapse": "-1", "show_page_program": "true", "move_tr_elapse": "0.5", "camera_path_object_size_max": "160000", "sound_shutter": "$shutter.wav", "ctrl_fw_elapse": "-1", "sound_stop": "$shutdown.wav", "ctrl_tr_speed": "80", "ctrl_fw_speed": "100", "move_tr_speed": "85", "move_power_angle_2": "60", "ctrl_hud_image": "", "load_at_start": "", "sound_start": "$startup.wav", "encoder": "True", "audio_volume_level": "100", "wifi_mode": "ap", "wifi_ssid": "coderbot", "wifi_psk": "coderbot", "packages_installed": ""} +{ + "move_power_angle_3":"60", + "cnn_default_model":"generic_fast_low", + "prog_maxblocks":"-1", + "camera_jpeg_quality":"5", + "show_page_control":"true", + "camera_framerate":"30", + "prog_scrollbars":"true", + "move_fw_speed":"100", + "prog_level":"adv", + "move_motor_trim":"1", + "move_motor_mode":"dc", + "cv_image_factor":"2", + "move_power_angle_1":"45", + "camera_path_object_size_min":"4000", + "button_func":"none", + "camera_color_object_size_min":"4000", + "camera_jpeg_bitrate":"1000000", + "move_fw_elapse":"1", + "show_control_move_commands":"true", + "camera_color_object_size_max":"160000", + "show_page_prefs":"true", + "camera_exposure_mode":"auto", + "ctrl_tr_elapse":"-1", + "show_page_program":"true", + "move_tr_elapse":"0.5", + "camera_path_object_size_max":"160000", + "sound_shutter":"$shutter.wav", + "ctrl_fw_elapse":"-1", + "sound_stop":"$shutdown.wav", + "ctrl_tr_speed":"80", + "ctrl_fw_speed":"100", + "move_tr_speed":"85", + "move_power_angle_2":"60", + "ctrl_hud_image":"", + "load_at_start":"", + "sound_start":"$startup.wav", + "hw_version":"5", + "audio_volume_level":"100", + "wifi_mode":"ap", + "wifi_ssid":"coderbot_CHANGEMEATFIRSTRUN", + "wifi_psk":"coderbot", + "packages_installed":"", + "admin_password":"", + "hardware_version":"5" +} diff --git a/coderbot.py b/coderbot.py index 1c05db79..67cecc5e 100644 --- a/coderbot.py +++ b/coderbot.py @@ -54,6 +54,8 @@ class GPIO_CODERBOT_V_4(): PIN_ENCODER_RIGHT_A = 15 PIN_ENCODER_RIGHT_B = 12 + HAS_ENCODER = False + class GPIO_CODERBOT_V_5(): # motors PIN_MOTOR_ENABLE = None #22 @@ -82,29 +84,36 @@ class GPIO_CODERBOT_V_5(): PIN_ENCODER_RIGHT_A = 24 #15 PIN_ENCODER_RIGHT_B = 25 #12 + HAS_ENCODER = True + # PWM PWM_FREQUENCY = 100 #Hz PWM_RANGE = 100 #0-100 +HW_VERSIONS = { + "4": GPIO_CODERBOT_V_4(), + "5": GPIO_CODERBOT_V_5() +} + class CoderBot(object): # pylint: disable=too-many-instance-attributes - def __init__(self, motor_trim_factor=1.0, encoder=True): + def __init__(self, motor_trim_factor=1.0, hw_version="5"): try: self._mpu = mpu.AccelGyroMag() logging.info("MPU available") except: logging.info("MPU not available") - self.GPIOS = GPIO_CODERBOT_V_5() + self.GPIOS = HW_VERSIONS.get(hw_version, GPIO_CODERBOT_V_5()) self._pin_out = [self.GPIOS.PIN_LEFT_FORWARD, self.GPIOS.PIN_RIGHT_FORWARD, self.GPIOS.PIN_LEFT_BACKWARD, self.GPIOS.PIN_RIGHT_BACKWARD, self.GPIOS.PIN_SERVO_1, self.GPIOS.PIN_SERVO_2] self.pi = pigpio.pi('localhost') self.pi.set_mode(self.GPIOS.PIN_PUSHBUTTON, pigpio.INPUT) self._cb = dict() self._cb_last_tick = dict() self._cb_elapse = dict() - self._encoder = encoder + self._encoder = self.GPIOS.HAS_ENCODER self._motor_trim_factor = motor_trim_factor self._twin_motors_enc = WheelsAxel( self.pi, @@ -143,9 +152,9 @@ def exit(self): s.cancel() @classmethod - def get_instance(cls, motor_trim_factor=1.0, encoder=True, servo=False): + def get_instance(cls, motor_trim_factor=1.0, hw_version="5", servo=False): if not cls.the_bot: - cls.the_bot = CoderBot(motor_trim_factor=motor_trim_factor, encoder=encoder) + cls.the_bot = CoderBot(motor_trim_factor=motor_trim_factor, hw_version=hw_version) return cls.the_bot def move(self, speed=100, elapse=0, distance=0): diff --git a/data/activities.json b/data/activities.json deleted file mode 100644 index 674b1c99..00000000 --- a/data/activities.json +++ /dev/null @@ -1 +0,0 @@ -{"_default": {"2": {"stock": true, "default": true, "uiLang": null, "defaultView": null, "exec": {"camera": true, "log": true}, "name": "default", "drawerEnabled": true, "showName": true, "buttons": [{"action": "clearProgramDlg", "icon": "clear", "label": "message.activity_program_clear", "type": "text"}, {"action": "saveProgram", "icon": "save", "label": "message.activity_program_save", "type": "text"}, {"action": "toggleSaveAs", "icon": "edit", "label": "message.activity_program_save_as", "type": "text"}, {"action": "loadProgramList", "icon": "folder_open", "label": "message.activity_program_load", "type": "text"}, {"action": "runProgram", "icon": "play_arrow", "label": "message.activity_program_run", "type": "text"}, {"action": "getProgramCode", "icon": "code", "label": "message.activity_program_show_code", "type": "text"}, {"action": "exportProgram", "icon": "fa-file-export", "label": "message.activity_program_export", "type": "text"}, {"action": "pickFile", "icon": "fa-file-import", "label": "message.activity_program_import", "type": "text"}], "description": "", "fontSize": "Medio", "capsSwitch": true, "bodyFont": "Roboto", "codeFont": "ubuntumono", "maxBlocks": 0, "availableViews": [], "viewSource": null, "autoRecVideo": null, "toolbox": {"contents": [{"colour": "210", "contents": [{"kind": "block", "type": "controls_if"}, {"kind": "block", "type": "logic_compare"}, {"kind": "block", "type": "logic_operation"}, {"kind": "block", "type": "logic_negate"}, {"kind": "block", "type": "logic_boolean"}, {"kind": "block", "type": "logic_null"}, {"kind": "block", "type": "logic_ternary"}], "kind": "category", "name": "Logica"}, {"colour": "120", "contents": [{"kind": "block", "type": "controls_repeat_ext", "value": {"contents": {"field": {"#text": "10", "name": "NUM"}, "kind": "block", "type": "math_number"}, "name": "TIMES"}}, {"kind": "block", "type": "controls_whileUntil"}, {"kind": "block", "type": "controls_for", "value": [{"contents": {"field": {"#text": "1", "name": "NUM"}, "kind": "block", "type": "math_number"}, "name": "FROM"}, {"contents": {"field": {"#text": "10", "name": "NUM"}, "kind": "block", "type": "math_number"}, "name": "TO"}, {"contents": {"field": {"#text": "1", "name": "NUM"}, "kind": "block", "type": "math_number"}, "name": "BY"}]}, {"kind": "block", "type": "controls_forEach"}, {"kind": "block", "type": "controls_flow_statements"}], "kind": "category", "name": "Cicli"}, {"colour": "230", "contents": [{"kind": "block", "type": "math_number"}, {"kind": "block", "type": "math_arithmetic"}, {"kind": "block", "type": "math_single"}, {"kind": "block", "type": "math_trig"}, {"kind": "block", "type": "math_constant"}, {"kind": "block", "type": "math_number_property"}, {"kind": "block", "type": "math_change"}, {"kind": "block", "type": "math_round"}, {"kind": "block", "type": "math_on_list"}, {"kind": "block", "type": "math_modulo"}, {"kind": "block", "type": "math_constrain"}, {"kind": "block", "type": "math_random_int"}, {"kind": "block", "type": "math_random_float"}], "kind": "category", "name": "Matematica"}, {"colour": "160", "contents": [{"kind": "block", "type": "text_print"}, {"kind": "block", "type": "text"}, {"kind": "block", "type": "text_join"}, {"kind": "block", "type": "text_append"}, {"kind": "block", "type": "text_length"}, {"kind": "block", "type": "text_isEmpty"}, {"kind": "block", "type": "text_indexOf"}, {"kind": "block", "type": "text_charAt"}, {"kind": "block", "type": "text_getSubstring"}, {"kind": "block", "type": "text_changeCase"}, {"kind": "block", "type": "text_trim"}], "kind": "category", "name": "Testo"}, {"colour": "260", "contents": [{"kind": "block", "type": "lists_create_empty"}, {"kind": "block", "type": "lists_create_with"}, {"kind": "block", "type": "lists_repeat"}, {"kind": "block", "type": "lists_length"}, {"kind": "block", "type": "lists_isEmpty"}, {"kind": "block", "type": "lists_indexOf"}, {"kind": "block", "type": "lists_getIndex"}, {"kind": "block", "type": "lists_setIndex"}, {"kind": "block", "type": "lists_getSublist"}, {"kind": "block", "type": "hashmap_get_value"}, {"kind": "block", "type": "hashmap_get_keys"}], "kind": "category", "name": "Liste"}, {"colour": "330", "custom": "VARIABLE", "kind": "category", "name": "Variabili"}, {"colour": "290", "custom": "PROCEDURE", "kind": "category", "name": "Funzioni"}, {"colour": "15", "contents": [{"kind": "block", "type": "coderbot_event_generator", "value": {"contents": {"kind": "block", "type": "controls_if", "value": [{"contents": {"type": "logic_compare"}, "name": "IF0"}, {"contents": {"field": {"#text": "a_topic", "name": "event_topic"}, "kind": "block", "type": "coderbot_event_publisher", "value": {"contents": {"#text": "\n\t\t\t\t\t\t\t\t", "kind": "block", "type": "text"}, "name": "event_data"}}, "name": "DO0"}]}, "name": "generator_statements"}}, {"field": {"#text": "a_topic", "name": "event_topic"}, "kind": "block", "type": "coderbot_event_publisher", "value": {"contents": {"#text": "\n\t\t\t\t", "kind": "block", "type": "text"}, "name": "event_data"}}, {"field": {"#text": "a_topic", "name": "event_topic"}, "kind": "block", "type": "coderbot_event_listener", "value": {"contents": {"kind": "block", "type": "text_print", "value": {"contents": {"field": {"#text": "event_data", "name": "VAR"}, "kind": "block", "type": "variables_get"}, "name": "TEXT"}}, "name": "event_statements"}}, {"field": {"#text": "event_data", "name": "VAR"}, "kind": "block", "type": "variables_get"}], "kind": "category", "name": "Eventi"}, {"colour": "40", "contents": [{"kind": "block", "type": "coderbot_moveForward"}, {"kind": "block", "type": "coderbot_moveBackward"}, {"kind": "block", "type": "coderbot_turnLeft"}, {"kind": "block", "type": "coderbot_turnRight"}, {"kind": "block", "type": "coderbot_adv_stop"}], "kind": "category", "name": "Movimento"}, {"colour": "120", "contents": [{"kind": "block", "type": "coderbot_camera_photoTake"}, {"kind": "block", "type": "coderbot_camera_videoRec"}, {"kind": "block", "type": "coderbot_camera_videoStop"}], "kind": "category", "name": "Camera"}, {"colour": "250", "contents": [{"kind": "block", "type": "coderbot_cam_average"}, {"kind": "block", "type": "coderbot_adv_pathAhead"}, {"kind": "block", "type": "coderbot_adv_findLine"}, {"kind": "block", "type": "coderbot_adv_findSignal"}, {"kind": "block", "type": "coderbot_adv_findFace"}, {"kind": "block", "type": "coderbot_adv_findColor", "value": {"contents": {"#text": "\n\t\t\t\t", "kind": "block", "type": "colour_picker"}, "name": "COLOR"}}, {"kind": "block", "type": "coderbot_adv_findText", "value": {"contents": {"#text": "\n\t\t\t\t", "kind": "block", "type": "colour_picker"}, "name": "COLOR"}}, {"kind": "block", "type": "coderbot_adv_findQRCode"}, {"kind": "block", "type": "coderbot_adv_findARCode"}, {"kind": "block", "type": "coderbot_adv_cnn_classify"}, {"kind": "block", "type": "coderbot_adv_cnn_detect_objects"}], "kind": "category", "name": "Visione"}, {"colour": "240", "contents": [{"kind": "block", "type": "coderbot_sonar_get_distance"}, {"kind": "block", "type": "coderbot_mpu_get_gyro"}, {"kind": "block", "type": "coderbot_mpu_get_accel"}, {"kind": "block", "type": "coderbot_mpu_get_heading"}, {"kind": "block", "type": "coderbot_mpu_get_temp"}], "kind": "category", "name": "Sensori"}, {"colour": "220", "contents": [{"kind": "block", "type": "coderbot_audio_say"}, {"kind": "block", "type": "coderbot_audio_record"}, {"kind": "block", "type": "coderbot_audio_play"}, {"kind": "block", "type": "coderbot_audio_hear", "value": [{"contents": {"field": {"#text": "100", "name": "NUM"}, "kind": "block", "type": "math_number"}, "name": "LEVEL"}, {"contents": {"field": {"#text": "1.0", "name": "NUM"}, "kind": "block", "type": "math_number"}, "name": "ELAPSE"}]}, {"kind": "block", "type": "coderbot_audio_listen"}], "kind": "category", "name": "Suoni"}, {"colour": "240", "contents": [{"kind": "block", "type": "coderbot_atmega_get_input"}, {"kind": "block", "type": "coderbot_atmega_set_output"}, {"kind": "block", "type": "coderbot_atmega_set_led"}], "kind": "category", "name": "Estensioni I/O"}, {"colour": "345", "contents": [{"kind": "block", "type": "coderbot_music_note_adv"}, {"kind": "block", "type": "coderbot_music_instrument_adv"}, {"kind": "block", "type": "coderbot_music_animal_adv"}, {"kind": "block", "type": "coderbot_music_pause_adv"}], "kind": "category", "name": "Music"}], "kind": "categoryToolbox"}}, "3": {"stock": null, "default": null, "uiLang": null, "defaultView": "blocks", "exec": {"camera": true, "log": true}, "name": "Base", "drawerEnabled": true, "showName": true, "buttons": [{"action": "clearProgramDlg", "icon": "clear", "label": "message.activity_program_clear", "type": "text"}, {"action": "saveProgram", "icon": "save", "label": "message.activity_program_save", "type": "text"}, {"action": "toggleSaveAs", "icon": "edit", "label": "message.activity_program_save_as", "type": "text"}, {"action": "loadProgramList", "icon": "folder_open", "label": "message.activity_program_load", "type": "text"}, {"action": "runProgram", "icon": "play_arrow", "label": "message.activity_program_run", "type": "text"}, {"action": "getProgramCode", "icon": "code", "label": "message.activity_program_show_code", "type": "text"}, {"action": "exportProgram", "icon": "fa-file-export", "label": "message.activity_program_export", "type": "text"}, {"action": "pickFile", "icon": "fa-file-import", "label": "message.activity_program_import", "type": "text"}], "description": "Base", "fontSize": "Medio", "capsSwitch": true, "bodyFont": "Roboto", "codeFont": "ubuntumono", "maxBlocks": 0, "availableViews": [], "viewSource": null, "autoRecVideo": null, "toolbox": {"kind": "flyoutToolbox", "contents": [{"kind": "block", "type": "coderbot_basic_moveForward", "enabled": true}, {"kind": "block", "type": "coderbot_basic_moveBackward", "enabled": true}, {"kind": "block", "type": "coderbot_basic_turnLeft", "enabled": true}, {"kind": "block", "type": "coderbot_basic_turnRight", "enabled": true}, {"kind": "block", "type": "coderbot_basic_repeat", "enabled": true}, {"kind": "block", "type": "coderbot_basic_audio_say", "enabled": true}, {"kind": "block", "type": "coderbot_basic_camera_photoTake", "enabled": true}]}}}} \ No newline at end of file diff --git a/data/defaults/config.json b/data/defaults/config.json index 55bfcee1..c5ce7f84 100644 --- a/data/defaults/config.json +++ b/data/defaults/config.json @@ -1,38 +1,46 @@ { - "move_power_angle_3": "60", - "cnn_default_model": "fruit_025_128_1", - "prog_maxblocks": "-1", - "camera_jpeg_quality": "5", - "show_page_control": "true", - "camera_framerate": "30", - "prog_scrollbars": "true", - "move_fw_speed": "100", - "prog_level": "adv", - "move_motor_trim": "1", - "move_motor_mode": "dc", - "cv_image_factor": "2", - "move_power_angle_1": "45", - "camera_path_object_size_min": "4000", - "button_func": "none", - "camera_color_object_size_min": "4000", - "camera_jpeg_bitrate": "1000000", - "move_fw_elapse": "1", - "show_control_move_commands": "true", - "camera_color_object_size_max": "160000", - "show_page_prefs": "true", - "camera_exposure_mode": "auto", - "ctrl_tr_elapse": "-1", - "show_page_program": "true", - "move_tr_elapse": "0.5", - "camera_path_object_size_max": "160000", - "sound_shutter": "$shutter.mp3", - "ctrl_fw_elapse": "-1", - "sound_stop": "$shutdown.mp3", - "ctrl_tr_speed": "80", - "ctrl_fw_speed": "100", - "move_tr_speed": "85", - "move_power_angle_2": "60", - "ctrl_hud_image": "", - "load_at_start": "", - "sound_start": "$startup.mp3" + "move_power_angle_3":"60", + "cnn_default_model":"generic_fast_low", + "prog_maxblocks":"-1", + "camera_jpeg_quality":"5", + "show_page_control":"true", + "camera_framerate":"30", + "prog_scrollbars":"true", + "move_fw_speed":"100", + "prog_level":"adv", + "move_motor_trim":"1", + "move_motor_mode":"dc", + "cv_image_factor":"2", + "move_power_angle_1":"45", + "camera_path_object_size_min":"4000", + "button_func":"none", + "camera_color_object_size_min":"4000", + "camera_jpeg_bitrate":"1000000", + "move_fw_elapse":"1", + "show_control_move_commands":"true", + "camera_color_object_size_max":"160000", + "show_page_prefs":"true", + "camera_exposure_mode":"auto", + "ctrl_tr_elapse":"-1", + "show_page_program":"true", + "move_tr_elapse":"0.5", + "camera_path_object_size_max":"160000", + "sound_shutter":"$shutter.wav", + "ctrl_fw_elapse":"-1", + "sound_stop":"$shutdown.wav", + "ctrl_tr_speed":"80", + "ctrl_fw_speed":"100", + "move_tr_speed":"85", + "move_power_angle_2":"60", + "ctrl_hud_image":"", + "load_at_start":"", + "sound_start":"$startup.wav", + "hw_version":"5", + "audio_volume_level":"100", + "wifi_mode":"ap", + "wifi_ssid":"coderbot_CHANGEMEATFIRSTRUN", + "wifi_psk":"coderbot", + "packages_installed":"", + "admin_password":"", + "hardware_version": "5" } \ No newline at end of file diff --git a/main.py b/main.py index 17659aa6..563e684a 100644 --- a/main.py +++ b/main.py @@ -460,6 +460,14 @@ def remove_doreset_file(): except OSError: pass +def align_wifi_config(): + if app.bot_config["wifi_ssid"] == "coderbot_CHANGEMEATFIRSTRUN": + out = os.popen("sudo ./wifi.py getcfg --ssid").read() + if "coderbot_" in out: + app.bot_config["wifi_ssid"] = out.split()[0] + Config.write(app.bot_config) + app.bot_config = Config.get() + # Finally, get the server running def run_server(): bot = None @@ -467,8 +475,9 @@ def run_server(): try: try: app.bot_config = Config.read() + align_wifi_config() bot = CoderBot.get_instance(motor_trim_factor=float(app.bot_config.get('move_motor_trim', 1.0)), - encoder=bool(app.bot_config.get('encoder'))) + hw_version=app.bot_config.get('hardware_version')) audio = Audio.get_instance() audio.say(app.bot_config.get("sound_start")) diff --git a/static/js/blockly/blocks.js b/static/js/blockly/blocks.js index 3602c871..c7e72208 100644 --- a/static/js/blockly/blocks.js +++ b/static/js/blockly/blocks.js @@ -572,27 +572,6 @@ Blockly.Python['coderbot_adv_findLine'] = function(block) { return [code, Blockly.Python.ORDER_ATOMIC]; }; -Blockly.Blocks['coderbot_adv_findSignal'] = { - /** - * Block for findSignal function. - * @this Blockly.Block - */ - init: function() { - this.setHelpUrl(Blockly.Msg.LOGIC_BOOLEAN_HELPURL); - this.setColour(250); - this.appendDummyInput() - .appendField(Blockly.Msg.CODERBOT_SENSOR_FINDSIGNAL); - this.setOutput(true, 'Number'); - this.setTooltip(Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP); - } -}; - -Blockly.Python['coderbot_adv_findSignal'] = function(block) { - // Boolean values true and false. - var code = 'get_cam().find_signal()'; - return [code, Blockly.Python.ORDER_ATOMIC]; -}; - Blockly.Blocks['coderbot_adv_findFace'] = { /** * Block for findSignal function. diff --git a/static/media/coderdojo-logo.png b/static/media/coderdojo-logo.png deleted file mode 100644 index 93a07e8d3812064fa36a5f2010b8767b08636f34..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3937 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 diff --git a/templates/blocks_adv.xml b/templates/blocks_adv.xml index 4a3f3c70..13b7e50a 100644 --- a/templates/blocks_adv.xml +++ b/templates/blocks_adv.xml @@ -304,7 +304,6 @@ - diff --git a/templates/blocks_std.xml b/templates/blocks_std.xml index b0fb4a00..a5243d97 100644 --- a/templates/blocks_std.xml +++ b/templates/blocks_std.xml @@ -61,7 +61,6 @@ - diff --git a/wifi.py b/wifi.py index 3bc5101e..4fa447e4 100755 --- a/wifi.py +++ b/wifi.py @@ -135,9 +135,22 @@ def set_ap_params(cls, wssid=None, wpsk=None): if wpsk: os.system("sudo sed -i s/wpa_passphrase=.*$/wpa_passphrase=" + wpsk + "/ /etc/hostapd/" + cls.hostapds.get(adapter) + ".conf") + @classmethod + def get_ap_params(cls): + adapter = cls.get_adapter_type() + ap_conf = {} + with open("/etc/hostapd/" + cls.hostapds.get(adapter) + ".conf", "r") as hostapd_conf: + for l in hostapd_conf.readlines(): + ls = l.split("=") + ap_conf[ls[0]] = ls[1] + return ap_conf + @classmethod def set_start_as_client(cls): cls._config["wifi_mode"] = "client" + os.system("sudo systemctl disable hostapd") + os.system("sudo systemctl disable dnsmasq") + os.system("sudo cp /etc/dhcpcd.conf.client /etc/dhcpcd.conf") cls.save_config() @classmethod @@ -147,22 +160,11 @@ def set_bot_name(cls, name): @classmethod def start_as_client(cls): - cls.stop_dnsmasq() - cls.stop_hostapd() try: - time.sleep(1.0) - out = os.system("wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1") - out += os.system("dhclient -1 wlan0") - print("start_as_client: " + str(out)) + time.sleep(30.0) ipaddr = cls.get_ipaddr("wlan0") if ipaddr is None or "169.254" in ipaddr: - os.system("sudo pkill wpa_supplicant") raise Exception() - try: - cls.register_ipaddr(cls.get_macaddr("wlan0"), cls.get_config().get('bot_name', 'CoderBot'), cls.get_ipaddr("wlan0"), "roberto.previtera@gmail.com") - print("registered bot, ip: " + str(cls.get_ipaddr("wlan0") + " name: " + cls.get_config().get('bot_name', 'CoderBot'))) - except: - pass except subprocess.CalledProcessError as e: print(e.output) raise @@ -170,19 +172,11 @@ def start_as_client(cls): @classmethod def set_start_as_ap(cls): cls._config["wifi_mode"] = "ap" + os.system("sudo systemctl enable hostapd") + os.system("sudo systemctl enable dnsmasq") + os.system("sudo cp /etc/dhcpcd.conf.ap /etc/dhcpcd.conf") cls.save_config() - @classmethod - def start_as_ap(cls): - time.sleep(1.0) - out = str(subprocess.check_output(["ip", "link", "set", "dev", "wlan0", "down"])) - out += str(subprocess.check_output(["ip", "a", "add", "10.0.0.1/24", "dev", "wlan0"])) - out += str(subprocess.check_output(["ip", "link", "set", "dev", "wlan0", "up"])) - out += str(subprocess.check_output(["ifconfig"])) - print("start_as_ap: " + str(out)) - cls.start_hostapd() - cls.start_dnsmasq() - @classmethod def start_service(cls): config = cls.load_config() @@ -195,7 +189,8 @@ def start_service(cls): cls.start_as_client() except: print("Unable to register ip, revert to ap mode") - cls.start_as_ap() + cls.set_start_as_ap() + os.system("sudo reboot") @classmethod def get_hostapd_config_file(cls): @@ -238,27 +233,34 @@ def get_serial(cls): def main(): parser = argparse.ArgumentParser(description="CoderBot wifi config manager and daemon initializer", prog="wifi.py") - subparsers = parser.add_subparsers() + subparsers = parser.add_subparsers(dest='subparser_name') up = subparsers.add_parser('updatecfg', help="update configuration") up.add_argument('-m', '--mode', choices=['ap', 'client'], help='wifi mode') up.add_argument('-s', '--ssid', help='wifi ssid') up.add_argument('-p', '--pwd', help='wifi password') up.add_argument('-n', '--name', help='coderbot unique id') + get = subparsers.add_parser('getcfg', help="get configuration") + get.add_argument('-s', '--ssid', nargs="*", help='wifi mode') + get = subparsers.add_parser('setuniquessid', help="set unique ssid") args = vars(parser.parse_args()) - print(args) w = WiFi() if args: - if args['mode'] == 'ap': - w.set_start_as_ap() - w.set_ap_params(args['ssid'], args['pwd']) - elif args['mode'] == 'client': - w.set_start_as_client() - w.set_client_params(args['ssid'], args['pwd']) - if args['name']: - w.set_bot_name(args['name']) - else: - w.set_unique_ssid() - w.start_service() + if args["subparser_name"] == "updatecfg": + if args['mode'] == 'ap': + w.set_start_as_ap() + w.set_ap_params(args['ssid'], args['pwd']) + elif args['mode'] == 'client': + w.set_start_as_client() + w.set_client_params(args['ssid'], args['pwd']) + if 'name' in args: + w.set_bot_name(args['name']) + elif args["subparser_name"] == "getcfg": + if "ssid" in args: + print(w.get_ap_params()["ssid"]) + elif args["subparser_name"] == "setuniquessid": + w.set_unique_ssid() + else: + w.start_service() if __name__ == "__main__": main()