Skip to content

Conversation

apfeuti
Copy link

@apfeuti apfeuti commented Nov 6, 2019

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

apfeuti added 6 commits June 6, 2019 23:15
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
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
…ce' into feature/LegoBoost-support-distance

# Conflicts:
#	src/extensions/scratch3_boost/index.js
value: BoostOperator.EQUAL
}
]
},
Copy link
Contributor

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

@knandersen
Copy link
Contributor

Closing due to #2210 (comment)

@knandersen knandersen closed this Feb 27, 2020
@SunnyChen-T
Copy link

SunnyChen-T commented Oct 25, 2020

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~

@apfeuti
Copy link
Author

apfeuti commented Oct 26, 2020

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.

@pawelbura
Copy link

@apfeuti I've tested your PR and it works great!
I've tested it on Windows/Firefox 81.0.2 with Scratch Link 1.3.67 (11acbe9) Win32NT (server on Ubuntu 18).
I've started server from master of LLK repo + replaced one file with yours https://raw.githubusercontent.com/apfeuti/scratch-vm/feature/LegoBoost-support-distance/src/extensions/scratch3_boost/index.js

Thank you!

@CrispStrobe
Copy link

CrispStrobe commented Nov 2, 2024

icyi: quick implementation (merged with xcratch)
(repo: https://github.com/CrispStrobe/scratch-gui)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants