Presentation is loading. Please wait.

Presentation is loading. Please wait.

Engineering H193 - Team Project Gateway Engineering Education Coalition P. 1 Spring Quarter 2008 Robot Programming Tips Week 4 Day 2 By Matt Gates and.

Similar presentations


Presentation on theme: "Engineering H193 - Team Project Gateway Engineering Education Coalition P. 1 Spring Quarter 2008 Robot Programming Tips Week 4 Day 2 By Matt Gates and."— Presentation transcript:

1 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 1 Spring Quarter 2008 Robot Programming Tips Week 4 Day 2 By Matt Gates and James Beams FEH Class of 1999

2 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 2 Spring Quarter 2008 Robot Programming Tips

3 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 3 Spring Quarter 2008 Limitations of the Handy Board Limited memory (16K available for program code) Limited CPU speed Very slow floating point calculations (no floating point hardware) Limited I/O (LCD screen, 7 analog, 8 digital ports) Strategy: Code must be small, fast, and make efficient use of the resources you have.

4 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 4 Spring Quarter 2008 Limitations of the System Controlling a mechanical system is much different than controlling a computer! –Why? System will never run the same way twice! –System runs in real time, independent of your program. You must constantly monitor the system and ensure that what you want to happen is actually happening. –Test, test, and test some more!!!

5 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 5 Spring Quarter 2008 Strategies I: What NOT To Do DO NOT write one large main ( ) DO NOT write code without error checking DO NOT assume your code will work right DO NOT use lots of memory or complex algorithms DO NOT wait until the last minute to test your code

6 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 6 Spring Quarter 2008 Strategies II: Maintainable Code Break your code into small segments (functions) that perform specific, simple tasks. –Example: motors_half_speed ( ) Use symbolic constants (#define) instead of literals. –“motor (LEFT_SIDE, FULL_POWER)” –NOT: “motor (1, 100)” Makes it easier to update your code if you make changes to the robot design or your goals.

7 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 7 Spring Quarter 2008 Strategies III: Getting Around The most difficult part of your task will be getting from Point A to Point B. –Driving straight –Turning –Avoiding obstacles

8 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 8 Spring Quarter 2008 Strategies III: Getting Around You should spend time developing and testing a routine that allows you to move around reliably. –Use shaft encoder data to keep wheels @ same RPM. –Shaft encoders can also help in turning. –Have adequate bump sensors and intelligent responses.

9 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 9 Spring Quarter 2008 Pseudo code Example #1 The following pseudo code example is for a ‘drive_straight’ function for a specific distance to be traveled and which corrects for uneven motor speeds.

10 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 10 Spring Quarter 2008

11 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 11 Spring Quarter 2008 Strategies IV: Break up Course The course can be handled more easily if you break it up into sections or tasks. –Ex: Determine object values, navigate to and pick up object, navigate and drop off object. Write code to handle each section separately. –Now you can test parts of the course individually. –Use the knob to select what section of code to execute.

12 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 12 Spring Quarter 2008 Pseudo code Example #2 The following pseudo code example breaks the course (for that year) into six routines.

13 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 13 Spring Quarter 2008

14 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 14 Spring Quarter 2008 Strategies V: Multithreading IC can run more than one functional “thread” at once. –Useful to perform background monitoring while doing main tasks. –Ex: Run “drive straight” code to make corrections to motor power while driving.

15 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 15 Spring Quarter 2008 Strategies V: Multithreading The more threads running, the more CPU resources used. –Can hurt IR reception, shaft encoder counts, etc. –Should keep number of threads small. See IC documentation on start_process ( ) for more info.

16 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 16 Spring Quarter 2008 Strategies VI: Testing Thorough testing is essential! Tips: –Begin by testing individual course sections, then combine until you can do the whole course. –Use the LCD screen to output useful values (ex. shaft encoder ticks, motor power, course side, IR output). –Make sure your robot will work even if the battery charge is low. –Don’t stop testing until the competition is over!

17 Engineering H193 - Team Project Gateway Engineering Education Coalition P. 17 Spring Quarter 2008 Grade Sheet for Pseudo Code / Flow Chart ITEMPOINTS Cover Page2 Introduction / Purpose2 Logic / Illustration / Description14 Modular by Function4 Completeness4 Format / Clarity / Neatness4 TOTAL30


Download ppt "Engineering H193 - Team Project Gateway Engineering Education Coalition P. 1 Spring Quarter 2008 Robot Programming Tips Week 4 Day 2 By Matt Gates and."

Similar presentations


Ads by Google