View Single Post
  #9   Spotlight this post!  
Unread 14-06-2006, 00:20
artdutra04's Avatar
artdutra04 artdutra04 is offline
VEX Robotics Engineer
AKA: Arthur Dutra IV; NERD #18
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: Mar 2005
Rookie Year: 2002
Location: Greenville, TX
Posts: 3,078
artdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond repute
Re: VEX Start Kit Projects

Quote:
Originally Posted by 1885.Blake
PS: Don't keep us in suspense. What are the magic 3 lines of code? :-) I have Vex ultrasonic sensors and I don't mind getting a peek at how other folks have used ultrasonics in the past.
Don't worry, I like sharing my knowledge! Besides, isn't the whole point of Chief Delphi to share knowledge?

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:
Originally Posted by 1885.Blake
Agreed - But
2) (Vex) Ultrasonics aren't spec'ed to work when the wall is very close to you
That's not a problem. The Vex Ultrasonic Sensors are spec'ed at 3 inches to 10 feet. So in order to ensure that an object (wall) can never be closer than 3" is to place your sensor at least three inches inside your robot frame. Like this:


Voila, no more 3 inch problem!
__________________
Art Dutra IV
Robotics Engineer, VEX Robotics, Inc., a subsidiary of Innovation First International (IFI)
Robowranglers Team 148 | GUS Robotics Team 228 (Alumni) | Rho Beta Epsilon (Alumni) | @arthurdutra

世上无难事,只怕有心人.
Reply With Quote