go away spammer

Author Topic: Using PID to move in a curve  (Read 3012 times)

0 Members and 1 Guest are viewing this topic.

Offline arixroboticsTopic starter

  • Full Member
  • ***
  • Posts: 119
  • Helpful? 3
    • TalasTronics WCIT KL2008 Fund Raising
Using PID to move in a curve
« on: October 29, 2008, 01:46:26 PM »
Hi all,

If PID can be used to make a robot go straight, then it should also be able to make the robot curve in a given radius too, am I right?

I am working on a robot modified from an electric wheelchair. The uC controls two servos that are linked to the original wheelchair joystick controller. So one servo will be for the drive and the other for the steering. Sort of Ackermann steering. Both left and right wheels are fitted with encoders.

I have implemented PID to move the robot in a straight line. Now I want the robot to move in a curve with a constant radius. So I did this;

Code: [Select]
error = leftWheel - (ratio*rightWheel)
where 'ratio' is the ratio of the distance I want the left wheel to travel over the distance the right wheel should travel. This is found from some calculations once I know what the radius should be. So to turn left, ratio<1. To turn right, ratio>1. To go straight, ratio=1.

Now this worked, to a certain extent. When I tell it to curve, it does curve, but the radius is not constant. Sometimes its getting smaller and smaller as the robot moves, and sometimes it gets bigger.

I tried to play around with the PID constants, and that seemed to do the trick. I suspect its the KI term that controls all this, but I'm not sure. I'm still trying to find out.

Can someone explain a bit more on the roles of each of the constants KP, KI, KD? I have done control theory and can imagine the step input curves with the rise time, oscillations, steady-state etc, but I can't relate to how the robot would move.  ???

Any help is appreciated  :)

Offline ArcMan

  • Supreme Robot
  • *****
  • Posts: 519
  • Helpful? 4
  • Mmmm... Plasma
Re: Using PID to move in a curve
« Reply #1 on: October 30, 2008, 12:59:12 PM »
You need to adjust your thinking a little.  The PID control loop should be used to attain the wheel rotation speed that you command.  Each wheel should have its own PID loop.  To run the robot in an arc, you simply command one of the wheels to a different speed than the other wheel, then depend on your PID loops to attain the commanded speeds.

Offline arixroboticsTopic starter

  • Full Member
  • ***
  • Posts: 119
  • Helpful? 3
    • TalasTronics WCIT KL2008 Fund Raising
Re: Using PID to move in a curve
« Reply #2 on: October 30, 2008, 04:09:25 PM »
Each wheel should have its own PID loop.


How can I do that when my robot has this setup:

So one servo will be for the drive and the other for the steering. Sort of Ackermann steering.

Currently, the output of the PID equation is fed into controlling the steering servo. That's why the error is calculated by comparing the two wheels, instead of comparing each wheel to a desired value.

I've been trying to tune the robot for hours yesterday, almost got it to curve perfectly, but suddenly everything went off. By that I mean the movement is off the desired path, not the robot turned off. I have no idea what happened, maybe the batteries are flat. Will try again today. Wish me luck  ;D

Offline arixroboticsTopic starter

  • Full Member
  • ***
  • Posts: 119
  • Helpful? 3
    • TalasTronics WCIT KL2008 Fund Raising
Re: Using PID to move in a curve
« Reply #3 on: October 31, 2008, 08:40:54 AM »
OK things has started to get better today. I've been trying to tune the PID constants all day long.

What I did was I draw lines on the floor to mark the curved path the robot should have taken. I then added some waypoints for reference. The path is a curved line with radius about a metre. The start and end points are 90degrees off each other from the center of the curve. So if a line is drawn to connect the start point, end point and curve center, it will look like a quarter circle.

Here are my observations so far;

1. With KP=20, the robot moved in a nice curve from the start and went through almost all waypoints. It went under-curved a bit at the last few waypoints. But the motion was perfect for like three quarters of the path.

2. With KP=5, the robot over-curved a bit at start, and then gets better and better. It then stops perfectly at the end point. This is like the reverse of case 1 above.

So here's what I think; for case 1, the rise time was fast, so the robot managed to follow the path right from the start. But there are probably steady-state errors, causing the robot to go off the course towards the end of the path.
 
For case 2, the rise time was too small, thats why it did not find the path fast enough. But it eventually finds it, and tracked it correctly. There was no steady-state errors, so the robot stopped exactly at the end point.

Do you think my observations and reasoning are correct? Or am I missing something here?

 


Get Your Ad Here