Strange motor change in behavior

Hello,

I’ve been working on the GoPiGo lately, and I came across a behavior I don’t understand.

I am trying to make the robot rotate as precisely as possible, as I want it to rotate 90 degrees all the time. I am using the compass to get a precise angle (if possible less than 5° error). I am slowing down the robot while it is rotating, otherwise it will overshoot its target angle.
The thing is that sometimes one of the motor, generally the left one, does not turn back to maximum speed after a rotation, thus making it turn instead of driving forwards. Any idea why this is happening?

I am using this code for the rotation for the moment:

def turn90DRight(self):
-gopigo.set_speed(self.TURNSPEED)
-time.sleep(0.1)
-self.compass.update()
-start=self.compass.headingDegrees
-target= (start+90)%360
-gopigo.right_rot()
-while True:
–self.compass.update()
–time.sleep(0.1)
–current=self.compass.headingDegrees
–if math.fabs(current - target) < 5:
—gopigo.stop()
—time.sleep(0.1)
—gopigo.set_speed(self.FORWARDSPEED)
—break

and this code to drive forwards:

def goForward(self):
-if self.sideFollowed == WallFollowed.Right:
–gopigo.servo(self.RIGHTSERVOANGLE)
-else:
–gopigo.servo(self.LEFTSERVOANGLE)
-time.sleep(0.1)
-self.isTurnPossible = True
-gopigo.enc_tgt(1,1,29)
-time.sleep(0.1)
-gopigo.fwd()
-time.sleep(0.1)
-while gopigo.read_status()[0] == 1:
–if gopigo.us_dist(15) < self.ROBOTLENGTH*3:
–self.isTurnPossible = False

I am also having overshooting problem because the compass doesn’t seem to update fast enough.
Edit: the “-” is the indentation, I can’t seem to find a way to make it show on my post

Hey,
Just wanted to ask a few question:

  1. Does the left motor show that behavior only a few of the times and does the right motor show it too?
  2. What result do you get when you give “f” command in the basic_test_all.py (https://github.com/DexterInd/GoPiGo/blob/master/Software/Python/basic_test_all.py) a couple of times?
  3. What result do you get when you give “v” command in the basic_test_all.py a couple of times? Is the reported voltage above 9V.
  4. What is the speed b/w 0-255 that you are using for TURNSPEED and FORWARDSPEED.

-Karan

Hello,

  1. I made a mistake, it is not the left on that does not turn fast enough, but the right one. The problem is the same, just mixed them up. It is always the right one that does not work, never the left one as far as I tested. I can’t seem to find a particular pattern on when it occurs, just that it is only after a “90°” turn.

  2. The result of multiple “f” commands is the same : v 1.3

  3. The reported voltage is above 9V, actually at 9.88V.

  4. Sorry, forgot to give those values: TURNSPEED = 70 and FORWARDSPEED = 200

I still have no idea on why this is behaving like this

Hello again,

Just to add a thing, I am having a lot of problems trying to make the GoPiGo turn accurately. I want it to turn 90° as precisely as possible, but I can’t seem to find a way, be it with the gopigo.enc_tgt function, or with the compass.

-Rob

Hey,
The GoPiGo works with 9V and above on the battery pack and it would be great if you had the battery at 10.5-12V. When it starts coming down to 9V, it starts misbehaving.

Also, the motors are rated for 6V and above and work best in that range only. The turn speed looks very low. Since you have kept it at 70 which means the motors get 2.7V (70*9.88/255) which looks very low.

Can you try using stronger batteries and a higher speed to see if that makes it any better.

-Karan

Hi Karan,

I tried what you said about setting speed and getting the corresponding voltage, but it doesn’t seem to relate that way.

I have my gopigo running on new batteries (volt() returns 10.1V). I connect my multimeter to read voltages given to the motors (actual motors are disconnected). I then start the python terminal via ssh

>>>from gopigo import *
>>>set_speed(255)
>>>fwd() #returns 9.45 V for both motors
>>>stop()
>>>set_speed(70)
>>>fwd() # 3.52V for left motor, 5.69V for right motor

What is the reason behind this mismatch of voltages? Also, by your calculation the voltage should be 9.45*(70/255) = 2.59V.

How is the voltage to the motors decided? I’m not sure what I’m missing. I’m trying to get my motors to run at the same speed, and this is one of debugging steps.

EDIT: Tried this for various speed settings. Uploaded image.

Hey,
Thanks a lot for trying this out. We had not noticed this earlier that there was a motor bias in the voltages on the GoPiGo. We’ll have a look at the firmware and test it to find the source of the problem.

-Karan