OpenRoberta / openroberta-lab

The programming environment »Open Roberta Lab« by Fraunhofer IAIS enables children and adolescents to program robots. A variety of different programming blocks are provided to program motors and sensors of the robot. Open Roberta Lab uses an approach of graphical programming so that beginners can seamlessly start coding. As a cloud-based application, the platform can be used without prior installation of specific software but runs in any popular browser, independent of operating system and device.
Apache License 2.0
123 stars 119 forks source link

Replace usages of BlocklyMethods for Python robots #95

Closed boonto closed 5 years ago

boonto commented 5 years ago

In Java and Python code generation we use BlocklyMethods for list and math operations. In the course of #1011 the list operations in BlocklyMethods will be replaced by inline code or readable methods in the program. As there is (currently?) no discernible reason why we should use the non-transparent BlocklyMethods, e.g. BlocklyMethods.sin(x) instead of simply Math.sin(x), all of these calls should be replaced. This will also increase readability and accessibility of the generated code.

ensonic commented 5 years ago

For ev3dev this is the impl: https://github.com/OpenRoberta/robertalab-ev3dev/blob/develop/roberta/BlocklyMethods.py Lots of them are one-liners. Inlining them makes a lot of sense. For the more complex ones we could emit the helper function as needed and call it. Getting rid of the class in the long run makes a lot of sense to me.

boonto commented 5 years ago

Python observations: Microbit:

EV3dev:

NAO:

Vorwerk/Raspberry:

For python almost everything can be pulled up to the generic code gen visitor.

uzkns commented 5 years ago

For Python: blockly_methods_all_robots.zip For C: NEPO_all_robots.zip

boonto commented 5 years ago

Implemented for Python, the helper methods are saved in a YAML file for now. If necessary, it can be split into individual language files later (Python only needs 3 helper methods).

Individual robots may override higher up implementations of methods.

boonto commented 5 years ago

Will be continued in #230.

VinArt commented 5 years ago

tested on microbit and ev3dev

boonto commented 5 years ago

Ah thanks,

repeatStmt.getList().visit(this);

is missing here.

bjost2s commented 5 years ago

@VinArt please fix this