Monday 15 August 2011

python - iRobot Create - Playing two songs -



python - iRobot Create - Playing two songs -

here's code:

import create robot = create.create(3) robot.tofullmode() robot.setsong(0,[(36,16),(36,16),(38,32),(36,32),(53,32),(52,32),\ (36,16),(36,16),(38,32),(36,32),(55,32),(41,32),\ (36,16),(36,16),(48,32),(33,32)]) robot.setsong(1,[(53,32),(40,32),(38,32),(34,16),(34,16),\ (33,32),(41,32),(43,32),(41,32)]) robot.playsongnumber(0) robot.playsongnumber(1)

the first song plays, sec 1 won't...any ideas why? beingness coded create.py python interface irobot create: http://www.cs.gmu.edu/~zduric/cs101/uploads/main/create.py

without seeing documentation or source code, wild guess, but…

i'll bet playsongnumber function sends robot play command, without waiting finish, , when send play command while it's playing something, ignores you.

if i'm right, api provides way wait until it's done. if doesn't provide that, provide way poll current state, can in loop (sleeping briefly between each check) until it's done. if doesn't provide that, have work out how long song take counting number of notes (or adding durations, if 1 of numbers in each of pairs duration) , sleep long.

python robotics robot mobile-robots

No comments:

Post a Comment