![]() |
Re: Programming - Getting Started
*****************************
** The Rookie Programmer's Primer ** ***** by Dr. Andrew Winslow ****** ***************************** What follows is a guide/list of do's and dont's for Rookie Teams to help them get a focus of how to approach the programming process for their "First" robot. This guidebook is basically a list I've come up as I helped mentor my First (USFirst.org *and* first-time mentor hehe) team. The team itself was a Rookie team just as I was a Rookie mentor. Needless to say, it was a tremendous learning experience for all involved. Here we go: ************************************************** ******** ************************************************** ******** Job #0: Access Code Your zero'th job as a programmer will be to understand your programming environment (EasyC, MPLAB, LabVIEW, etc..). You will need to know how to use While Loops, If/Then/Else Statements, Declare Variables, create Timers and Waits, and create Subroutines. All of these functionalities of the language should be well understood to where you can perform them with ease. You will also need to know how to download your code down onto your bot's controller. Trust me when I say you will be doing this a lot, so you should be able to push your code at a moments notice. Note: COMMENT YOUR CODE!!! Placing comments throughout your code will make your job easier and will also aid anyone else that may need to look through your code. It is a real life-saver during debugging. ************************************************** ******** ************************************************** ******** Job #1: Sunday Driver Your first job as a programmer will be to get a basic driving program written for your bot. Typically, most teams approach their chassis first, so you should get this code going asap. Having a driveable bot will be a great sense of achievement for your whole team and will fuel the desire for more success. The team I was on was able to (in a 12 hour day), complete the chassis and drive train, and get a basic 2-joystick tank drive program downloaded onto the bot's controller. It was a wonderful kickoff for our team and injected loads of enthusiasm that kept us coming back for more. ************************************************** ******** ************************************************** ******** Job #2: I Sense Trouble Your second job as a programmer (after getting your chassis driving) should be to start work on understanding all of the sensors shipped in your First Kit. The benefit of this is that it is a programming task that can be performed in parallel with the mechanical/electrical design and fabrication. Here's the order I would recommend tackling them in: 1) Gear Tooth Sensors - As a rookie team, you will likely not have time to work on the more advanced sensors like CMU Cameras and such. This pair of sensors, to be mounted near the drive sprockets on either side of your bot, will ultimately enable you to have a bot that can drive (roughly) straight, and then be able to turn corners at programmed distances. This is the primary sensor needed to get a basic program written to have your bot be able to run a pre-programmed course *autonomously*. The 'pre-programmed' part will take a bit of work and will require *dedicated access* to a working chassis, so for starters, just work on understanding how to measure the sensor. Once you have a program that can measure this sensor properly, move on to the next sensor. 2) Contact Switches - Contact Switches (a.k.a. Limit Switches) are integral to the design of many bots. They will allow you to sense when an arm or other moving part has reached a given location or attitude. They can also be used on bumpers or other parts of your bot to detect if it has contacted a wall or other obstruction. 3) IR Board - This board will allow you to send up to 4 commands to your bot using a common stereo or tv remote control. The team I was mentoring never had time to get this sensor working and I greatly regret not seeing the value it would have given to our bot. 4) Yaw Rate Gauge and Accelerometers - Note: YOUR BOT WILL BE HIT! This is an unwritten fact. However, successfully measuring these sensors will be able to tell you how much your bot has been turned and moved by the collision. You can then feed this information back to your Gear Tooth Sensor code to be able to correct for the wheel-slippage and thus get you back on track. If understanding these sensors starts taking too long, they can be dropped and you can just run your bot autonomously using a lot of faith and luck. There may be more sensors your team has sketched into your design. If the sensor is critical to the success of your bot, tackle them as well. If it begins to take too long though to get them running, put them on the back burner and move on to the next phase. A side note on sensors: Have your electrical design such that the robot controller board is easily removed from the bot. This will allow the programming team can yank it out while the mechanical/electrical teams are working on the rest of the bot. While it is removed, you can connect your pc up to the programming port on it, connect your sensors, and toy around with them without interfering with the other parts of your team. ************************************************** ******** ************************************************** ******** Job #3: It's All About Control After getting your sensors up and running, you will need to start work on the Controls for your bot. This involves all physical actions your bot needs to do to perform its assigned task and includes all of your bot's motors, actuators, and pneumatics. You should tackle these in order of importance to your bot's design. If you have a lifting arm that does most of the work, make sure you understand how to accurately drive its motor so the arm gets where it needs to go. If you have pneumatics, learn how to make your pistons extend and retract properly. A design note here: For the actionable parts of your bot, try to envision whether they will need to be controlled via analog or digital. Any given action needs to be able to be set to either a range of values (analog) or to purely on/off, up/down, or forward/backward values (digital). Be sure to count all your inputs (sensors) and outputs (controls) and make sure that the robot controller board has enough I/O ports for the task. ************************************************** ******** ************************************************** ******** Job #4: System Integration This is the last step of the fabrication process. It is the process of bringing all the parts together into a working whole. If all teams have been working in parallel with one another, hopefully everyone should reach this phase at nearly the same time (I did say *hopefully*). Granted, the programming team may be a bit behind the others. This will be due to the fact that you've been trying to write code for something that you haven't had dedicated access to. This will likely be your crunch time. Late nights will be spent here so be sure to stock up on your favorite caffeinated beverage and memorize the phone number to the local pizza delivery guy. ************************************************** ******** ************************************************** ******** Job #5: This Is Just A Test The final phase is testing. Test - Refine Code - Deploy - Lather - Rinse - Repeat. One good thing about this phase is that you've already memorized the phone number to the local pizza place. You may need to restock on sodas though. ************************************************** ******** ************************************************** ******** I hope this information can be used to help future Rookie Teams be able to achieve as much success as can be had. Good Luck!!! - Andy |
Re: Programming - Getting Started
can anyone tell me what macros, constants, and stuff like that are for? as in, what do they modify-Relays,PWM or what? and can i have an example of a code and tell me what it does to the robot?
|
Re: Programming - Getting Started
Quote:
Instead of changing pwm01=150; to pwm03=150; You would just change a value assigned to the macro like Left_wheel_pwms pwm03 It save a lot of time spent on hunting errors. A constant is user defined such as pi 3.14 and helps the compiler catch errors. Sorry, can;t give code right now,no computer and I don't type very fast. |
Re: Programming - Getting Started
where can i find a gear tooth sensor code? Just post the link.
thank you in advance, team 2604. |
Re: Programming - Getting Started
Quote:
|
Re: Programming - Getting Started
Quote:
Thanks Andy!!!! Jacob |
| All times are GMT -5. The time now is 11:20. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi