1
$\begingroup$

We have a tunnel and the distance from the walls to the robot is about 30cm when the robot is centered, the tunnel curves to the right. The robot has an infrared sensor on its left and one on its right and has an ultrasonic sensor at its front (so basically its eyes). How can I make the robot turn appropriately while its moving so that it's centered in the tunnel. I just need an idea for this algorithm because I can't find any. All what the infrared sensors can do is measure the distance to the walls.

| improve this question | | | | |
$\endgroup$
  • 3
    $\begingroup$ Walk slowly down a hallway at your house, or at your school. ... Think about what the robot does. ... Measure distance to each wall. ... What do you do with your motors if the distance is too small? ... Write it down in a flowchart form. $\endgroup$ – jsotola Feb 12 '18 at 16:42
1
$\begingroup$

One possible method is to find the width of your robot, subtract that from 30 cm, then half the remaining distance and if one of the IR sensors reads less than that number, turn in the other direction.

| improve this answer | | | | |
$\endgroup$
1
$\begingroup$

I agree with @NikolaPi in principle. But the controlling/driving mechanism is important here. If you are using PID controlling, then steering the robot can be very smooth. All you have to do is to tune the variables so that when robot starts getting closer to lets say, left wall, left motor's pwm increases w.r.t. the right one and vice versa. This way the robot will remain in an imaginary boundary/lane that is slightly wider than the robot but significantly smaller than the Tunnel's width. But the tuning will take a little effort to find the sweet spot where the correction neither occurs too often nor too late (Hint: You robot should move almost straight without compromising on speed. If its is moving in the form of the letter "S", your limits are too generous).

On the other hand, if you are using the simpler On/Off Controlling technique (also known as band bang approach), you take a limit of IR sensor reading from one wall and program according to that. If it crosses the limit, stop the other sides motor for some time so that the robot comes back to its center position. But beware that in this approach, with the battery voltage drop, the response from the motors changes. What I mean is that if you tune the robot to switch off motor for 100 ms in case of limit detection and it comes back to the good position, when the battery would get drained a little, the robot would need 130 or 150 ms of switching off to make the same correction. Of course it won't be able to as you have set it to 100 ms so there will be an error in the robots's position every time an adjustment is made. Eventually, these errors will pile up and the robot will collide with a wall.

| improve this answer | | | | |
$\endgroup$
0
$\begingroup$

If I understand correctly, all your sensors look ahead, but you want safety to the sides.

Maybe it would be better to turn the IR sensors 90deg so they check the distance to the side walls, while you keep the ultrasound sensor to look ahead.

Using the data from the three sensors, you should be able to create a limited map of the robot inside the tunnel, which will be the basis for controlling the movement.

| improve this answer | | | | |
$\endgroup$

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.