blockpy-edu / blockpy

Blockly that's more Python than JavaScript, powered with Skulpt
Apache License 2.0
391 stars 130 forks source link

Robot controller module #75

Open Skydler opened 4 years ago

Skydler commented 4 years ago

Hi, we are using Python Blocks to manipulate a robot via HTTP requests for a project in college.

The idea is simple, we have a robot listening and we pass the direction and value indicating how much it should move. This is done in one side, by defining blocks for the initialization and movement of the robot and on the other side defining a module "robot" in skulpt with the funcionality

If you are interested we would be glad to contribute to the project by adding this new feature, if not thanks anyway blockpy help us a lot!

acbart commented 4 years ago

This is interesting, though I don't have much experience with this kind of API. What type of robot?

If you can make the API in skulpt, it should be pretty trivial to get it integrated into BlockPy. Adding in the blocks can be relatively straightforward too, similar to what we do with the Turtle blocks in BlockMirror.

Do you know how to go about getting started with making a Skulpt module?

Skydler commented 4 years ago

This is interesting, though I don't have much experience with this kind of API. What type of robot?

We did it with a NodeMCU which is similar to Arduino and we configured it to emit a Wi-fi signal. Once you're connected to that network you can start sending requests. If you can archive that you are ready to go with any kind of robot.

If you can make the API in skulpt, it should be pretty trivial to get it integrated into BlockPy. Adding in the blocks can be relatively straightforward too, similar to what we do with the Turtle blocks in BlockMirror.

Yeah, actually we did a fork of skulpt and blockpy for our project. As you can see the code is really simple.

https://github.com/Skydler/skulpt https://github.com/Skydler/blockpy

Do you know how to go about getting started with making a Skulpt module?

I read the documentation and saw how you implemented other modules. Tell me if we missed something!

acbart commented 4 years ago

I haven't forgotten about this, by the way, it's been in my inbox to get a closer look for a while. We're still deep in a thick part of the semester, but things are winding down so hopefully sometime in the next month I'll be able to turn my attention to this. I am very interested in having some modules like this. Ironing out the exact API and implementation are important.

Skydler commented 4 years ago

Hi! any news about this? @acbart

acbart commented 3 years ago

Finally going through my backlog a little. Almost a full year waiting, how busy things are.

Scoping this out, it would be pretty easy to hardcode this in. The skulpt side already seems to be working, so we'd just need to copy over the robot/init.js file into our skulpt fork's src/lib/ folder. Then we'd need to create a bunch of new BlockMirror blocks similar to what we do for Turtles. Finally, creating a new BlockMirror menu and making it available for selection in BlockPy would wrap all that up in a quick coding session.

However... I'm a little concerned about incorporating a Spanish-language API into our codebase. It wouldn't be a problem for me to translate, but I'm not sure that that helps your use case. We're SUPER far away from internationalization in BlockPy - that would be a whole summer job requiring a dedicated student working at multiple levels of our infrastructure. However, we're pretty close to having custom block menus available in BlockPy, and we already have support for instructors to provide hidden Python files that students can import.

If you wanted to use this interface in the next few months, and didn't mind the fact that I might arbitrarily replace it in the future with something in English, I'd have no problem just slapping the hotfix in I described before. However, if you're not planning to use this any time soon, I'd actually go with the custom block menu option. I don't think I'll have time to work on that soon, though.