I'm using a Scribbler robot.
There doesn't seem to be a function in the Myro library that has the robot move in a circle at a user specified radius.
Here's what I was able to gather
The distance between the left and right wheel of the robot is 6 inches.
So the left wheel should travel at a distance of 2(pi)(radius+6)
And the right wheel should travel at a distance of 2(pi) (radius-6)
(I think)
Moving the robot in a circle is rather simple. I could just use the motors
function and call
motors(1, 0)
Meaning the left wheel moves, and the right wheel stops, effectively moving in a circle.
My issue is specifying a radius for the circle and getting it to move in a circle of that radius.
Here's a code I have.
#Practice for Circle
def goCircle(int radius):
pi = 3.14159265359
Left = 2(pi)(radius + 6)
Right = 2(pi)(radius - 6)
turnRight(1,radius/360.0)
generally turnRight
would have these parameters turnRight(speed, time)
So you specify the speed you'd like the robot to go, and the seconds you'd like it to travel. I put it at 1 speed, and tried passing the radius/360 in the time variable.
I get this error
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 4, in goCircle
TypeError: int is not callable
I also tried motors(left, right)
and got the same error
#Practice for Circle
def goCircle(radius):
pi = 3.14159265359
Left = 2(pi)(radius + 6)
Right = 2(pi)(radius - 6)
motors(left,right)
What could I do to make this work?
You are getting an error because you of your syntax. You cannot multiply with:
2(pi)(radius + 6)
You need to put *
between the terms:
2*(pi)*(radius + 6)
The interpreter thinks that you are tying to call an int like a function 2()
.
Also, if you import math
, you get math.pi built in.