Sensor Tracking the Boxes

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

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.

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.

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.

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?

white

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?

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.

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.

*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.

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 :wink:

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.

The problem with that solution is that PBASIC doesn’t have trigonometry support. At least, I’m pretty sure.

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

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.

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…

*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.

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.

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.

*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.