Go to Post I pumped my fist to cheer - but since I was a ref at the time it looked like I signaled a red foul... - Tom Ore [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 25-04-2010, 11:26
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 328
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Thumbs up IR Sensor Class w/ IR sensor mounted on servo

Hi Gang,

I've attached a C++ project that searches for items of a specified size range and returns the angle and distance to that item. The angle is set so that 0 is straight ahead, - is to the left and + is to the right for the return values. The distance is in inches, although the formula could easily be modded to report in cm for our metric users. In addition, the code can be instantiated multiple times for multiple, simultaneous scanners.

There is copious documentation in the class. To the level that I really wish the WPILib was documented -- hint, hint WPI... Plus, I've added all sorts of get/set calls to change the behavior of the scan, starting and ending angles, step rates of the servo, minimum and maximum distances, etc. It works pretty well for finding objects in the IR sensor's (Sharp GP2Y0A02YK0F long-range IR sensor) field of view. I've also got alternative distance measurement formulas if you're using the short-lange GP2Y0A21YK0F sensor.

This project just shows the sensor and its output, it isn't hooked up to drive the robot. Another cool thing about this class is that it creates a separate thread that drives the scanner while the reader (ostensibly the robot code) runs asynchronously. Also, for you true VxWorks aficionados, the scanner thread uses a VxWorks message queue to communicate with the robot code via a getNextObject method.

The file is a Workbench build project and can be imported from the workbench project dialog. In addition, in the directory, there is a Makefile that will build the class into a library so you can just link against it ala WPILib rather than include the code into your project. This is too late for the 2010 build season, but hopefully it will eventually find its way into WPILib.

If you've got any questions about the code, I'd be happy to respond and explain. Just PM me or respond to this thread.

HTH,

Mike
Attached Files
File Type: zip IRScanner-Aware-Project.zip (996.5 KB, 93 views)
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Analog ultrasonic sensor class? Phoenix Spud C/C++ 7 27-01-2009 09:46
IR Sensor mechman9113 Programming 9 29-01-2008 16:18
IR Sensor fabalafae Programming 1 19-01-2008 16:53
Sensor or no Sensor For Autonomous mode Kyle1010 Programming 14 22-01-2003 13:10
Sensor Q Brew Technical Discussion 2 10-02-2002 12:48


All times are GMT -5. The time now is 04:19.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi