Cozmo Programming with Blockly
All programming constructs are available to teach/learn basics of programming. 3D live visualization makes it a little more interesting. Cube rendering as any character (currently Minecraft mobs are supported) bumps interest even more. Physical interaction with objects and watching live how it is reflected in Cozmo's world should be even more engaging.
Currently with Cozmo you can do:
Improved security compared to Cozmo ScratchX extension:
Some other features:
pip3 install --user cozmo[camera]
pip3 install --user tornado ws4py
server
folderpython3 server.py
(additionally, -n <the future programmer's name>
can be supplied to set the default filename when saving/reloading programs - convenient on mobile devices)http://localhost:9090/cozmo/
play
button in the top-right cornerIf your program hangs, or you just want to stop it, click the stop button.
The last executed program will be stored in .last
file for you to be able to reload it.
You can also save any program with any other name and load any previously saved programs.
There are two modes of code execution: secure
and non-secure
.
secure
mode requires installation of Node.js.
In that mode the code you create with Blockly and execute with the play
button is sent as Blockly XML AST to the server and there translated to an actual Python code and executed.
After you download and install NodeJS go to the nodejs
folder and run npm install
. That would install all the modules that are required for that additional service.
non-secure
mode doesn't require Node.js. In that mode your program is traslated into Python code and is sent to the server for execution.
This mode is intended for contained environments (e.g. in a home network).
The risk here is that the server accepts arbitrary code from the network for execution.
If you are not sure your local home network is secure, or if you're planning to let people with potentially malicious intentions program your Cozmo, or you're running server.py
not in your local home network, it is highly recommended to run server.py
in secure
mode.
By default server.py
runs in secure
mode. To run it in non-secure
mode use --nonsecure
command argument.
There are two Javascript versions: compressed and uncompressed. Compressed version is compiled with google's closure library, is minified and obfuscated. Uncompressed version is debuggable.
To run uncompressed version: python3 server.py -d
which enables debug mode.
You may encounter some caching issues. If so, restart server.py
Any issues? Report an issue above.
MEGAkid: Learn to Code the Cozmo Robot! Beginners: Ages 6-12