Obstacle avoidance
Using 2 ultrasound sensors, we could manoeuvre the robot to avoid large obsticles such as walls.
The sensors are placed as highlighted in the diagram, they are diagonal allowing for 2 sensors to monitor 3 sides of the robot (front,left and right).
As the distance in one sensor is lowered past a certain threshold, meaning that the robot is getting closer to the object on that side of the sensor, the wheels on the opposite side of the sensor start to slow down making the robot turn away from the closening obstical. If both distances are lowered then it prioritises the lower of the two. The reduction of the speed of the wheels is dependant on how close the object is to the sensor, this can be judged easily using simple if statements in python.
*Numbers shown in the image might not reflect those in actual code
The closer the robot gets to the obstacle, the faster it turns away from it. This not only creates a satisfying curve the robot follows, but also makes it so that if the robot gets too close to the wall it reverses and then continues turning which stops the robot from crashing into the obstacle.
The rate at which the robot turns was found through testing by setting up the robot as different angles to wall and seeing how it behaves. depending on the results we fine tuned the rate of turning to make it more fluid and faultless, though we did encounter some problems
Corners
The main problem we encountered was the robots behavious when going into a corner, as it got closer to the corner it attempted to turn away from the side it is closer to, but this in turn makes it closer to the other side which insitls a responce from the robot to turn away from it, which then again makes it closer to the original side. This makes the robot perform a wierd dance as it gets closer and closer to the corner not being able to turn away fully.
As shown above, the robot when closing in on a corner wiggles side to side unalbe to escape it. We solves this problem by checking when the robot got too close to one of the walls of the corner and turning it away from that wall for a specific amount of time, ignoring the change in the distances while it is turning.
However, this created another problem being that the robot would collide against the obsticales as its turning, for while its turning it is also moving forwards at the same time. This was somewhat solved by making it turn on the spot instead, though at times it still hit the walls as the lentht of the back of the robot was not considered.
We finally solved the colliding by making it reverse a set amount before begining the turning on the spot, this gave the robot a safe area away from the walls to turn in.
Add comment
Comments