-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Feature/lego boost support distance #2299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/lego boost support distance #2299
Conversation
Beside the color, the LegoBoost-vision-sensor can also report the distance. This commit adds two new blocks for the LegoBoost-Extension: 1) whenDistance - BlockType.HAT with a menu for the "<, >, =" operators 2) getDistance - BlockType.REPOETER - reports the distance as a float. the resolution is higher for closer distances
fix linter-issues
Beside the color, the LegoBoost-vision-sensor can also report the distance. This commit adds two new blocks for the LegoBoost-Extension: 1) whenDistance - BlockType.HAT with a menu for the "<, >, =" operators 2) getDistance - BlockType.REPOETER - reports the distance as a float. the resolution is higher for closer distances
fix linter-issues
fix definition of new operators
…ce' into feature/LegoBoost-support-distance # Conflicts: # src/extensions/scratch3_boost/index.js
value: BoostOperator.EQUAL | ||
} | ||
] | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this trailing comma is causing the lint failure
fix lint issue (comma-dangle)
Closing due to #2210 (comment) |
Dear @apfeuti , S2Bot by PICAXE for scratch 2 was way better than current boost extension for scratch 3.0 but it seems not maintained for a long time. Is that possible to show us how to add distance sensor "unofficially" since you are the only one knows how to do it? Thank you for your kind help~ |
Hi @SunnyChen-T It was a political decision by the Lego-Scratch-Team to not support the distance-sensor for Lego Boost. You can build your own Scratch - but you have to setup the development-environment for Scratch.
Maybe you can reopen a new feature-request here to support distance-sensor on Lego-Boost and link to this discussion. The responsible Scratch-Team will notice the demand of the community. |
@apfeuti I've tested your PR and it works great! Thank you! |
icyi: quick implementation (merged with xcratch) |
Resolves
#2210
Proposed Changes
The LegoBoost-vision-sensor reports the distance (how far is the sensor away from any obstacle).
This PR adds support to the LegoBoost-Extension to read the distance-sensor-value from the MoveHub.
According to https://github.com/JorgePe/BOOSTreveng/blob/master/ColorDistanceSensor.md the color-sensor can be put into a "color and distance (0x08)" mode, where not only the color is reported but also the distance.
This PR adds two new blocks for the LegoBoost-Extension:
whenDistance - BlockType.HAT with a menu for the "<, >, =" operators
getDistance - BlockType.REPORTER - reports the distance as a float.
the resolution is higher for closer distances
Reason for Changes
Having a possibility to get the distance-sensor-value from the MoveHub, greatly improves the possibilities what can be done with LegoBoost and Scratch.
Eg:
Stop a robot (or drive into another direction) before he hits a wall or some other obstacle -> we can write some Scratch-programs for autonomous navigation.
Count objects passing (slowly) the distance-sensor
Test Coverage
There's no test-automation for LegoBoost-Extension. I tested manually in this environments:
Ubuntu 18.04.2 LTS
Browsers: Chrome, Firefox
ScratchLink running on Windows
Windows 10 Pro
Browsers: Chrome, Edge
macOS Mojave 10.14.5
Browsers: Safari, Chrome
See the attached SB3-file for the test-program, which does the following:
Play a sound (in a forever-loop) when distance-reporter detects a distance < 4
Play an alarm-sound whenDistance (HAT-block) equals 5
Show a message when the vision-sensor detects the color "green" -> regression-test for the existing color-feature.
LegoBoost-Distance-Test.zip