The program should follow this pattern. But I don’t know where my code is going wrong as whenever my robot takes a left turn it gets hit by a wall and doesn’t move further. Please help!!
I HAVE ADDED MY CODE IN THE COMMENT SECTION!
- If the laser reading in front of the robot is higher than 1 meter (there is no obstacle closer than 1 meter in front of the robot), the robot will move forward.
- If the laser reading in front of the robot is lower than 1 meter (there is an obstacle closer than 1 meter in front of the robot), the robot will turn left.
- If the laser reading at the right side of the robot is lower than 1 meter (there is an obstacle closer than 1 meter at the right side of the robot), the robot will turn left.
- If the laser reading at the left side of the robot is lower than 1 meter (there is an obstacle closer than 1 meter at the left side of the robot), the robot will turn right.