Under the help section, locatio program 18.Detect Touch and program your robot to achieve the challenge brief
Here's the program I built.
Here's a quick video demoing it working.
Move Until Bump
Implement robot behaviour where each contact or touch is met by a reverse and 90 degree rotation
1. Investigate how you can use the touch sensor effectively in order to avoid long contacts with obstacles.
The wait block that pauses execution until a bump has been made only works in a few conditions, if you give a robot a number of rotations to complete then the move block will complete, or try to complete, before the wait block is even acknowledged meaning your robot may just drive aimlessly into the wall. To conteract this you must give all move blocks an unlimited value and control your robot from another location so as when you could recieve a bump it will be reacted upon instantly.
2. Investigate how to use loops within the program in order to program a revese-rotate scenario after each contact. Use our findings from last session in order to devise a reverse (duration = 1 rotation) plus a quarter circle turn (90 degrees left or right) after each touch detection.
Here you can see a program the goes forwards, and when the bump sensor is triggered it rolls back and does a 90 degree turn. After this it repeats and waits for the next collision.
3. Once your previous steps are done, try your robot inside the maze and write your observations. Comment on whether your robot managed to solve the maze, or if it was trapped in some unexpected loop holes. Try to explain your reasons for your observations
When I ran this code in the maze the robot was able to handle wider turns, and manage some of the corridors.
However it has no correction to aid it, so if it starts heading down a corridor at an angle it runs into the edge and filps onto its side/back and gets stuck.
If the robot manages to escap the embarassment of capsizing it takes the same turn over and over again meaning it can very easily enter a part of the maze it could never get out of.
4. Hypothetically speaking, with a robot with two touch sensors, would you have any additional capabilities or advatanges in solving a maze? Please explain what are the added advantages for having two sensors, which can determine left and right side contact separately
If we give the robot an instruction to go forwards for a set number of rotations it become stuck if the wheels aren't turning. Because the robot knows how many turns its wheels have made it just keeps trying to go forwards, so it just stays stuck. This is solved in our current desing by having a forward facing bump sensor, however if we want to reverse we then again face the problem if stuck wheels. A second bump sensor would allow us to detect this problem and totally elimiate situations in which the robot could become stuck.