Snap interfacing

After the few workshop I did with Snap! software to pilot robot, I really enjoyed. I also saw some drawbacks which are very cosmetic for many.
I now imagine I make a robot, artistic robot with high tech stuff. I want now the robot to be programmed by children using Snap!

What are the different ways to make such an interface ? How to build personnalized blocks ? Is there only HTTP REST API way ? Or could I program a specific block ?

Thank you for your help.

1 Like

You can make your own block in Snap, using right click “make a block”.
56

You choose the category and the name
21

You can add variables if you click on the “+” sign
51

1 Like

an easy way is to run a Python Flask server (https://projects.raspberrypi.org/en/projects/python-web-server-with-flask/5) and make some entries (https://projects.raspberrypi.org/en/projects/python-web-server-with-flask/6)

for exemple for ErgoJr you have (in https://github.com/poppy-project/pypot/blob/master/pypot/server/snap.py)

@self.app.get('/motors/<motors>/get/<register>')
def get_motors_registers(motors, register):
    motors = motors.split(';')
    return ';'.join(str(rr.get_register_value(m, register)) for m in motors)

In snap! just make a right clic to “make a new block” select your parameter and use the url block and split block to return the good answer

1 Like