|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#7
|
|||||
|
|||||
|
Re: VEX Start Kit Projects
Quote:
Unfortunately, I don't have the exact code anymore, as it was on a laptop owned by WPI. The algorithim here was my rough draft working one; you would definitely need to tweak the coefficients in there in order to get good results. Here's the general jist of it: you get the Ultrasonic sensor value, and you use that value to change the speed of each motor. The farther you are away from the optimal path (grey line in diagram below), the faster you want the robot to react. If the robot is way off the line, you want it to turn fast to get back to the line. But if the robot is very close to the line, then all you want to do if go mostly forward, and only turn a little bit. ![]() So here is what we need to do: 1. Get ultrasonic sensor values. 2. Make sure range of ultrasonic values are less than 127. 3. Add ultrasonic values to one motor, subtract from the other, keeping everything proportionate. 4. Set motors to these new variables. I do have (somewhere) the notes I took when I originally made the algorithim for this, and I will look for it tomorrow to post online if you need it. Or... Using a printscreen command in the code, manually drive the robot along a wall a set distance away, and drive in a zig-zag pattern as if you were the robot following the wall. Record the values needed for your specific robot to make the turns in an Excel speadsheet. Using this data, try to find an equation to best fit the data, and then you can use that in your algorthim. (Remember, the part of C programming that makes this all possible is that any conditional statement inside parenthesis will return a 1 if true, and a 0 if not. So using the assignment left_drive = 127-42(ultrasonic_value>40); will return either 127 if the ultrasonic sensor value is less than 40, or it will return an 85 if the ultrasonic value is greater than 40. It is these conditionals inside an assigment that makes the three-lines of code possible.) Quote:
![]() Voila, no more 3 inch problem! ![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Vex start up code run PWM outputs without Rx | intellec7 | Programming | 3 | 05-05-2006 23:29 |
| vex programming kit | Alex Burman | FIRST Tech Challenge | 1 | 30-03-2006 18:30 |
| Start a Vex team NOW! | skimoose | FIRST Tech Challenge | 4 | 25-01-2006 14:43 |
| VEX kit SALE/DISCOUNT !! | Stu Bloom | FIRST Tech Challenge | 10 | 13-11-2005 23:24 |
| VEX EDUbot hybrid or $50.00 VEX kit? | Tazlikesrobots | Robot Showcase | 15 | 13-08-2005 22:12 |