Hi folks,
I got the raspberry pi connector on top of bittle, set up and everything works. I can send commands to from python, and Bittle mostly does them. Now, a few problems:
- the interface from Python is extremely coarse - you can give commands and some time (in seconds), but a better one would be "run x instances of the loop". Is that not available yet, or did I miss it?
- the communication is also very error-prone. I get into modes where the skills don't work, but things like turn off/balance do. How do I know the status of the channel, and is there a way to reset it without a more general reset?
Generally though, should I be investing in the serial communication, or should I start looking into i2c (and flip that switch) which I presume means driving the servos directly?
If this question is answered/portable from a different Petoi platform, I can crib from there, just point me to it please - couldn't find it on my own.
Thanks,
Bear.
PS: posting to the forum seems broken, the "select your post category" can't select any option, so "publish" is grayed out.
This looks like a very cool project. Do you have instructions somewhere?
I think found my problem. in OpenCat.ino, line 632 you have:
if (strcmp(newCmd, "") && strcmp(newCmd, lastCmd) ) {
but the treatment is inconsistent for skills. Balance, specifically, writes something else in lastCmd even though it's a skill. Check out line 711:
strcpy(lastCmd, "balance");
So that strips the "k", meaning you can send "kbalance" in a row, whereas if you send other skills like crawl forward, etc. it gets ignored. Makes sense I guess if you're on a remote that keeps sending the same command over and over again, you don't want to restart the sequence.
Somehow - haven't finished tracing all the code (like around line 650), if you have a sequence over serial like "kcrF" -> "kbalance" -> "kcrF", the second "kcrF" will get eaten.
Would be nice to document the state machine explicitly, clean it up a bit and break up the code into more functions - but I can't complain, it works and wouldn't have wrote it myself, so here we are.
I wrote the following short program to try things out easily:
#!/usr/bin/python import datetime import sys import tty import termios from ardSerial import wrapper # read a single character on a unix system # https://exceptionshub.com/python-read-a-single-character-from-the-user.html def read_unix(count): ch = sys.stdin.read(count) return ch fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) tty.setraw(fd) wrapper(['g',2]) wrapper(['kbalance',2]) while True: char = read_unix(1) if char == "q": break elif char == "a": wrapper(['kcrL',1]) elif char == "s": wrapper(['bk',1]) elif char == "d": wrapper(['kcrR',1]) elif char == "w": wrapper(['kcrF',1]) termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) wrapper(['d',2])
I definitely get the log of the commands sent by ardSerial - and the balance/turn off commands work reliably, but the move skills do not - sometimes they work, sometimes the command gets ignored.