PDA

View Full Version : Sensor Tracking the Boxes


mjt902
01-07-2003, 09:03 PM
I want to use a servo to rotate the optical sensor. When the sensor variable switches on, I want the chassis to turn the exact degree of the servo. (My engineer says to forget about it, so I need to do this quick before we rule it impossible:mad: :ahh:). Anyway, How do I get input or anything to control the turn degree on the chassis?? We have tank drive so it seems harder than the one joystick drive system we had last year.
I'm extremely thankful for any help I can get, and thanks 47 for the great site.

mjt

rbayer
01-07-2003, 09:36 PM
One thing you could do would be mount three optical sensors next to each other, spaced a few inches apart, with all three rotating together.

Then, once you get a "lock-on" from moving the servo, start turning in the direction that the servo is pointing. As you turn, move the servo so that only the center optical sensor sees the target (ie if the left sees it, move the servo left). Doing this, the servo will eventually line itself up with the robot.

nwagers
01-07-2003, 09:48 PM
perhaps you are attacking the problem the wrong way. We'll probably do this on our robot, so I'm hesitant to share, but mount the optical sensor in a fixed position and turn the robot until the sensor input changes. Once you have a "lock" just drive straight forward, the turning will already be done. I plan on scanning while following the white line.

Mongoose
01-07-2003, 10:53 PM
Once you detect the tape, you could rotate the servo back toward the center of the robot (the axis going from stern to bow) a couple degrees, turn the robot until the sensor reads true again, and rinse and repeat until the servo reads that it is pointing straight forward.

chewie
01-08-2003, 12:24 PM
hrm...i'm under the impression that the tape on the carpet is white....or so i have read from the manual, is it white or reflective?

FotoPlasma
01-08-2003, 12:32 PM
white

chewie
01-08-2003, 12:40 PM
so, i'm guessing the sensors are sensitive enough to detect the white surface, even though it is not as reflective as the reflective tape on the boxes?

rbayer
01-08-2003, 01:19 PM
In theory, yes. However, you will definately need to experiment with the correct gain setting (that little dial on the back) and the distance from the ground to find the optimal setting such that it reflects on the white but not on the carpet.

Mike537Strategy
01-08-2003, 05:14 PM
Anyone used the boe-bots? I am new on my team, and there was an option for new members to take a summer school course where out final test was to use optical sensors to follow a black line on a white surface and be able to turn off the sensors and skip over some white. That was fairly simple, and we had to convert the pre-given white line follower to make it follow black.

imjustmatthew
01-08-2003, 05:56 PM
Originally posted by mjt902
I want to use a servo to rotate the optical sensor. When the sensor variable switches on, I want the chassis to turn the exact degree of the servo. (My engineer says to forget about it, so I need to do this quick before we rule it impossible:mad: :ahh:). Anyway, How do I get input or anything to control the turn degree on the chassis?? We have tank drive so it seems harder than the one joystick drive system we had last year.
I'm extremely thankful for any help I can get, and thanks 47 for the great site.

mjt

we thought about trying that, but then ruled out "box finding" all together, because we didn't see it as time efficent with autonomous control, a human could do it far better.

Our solution however, was a variable gain sensor that would allow us to track the rotation of the light sensor. When we tested it the only problem was the detection range and width of the containor strips. At distance, you have to "hit" the tape on the containers almost exactly with your sensor's line of sight, and it has to stay in the line of sight long enough to register in your programs loop. Good luck with it if you try it.

Ryan Meador
01-08-2003, 06:09 PM
Don't forget our wonderful yaw rate sensor. I've used it in an application that could be equated to this, and it did it within a couple of degrees accuracy. I'm not sure if this is the solution my team is going to use or not... our (hopefully) unique chassis might offer another possibility ;)

mjt902
01-09-2003, 03:15 PM
To anyone that still cares about my original post:

I asked my math teacher how to figure distance based on a single angle. I found that to be impossible. Howver, if I read from the first sensor switch to on, then at the sensor switch to off, and move foward on the half angle an alotted distance, the process can be simplified. After moving foward an alotted distance, I take two more readings and parts of the imaginary triangles are revealed using law of sin and other stuff. This is necessary for the distance you want to travel to the boxes only if you want to pick them up.

Anyway, if you want an expanded explanatyion, just post and ask for it.

Gobiner
01-09-2003, 03:28 PM
The problem with that solution is that PBASIC doesn't have trigonometry support. At least, I'm pretty sure.

frumious
01-09-2003, 03:35 PM
You can always do trig with calculus using functions pbasic does support, altho you'd probably end up slowing the processor down so much that your execution time would provide noticable lag in doing anything

Tyson

Skabana159
01-09-2003, 03:57 PM
To find distance is pretty hard in PBASIC, anyways. We thought about it last year, but threw it away after realizing it would take up like 3 or 4 words. If you recall last year's kickoff, they had a crazy contraption with four light sensors on it, three stationary rotating on an axis and the fourth on top of them, rotating the light up and down. You could use this to find an angle between the ground and the top of the bin.
You could do all of this by finding the angle between flat and the top sensor, and finding the hypotenuse. However, sin, cosin, and tan are all unsigned integers in a word in PBASIC. However, if you didn't care about any of that, you could just chase down a bin by putting a pot on the robot, attaching the knob to your sensor array, and turning the robot untill the pot was 127 or whatever value is lined up.

Don Wright
01-09-2003, 03:59 PM
If I were doing what you asked in your original post (thought about it actually) is put a pot on the optical sensor to give you feedback where it's pointing. Then, if you know that straight ahead is 90 degrees, for example (if you are sweeping from 0 degrees to 180 degrees), you can then get an idea based on the voltage where the container is in relation to your position. Then, as you rotate or move your robot towards the box, rotate the sensor to keep the signal.

Then, as you are moving towards the boxes, keep scanning (only if you lose signal)for the tape to correct the direction. You should close right in on it...

Morgan Jones
01-09-2003, 04:01 PM
Originally posted by Gobiner
The problem with that solution is that PBASIC doesn't have trigonometry support. At least, I'm pretty sure.

PBASIC has SIN and COS functions (and therefore, tan can also be determined if necessary). The catch is that the angle must be in brads (binary radians). That is, there are 256 brads in a circle rather than 360 degrees or 2pi radians. Also there are no inverse functions, although I don't think that would be a problem in this case.

Personally, I'd be more worried about the inherent inacuracies of the the stamp processor. If you based your robot's movements on a calculated distance, you'd likely hit the stack and knock it over or fall short and pick up nothing.

K. Skontrianos
01-10-2003, 12:15 AM
Trying to use trig functions in BASIC is just a waste of time. We thought about creating our own inverse functions for our fully automated GPS-guided robot, but after research this option turned out to be way too complicated. Stamp simply is too archaic to be used for complicated math formulas. If you reseach, you'll find several threads on the topic. We used a type of dead reckoning for the robot, which was somewhat inaccurate, but successful.

rbayer
01-10-2003, 01:35 AM
In all honesty, the trig functions probably aren't that useful. It is far easier to do a simple lookup/lookdown to get the distance straight from your angle. Or, better yet, to get the motor speed directly from the angle.

Morgan Jones
01-10-2003, 03:02 PM
Originally posted by rbayer
It is far easier to do a simple lookup/lookdown to get the distance straight from your angle. Or, better yet, to get the motor speed directly from the angle.

Its probably a lot faster too... its always good to have as quick a loop time as possible.

gofortyeight
01-28-2003, 07:57 PM
C'mon nwagers.....you know you want to share this code.

mjt902
01-28-2003, 08:48 PM
So, what the majority of you all are saying is that the trig function solution is a waste of time...
i might still write a program for it just because i love math and it would look really cool so i still have a question for anyone who cares:

Where is the reflective tape on the boxes?? is it all the way around or is it only on corners??

Thanx for the help!!!:) :confused:

RoboCoder
01-28-2003, 08:51 PM
The reflective tape will be on two opposing corners of the boxes. Have fun doing trig functions in PBASIC, be careful that it doesnt slow the loop down far enough that it causes a run error from missed data!

mjt902
01-28-2003, 09:06 PM
OK, so now i'm a little scared (and running outta time) to do stuff with the sensors .:( However, I am woried about any complex coding causing run time errors. what might happen (our code last year was simple) as a result of using trig or calc in methods (referring to run time) ???

doomsdaytank
01-29-2003, 03:22 PM
ok there is a sin function in pbasic just to let everyone know so calm down read the pbasic manual and if you dont belive me put sin in the coding and you will see no error


fools

mjt902
01-29-2003, 04:24 PM
Fady, once again- people are smarter than you. Don't call me a fool. Also, if the loop gets large enough, I think these people are saying that a run time error will occur- not a logic error.

So anyway, I'm still worried about it. I'm willing to sacrrifice 5 seconds of atonamous mode to run through the math, is that enough time to take 4 sensor readings and go through about 7 calculations (not the taylors calc method, just SIN, and angle arithmetic using the 255 rotation thing)???