Can someone check my python code? Trying play with a robot.

page: 1
0

log in

join

posted on Dec, 1 2012 @ 11:46 AM
link   
Trying to make a code that interacts with the robot in python but, I lost the battery and I can't test it out. I have most of what I want to do but I'm also sure I'm not calling it correctly. Any gurus from ATS, that can help a fellow member?
Thanks.

#Robot does a YoYo routine of forward and Backward motions
def yoyo(speed, duration):
forward(speed, duration)
backward(speed, duration)
stop()

def beep(duration, frequency)
beep(duration, frequency)
beep(duration, frequency, frequency1)
stop()

#Robot does the wiggle routine from Left to Right
def wiggle(speed, duration):
turnLeft(speed, duration)
turnRight(speed, duration)
stop()

def ledLight():
ledLight('off')
ledLight(0)
ledLight('on')
ledLight(1)



#Robot incorporates the dance combination of YoYo and Wiggle followed by a beep and using the LedLight.
def dance(speed, duration):
for i in range(3)
yoyo(0,1)
beep(1,440,880)
wiggle(0,1)
ledLight(0)
stop()

#Main Program of Dance Routine that loops 3 times
def main():
from Myro import *
initalize()
speedValue = eval(ask("please enter the Speed Value:")
dance()
main()
edit on 1-12-2012 by Manhater because: (no reason given)




posted on Dec, 1 2012 @ 12:05 PM
link   
reply to post by Manhater
 


Please repost it with the whitespace included. It is hard to tell what may be out.

Also, the import is typically included at the beginning rather than specialized in a class or function.



posted on Dec, 1 2012 @ 12:09 PM
link   
reply to post by GreenGlassDoor
 

It won't let me post the the whitespaces. I just tried it. I did put the import at the beginning then I deleted and put it under main.
edit on 1-12-2012 by Manhater because: (no reason given)



posted on Dec, 1 2012 @ 12:33 PM
link   



#Robot does a YoYo routine of forward and Backward motions
def yoyo(speed, duration):
forward(speed, duration)
backward(speed, duration)
stop()



you're calling something called forward and backward, but python wouldn't know where to look. So you'd need something like Myro.forward(speed, duration) for all those functions you're calling.



def beep(duration, frequency)
beep(duration, frequency)
beep(duration, frequency, frequency1)
stop()


same as above. As written the stuff inside the function beep is calling itself.



#Robot does the wiggle routine from Left to Right
def wiggle(speed, duration):
turnLeft(speed, duration)
turnRight(speed, duration)
stop()

def ledLight():
ledLight('off')
ledLight(0)
ledLight('on')
ledLight(1)



#Robot incorporates the dance combination of YoYo and Wiggle followed by a beep and using the LedLight.
def dance(speed, duration):
for i in range(3)
yoyo(0,1)
beep(1,440,880)
wiggle(0,1)
ledLight(0)
stop()


Same as above. You also need to fix the for loop. You need to end it with a : and then nest all the things within the for loop.




#Main Program of Dance Routine that loops 3 times
def main():
from Myro import *
initalize()
speedValue = eval(ask("please enter the Speed Value:")
dance()
main()
edit on 1-12-2012 by Manhater because: (no reason given)


set you're import at the beginning of the program.



posted on Dec, 1 2012 @ 01:12 PM
link   
Okay, I'll try that. Thank you.



posted on Dec, 1 2012 @ 01:22 PM
link   
I guess I don't have to do anything. I already handed it in and wanted to do more but he gave me 90 on it. I'll take that and not complain. I actually thought I did worse on it.





top topics
 
0

log in

join