0

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?

user3019802
  • 65
  • 2
  • 10
  • Shouldn't it be 2*(pi)*(radius + 3) and 2*(pi)*(radius - 3) assuming you want the radius of the circle to end at the center of the robot – KMier Mar 06 '17 at 16:27

1 Answers1

0

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.

user3473949
  • 205
  • 1
  • 8
  • Thanks. I figured out an easier way to do it. But that may have been my problem, I may have forgot to import math. And I should have did * between 2 and (pi). – user3019802 Oct 14 '14 at 20:16