1 / 16

Robotics Programming

Robotics Programming. Wall Follow Line tracking for a set amount of time Line tracking for a distance. Learning Objectives. You will be able to understand at least one method of following a wall. Be able to write a program for a robot to follow a wall forever.

fritzi
Download Presentation

Robotics Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Robotics Programming Wall Follow Line tracking for a set amount of time Line tracking for a distance

  2. Learning Objectives • You will be able to understand at least one method of following a wall. • Be able to write a program for a robot to follow a wall forever. • Be able to add sensors and internal timers to stop the robot once it has tracked for a certain distance.

  3. Review • How does an ultrasonic range finder work? • What is the range of distances it can read? • What value does it give if it cannot see anything?

  4. Basic Wall Following • Pseudo Code • Forever: • - If the robot is too far from the wall • Turn into the wall • - else • Turn away from the wall. How is this done in code?

  5. Sensor Placement Considerations • Clear Path to the wall • Near the front to the robot • Mounted far enough from the wall to get a reading. (3.0 cm to 3.0 m or 1.5 to 115 inches)

  6. Sensor Setup • Motors and Sensors Setup -> VEX Cortex Digital Sensors 1-12 • Name the sensor (sonarSensor) • Select the Sensor Type • SONAR -> Units being measured • I will use Digital Port 8 in my demonstration. • You may assign a different Digital port.

  7. Pseudo-code to Code: Wall on Left Pseudo Code Forever: - if the robot is too far Turn into the wall - Else Turn away from the wall. task main() { int distance = 100; //Used for following 100 cm from wall while (true) //Forever { if ((SensorValue(sonarSensor)>distance) || (SensorValue(sonarSensor) == -1))//Too far { motor[leftMotor] = 10; motor[rightMotor] = 100; } else //Too close { motor[leftMotor] = 100; motor[rightMotor] = 10; } } }

  8. How can you modify the code to have the robot stop when it hits something?

  9. Incorporate a Touch Sensor • Place a ‘Bumper’ Switch in front of the Robot • Bumper Switch is a touch Sensor • Gives a value of ‘0’ when not touched • Gives a value of ‘1’ when pressed.

  10. Pseudo Code • While the robot has not bumped into something If the robot is too far Turn into the wall Else Turn away from the wall. • Stop the Robot

  11. Sensor Setup: Bumper (Touch) Sensor • Plug the Bumper Switch into Port 6 • Digital (1 and 0) Sensor

  12. Translating to code While the robot has not bumped into something If the robot is too far Turn into the wall Else if the robot is too close Turn away from the wall. Else Go straight Stop the Robot task main() { int distance = 100; //Used for following 100 cm from wall while (SensorValue(sensorTouch) == 0) { if ((SensorValue(sonarSensor)>distance) || (SensorValue(sonarSensor) == -1))//Too far { motor[leftMotor] = 10; motor[rightMotor] = 100; } else //Too close { motor[leftMotor] = 100; motor[rightMotor] = 10; } } motor[leftMotor] = 0; //Stop the robot motor[rightMotor] = 0; } Demonstrate your physical robot following a line until the touch sensor is pressed.

  13. Line Tracking for an amount of time • In this section you will modify the code for line tracking so it will go for a set amount of time.

  14. Pseudo-Code • Reset the timer • While there is still time • If light sensor is on black • Turn left • Else • Turn right • When the time is up, stop

  15. Translating to Code Reset the timer While there is still time If light sensor is on black Turn left Else Turn right When the time is up, stop

  16. Activities • Complete the Ultrasonic Wall Follower challenges • Each person will need to answer the first two questions. • Add the sensor to your robot so it can follow a wall and modify code to work with your sensor. • Demonstrate your performance to get it signed off.

More Related