Discuss Scratch

botkop
New to Scratch
7 posts

scratch and lego mindstorms ev3

Hi,

I started working on a way to program the EV3 with the Scratch 2.0 off-line editor.

Source and documentation can be found on github:
https://github.com/koen-dejonghe/ev3-scratch-helper-app

Currently it's only possible to read a couple of sensors, but I think it's a good start.

Suggestions, bug reports, etc… welcome.
Thank you.
swedish_cook
New to Scratch
4 posts

scratch and lego mindstorms ev3

botkop wrote:

Hi,

I started working on a way to program the EV3 with the Scratch 2.0 off-line editor.

Source and documentation can be found on github:
https://github.com/koen-dejonghe/ev3-scratch-helper-app

Currently it's only possible to read a couple of sensors, but I think it's a good start.

Suggestions, bug reports, etc… welcome.
Thank you.

Awesome - the old NXT had 2 Scratch implementations, so glad to hear one is starting for EV3 !

Imho the programming suite supplied by Lego really really sucks (to be generous), once programs become more than trivial they look a real mess and are unintelligible (speaking as someone working in systems design for 20 years or more). How they think that kids can learn well with that software really beats me.

I'll take a look next weekend :-)
swedish_cook
New to Scratch
4 posts

scratch and lego mindstorms ev3



I followed the instructions and connected successfully to my ev3 on first attempt, I ticked the 3 sensors I had connected, dragged on the blocks to tell it which sensors(touch, distance and color) were connected to what and followed that by a loop forever. The first time I tried I got the touch sensor to registed a press, on subsequent runs it did not, the values displayed for the other sensors did not change irrespective of what I did with those sensors. Connected a large motor and that seemed to start and stop ok.

I had lots of errors on the command window like these :

2014-04-21 17:32:50.392 ERROR 2544 — scratch.ev3.PollControl
ler : null
2014-04-21 17:32:50.392 ERROR 2544 — scratch.ev3.PollControl
ler : null
2014-04-21 17:32:50.532 ERROR 2544 — scratch.ev3.PollControl
ler : null
2014-04-21 17:32:50.535 ERROR 2544 — scratch.ev3.PollControl
ler : null
2014-04-21 17:32:50.586 ERROR 2544 — scratch.ev3.PollControl
ler : null
2014-04-21 17:32:50.593 ERROR 2544 — scratch.ev3.PollControl
ler : null
> Building 50% > :bootRunTerminate batch job (Y/N)? y

Minor install niggles (may be worth update to instructions for others) :
1. Slightly confused what to do on github (I haven't used it before), elected to download as a zip and that seemed to be ok.
2. Needed full jdk, only had a jre installed. For those new to java worth a comment on java_home and path.
3. With the ev3 disconnected I expected an error, but the one displayed looked more like a compile error than a connectivity error.
4. With ev3 connected the last thing displayed on the command window before I started scratch was “Building 50%”, you can still see it above, so I wasn't sure it was actually running.

Thanks for this, looks like something that could really work well, happy to test some more … how can I verify what is wrong with the sensors ?

Last edited by swedish_cook (April 21, 2014 17:58:10)

botkop
New to Scratch
7 posts

scratch and lego mindstorms ev3

I am very grateful for this test report. Frankly I have never tested it on Windows, so I'm glad to hear that it ‘works’ just like on other platforms.

The null error generated by the poll controller is a known issue to me. I am still investigating how to fix it.
Basically, I have not found a way for lejos to report the current state (connected/disconnected) of motors and sensors. In other words, my program must keep track of all state changes, and must be told explicitly. If something changes in the physical world without my program being told, then this will generate these null errors. There may be other reasons as well.
If this situation happens, then the only way I have found to slove this, is to reset lejos, by either rebooting the ev3, or logging in to the ev3, killing the menu program, and restarting it.

I have included a small demo program ‘scratchcar’. If you have a look at it, you will find an initialize, a reset and a start sprite.
The initialize sprite tells the helper-app which devices have been connected to the ev3. This must be executed before anything else.
The reset sprite tells the program to close the connected devices. It is not necessary to remove them physically from the ev3, but if you want to use them again, then you must execute the initialize sprite again.
The start sprite is a small program that will tell the ev3 to keep running forward, until it comes too close to an obstacle, at which point it will make a left or right turn, depending on how you connected the motors.

About the documentation, you are absolutely right. I will include your remarks as soon as possible. Some things that are obvious to me, are not clear to other people. That is why testing and reporting like you did is so valuable.

swedish_cook
New to Scratch
4 posts

scratch and lego mindstorms ev3

Tried scratchcar - runs fine, no errors, looks like your project is progressing well.

Any chance that you can add motor rotation by degrees/rotations ? My son is building the Spider (Spik3r) and firing motor cannot be allowed to run free, so won't be able to test for a while without that. Obviously don't let me derail your plans though !
botkop
New to Scratch
7 posts

scratch and lego mindstorms ev3

Good to hear that. There are still problems though with the program…

I've implemented to rotate and rotateTo methods, but I've not had much time to test (and I will not have the possibility to make changes in the next coming days).
One thing to keep in mind: these methods take time to finish, but the wait-commands in scratch are buggy so I cannot use them. What this means is that you must have the rotate instruction followed by a wait instruction for approx. the time it takes for the rotation to finish.

Hopefully you will already find it useful.
gatzke
Scratcher
44 posts

scratch and lego mindstorms ev3

I like the idea of this project, but install is not “seemless” by any means.

What would it take to get code like this included in the offline editor? The package is quite small…

Also, what would it take to include NXT support? We currently run NXT, but will have to switch. There will be many NXT folks for years, though!

Good job! You are terrific! You are a beautiful and unique snowflake!

Powered by DjangoBB

Standard | Mobile