Page 1 of 1

Robot difficult to drive in a straight line

PostPosted: Sat Jan 03, 2015 10:58 pm
by Doug
Hi

I have recently completed the assembly of the Raspberry Pi Camera Robot, but I am having difficulty making it go in a straight line, either forwards or backwards. I have checked the wiring between the motor and the control board.

If I access the config.html screen and select Motors and click on Drive Straight, the robot turns anti-clockwise and then reverses. If I swap the connections for the left motor, on the control board, the robot goes backwards in a clockwise direction.

The software is that supplied on the microSD card purchased on 14th December.

I would appreciate any help in solving this problem.

Thanks

Doug

Re: Robot difficult to drive in a straight line

PostPosted: Mon Jan 05, 2015 7:47 pm
by Alan
Hi Doug,

Welcome to the forums. :) Sorry for the delayed reply.

The first thing I'd check would be the motor connections (sorry I know you've done this, but just to be sure). Things are easier if you prop the robot up so that its wheels are off the ground. Then if you push forward on the left control stick you can check that the motors go in the correct direction. Pushing left should make the left motor go backwards and the right motor forwards. Pushing right should make the right motor go backwards and the left motor forwards. It can also sometimes be helpful to temporarily disconnect one motor to check that nothing odd has happened like wiring one motor to both sides (its easily done, especially after threading the wires through the chassis).

Once the wires have been checked, another thing to look at would be to see if visually, it appears as if one motor is going much faster than the other. This might be because one gearbox is stiffer than the other. If you drive the motors at full speed, forward and backwards a few times then this may help to more evenly distribute the lubricant inside the gearboxes and loosen things up a bit.

Beyond that, it can in general be a bit difficult to get the robot to go straight, as in general 2 DC motors (even ones that are meant to be identical) will run at different speeds when they have the same voltage applied to them, due to manufacturing tolerances. The usual method to work around this is to add encoders to the robot which allows it to measure the speed of its wheels in order to balance them. We are working on an encoder kit for the robot, but it'll be a while before it's released and it's probably not something that we'd include by default due to cost, and because a lot of beginners wouldn't know why they'd need them (initially they'll probably be driving the robot around manually and so can correct heading errors themselves).

Having said that, it should be possible to improve things by changing the 'Left Motor Speed Scale' on the config page. This scales the left motor speed relative to the right motor to try to balance the motor speeds a bit. Also, you should hopefully get better control if you move the control joystick just a small amount. This causes the robot to drive at a slow speed, and the robot is much more controllable at low speeds.

Anyway, hopefully some of that will be of some use to you. Please let me know how you get on.

Regards

Alan

Re: Robot difficult to drive in a straight line

PostPosted: Sat Jan 17, 2015 10:02 pm
by Adeste
Hi
I have similar problems trying to make the bot turn exactly 360'. You can get some consistency by experimenting with the speed. Too slow it stalls? and too fast it skids. I have tried to prime the motors by a short pulse before the main turn this seems to have little effect. I think we have to wait for the encoders to be available. I have, many years ago, done something similar with a BBC micro using stepper motors? maybe this is a way forward.

Re: Robot difficult to drive in a straight line

PostPosted: Fri Jun 05, 2015 3:35 pm
by kevcook
I know this is an older discussion, but I wonder if anyone has progressed it further.
The issue is getting the motors to run in a straight line. I cannot seem to balance the motor speeds so that there is a match. Set a bias in one speed and it seems to correct it, next time it doesn't and an alternative adjustment is needed, there seems to be no reason for it. I've varied surfaces and even balanced the robot (using weights) to ensure there is no built in bias!
I wrote a simple test program, the basics of which are:-

# Connect to the robot
bot = py_websockets_bot.WebsocketsBot("192.168.42.1")
# Stop
bot.set_motor_speeds(0.0, 0.0)
time.sleep(0.75)
# Drive forwards
bot.set_motor_speeds(80.0, 80.0)
time.sleep(2.5)

Run it the first time and it runs straight and true for 2.5 secs. Put it back to the start (without disturbing it too much)
Run the program again and it will swing to the right - everytime!
Turn all off and re-run and the same thing will happen, straight and then swing - every time!
I've ordered up some encoders as from what has been said it seems a must.
I've no idea, mind you, how to get the encoders working and into the code!

Kevin

Re: Robot difficult to drive in a straight line

PostPosted: Fri Jun 05, 2015 4:05 pm
by Alan
Hi Kevin,

Do you have a white castor wheel on the back of your robot?

Dagu have recently switched the 2WD kit back to a metal omniwheel, and some people have reported that the turning castor wheel caused the robot to go off course.

Are you able to lock the castor wheel in place (perhaps by using tape) to see if that improves things?

Regards

Alan

Re: Robot difficult to drive in a straight line

PostPosted: Fri Jun 12, 2015 4:57 pm
by kevcook
Thanks, I'll try that out. Ive now obtained some encoders (the basic tacho style) and am looking for some direction in integrating them into the robot design having not used them before. I know how to attach them from info on the net but cannot find any useful Python programming advice on using them. Any advice or hints would be good. I'm initialling trying to get it to work with your motor test example first.

Thanks Kevin.

Re: Robot difficult to drive in a straight line

PostPosted: Fri Jun 12, 2015 5:17 pm
by Alan
Hi Kev,

Assuming that they have a +5V and a GND line, coupled with either 1 or 2 output signals, you should be able to wire them up using the instructions in the 'incremental encoders' section of this blog post. Once they're wired up you should be able to run the get_sensor_readings.py script (also described in the blog post) and see encoder readings come back from the robot.

Any questions or problems, please let me know.

Regards

Alan