Avoid Obstacles
Last updated
Was this helpful?
Last updated
Was this helpful?
Now that you are an expert with the Scout and MODI sensor, we can use this knowledge to avoid obstacles during navigation. In this module, functions define a set of motor motion commands (Forward, Stop and Turn). Loops and conditions then provided instructions to control the robot.
This block instructs the robot to move forward with both motors at a speed of 80.
This block instructs the robot to stop both motors.
This block instructs the Scout to turn both motors in opposite directions at a speed of 80, for a period of 400 ms.
After connecting with the robot, pressing the g key will kick off the control loop. The program will move forward if the distance reading is below 160 (and not 0). Whenever this is not the case, the robot will stop and turn. A 0 reading implies that no objects are detected by the sensor, or that it’s not enabled.
Please note that in each of the functions, there is a 1 second delay after the commands are issued. This is extremely important. If you don’t include the program will issue the command repeatedly, which could cause unwanted results. Computers are fast and this program can issue up to 30 commands every second!