0
$\begingroup$

I’ve got 2 motors that drives my unit and I can easily steer it manually by simply adding more speed to one wheel vs the other.

Now I’m automating the rover using image processing to follow a driveway. As the rover travels I calculate the distance in pixels between the rover center and the target (middle of driveway). I then use some factor (1.1) and use that to add speed to the correct wheel.

Kinda works good until it needs to make large corrections. I can only update the speed every .75secs.

After it turns and drives to the middle the wheel speeds are equalized - but the rover is pointing in the direction of the turn. In the best case it then goes past the center before correcting back again and eventually stabilizes.

Original Poster here with some more details of what i've tried so far. Attached is a frame from my imagine processing. As you can see i have 2 green circles along the edges that define the sides of the road and a green circle in the middle that is simply the mid-point between them (TARGET). This isn't a great example because I also have a red circle behind the center which indicates the center of the camera (CENTER). When i am not centered on the driveway the TARGET will be some number of pixels from CENTER - this is my DELTA as indicated in the legends.

So what i have so far is that i take DELTA and multiple it by 1.1 and then add that to the correct wheel to steer it back towards the center. Each time I get a new image frame (every .5 - 1sec) DELTA is smaller and I reduce the rate of the turn - but its still turning. Once I get to the center or past the center I either make both motors the same or i add to the opposite motor since i over corrected.

If things go well this actually works good enough - i get some S turns as it zeros in on the center. Problem is when the image processing doesn't work perfectly and the algorithm needs to make large changes. In this case the DELTA needs to be significant to turn it but then reduce so it doesn't turn beyond the center point.

In a perfect world i would be able to turn a calculated amount depending on how far off i was (size of DELTA), drive straight to the center, then turn in opposite direction a specific amount to center the rover. Problem is i need to do this relative to each frame from the camera as the DELTA gets smaller as i am correcting.

This really feels like i'm trying to invent a new algorithm for something i have a feeling has been solved a long time ago. I am not 100% sure what a PID controller does but I have a feeling it may help here. Or do i need some sort of additional piece of information (feedback?) to indicate my orientation?

I don't need perfect here - just want the rover not to go off the side of the driveway...

enter image description here

$\endgroup$
2
  • $\begingroup$ Welcome to Robotics, Dave In PA. As-is, the question is kind of open-ended. Do you have a particular approach you'd like to try? Simplest/naive approach would be to save whatever rotation you're making to point your vehicle to center and then apply the opposite rotation when you're at center. You could also make S-curves to "merge" to center, you could use PID line following to track to the center, etc. $\endgroup$
    – Chuck
    Dec 6, 2021 at 14:10
  • $\begingroup$ Please edit your question to include details of what you'd like to try and what issues you're having with implementing that solution to narrow things down and make this an answerable question. $\endgroup$
    – Chuck
    Dec 6, 2021 at 14:10

1 Answer 1

2
$\begingroup$

Based on the suggestion “look into PID”l controller” I did some more research on that for line following and that’s exactly what I was looking for. Funny in some ways my naive algorithm already uses a P factor to adjust the error. The I and D will help smooth out the amount of overshoot when I hit the center and minimize the “S turns” to stabilize.

Will need to fine tune it but this seems like the standard approach for line following (which is basically what my image processing does). However it is very dependent on the initial position being with the correct orientation and close to the line. If the rover gets too far out of position it may not be recoverable. But I’ll have to solve for that with additional logic.

So the answer (thanks chuck or bill) is applying PiD control algorithm to calculate the error correction to the individual motors.

$\endgroup$
1
  • $\begingroup$ Hey glad you found an approach that works for you! Don't forget to come back and accept your own answer when you're able :D $\endgroup$
    – Chuck
    Dec 7, 2021 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.