I’m teaching a bunch of kids (9-14years old with little or no experience) robotics with a flotilla kit, and whilst the existing python library works really well it’s not ideally suited to use with kids; it’s kinda complex and requires a lot of code to setup the flotilla before something actually happens. There’s also little documentation available although I know it’s something that’s being worked on - I imagine that in a year or so the python library will be a bit more fully fledged and so better for teaching and that’s fine.
Anyway, TL;DR I am trying to wrap the existing code needed to control the modules into an uber-simple library- which ideally will literally require something like
import easyflotilla
easyflotilla.setup()
easyflotilla.motor(100)
or print("easyflotilla.colour") or whatever.
I’ll try and make it available somewhere online for people in the same boat as me when I’m done.
Anyway, here’s my hastily adapted test code so far:
#!/usr/bin/env python
import sys
import time
import flotilla
print("""
Check colour
""")
COLOR_INFO = "{red},{green},{blue},{clear}"
client = flotilla.Client()
print("Client connected...")
while not client.ready:
pass
print("Finding colour module...")
#we should scale all values to 1000 I think
col = client.first(flotilla.Colour) #y - the values scale 0 to 25
mat = client.first(flotilla.Matrix)#y
mot = client.first(flotilla.Motor)#y - values are 0 to 63/-63 (f/r)
num = client.first(flotilla.Number)#n
tou = client.first(flotilla.Touch)#y
dia = client.first(flotilla.Dial)#y - the values scale 0-1023
joy = client.first(flotilla.Joystick)#y - the values scale from 0 (right/btm) to 1023 (top/left) - scale -1k to 1k or will this cause errors?
sli = client.first(flotilla.Slider)#y -s scales 0 to 1023
wea = client.first(flotilla.Weather)#y
acc = client.first(flotilla.Motion)#y
#lig = client.first(flotilla.Light)#y
'''
if color is None:
client.stop()
sys.exit(1)
'''
i = 0
#mot.set_speed(0)
#num.set_number(0)
'''for i in range(10):
for j in range(10):
mat.set_pixel(i,j,0)'''
#MONSTER EXAMPLE LOOP (comment out stuff you didn't connect)
try:
while True:
print(COLOR_INFO.format(
red= col.red,
green=col.green,
blue=col.blue,
clear=col.clear))
time.sleep(0.5)
#mat.set_pixel(1, 1, 1).update()
#mot.set_speed(-63)
num.set_number(int(1234))
if tou.one:
print("True")
print(dia.position)
print("x", joy.x, "y", joy.y, "button?", joy.button)
print("slider: ", sli.position)
print("temp: ", wea.temperature, "pres: ", wea.pressure)
print("ax: ", acc.x, "ay: ", acc.y, "az", acc.z)
#print('light: ', lig.light, "lux ", lig.lux)
except KeyboardInterrupt:
print("Stopping Flotilla...")
client.stop()
All the modules work, except for the number module. I can’t figure out why it’s not working. I’ve tested the module with Rockpool (works fine) but I can’t do numbers or even turn on or off the colon from my code. The code by the way for this is just kinda assumed from the existing flotilla library for the number module.
In essence, the only code that I’ve put in for the number module is this:
num = client.first(flotilla.Number)
num.set_number(int(1234))
Which appears to work for all the other modules - I’ve tried the number on loads of different ports on the dock with loads of different ropes.
What am I doing wrong?