PDA

View Full Version : Gun panning and distance sensors



ntopper
07-24-2013, 10:54 AM
HAs anyone played around with the idea of using distance sensors and a little bit of trigonometry to auto-aim guns that are not in the center of the mech? (for instance if you have two guns)

It's something I have been thinking about lately. In theory, if a pair of guns were a mm from the center of mass (presumably the FPV crosshair overlay) and a distance sensor knew a target was b mm away, then the angle of the guns should be + and -arctan(b/a)

The ping ultrasonic distance sensor (http://www.parallax.com/tabid/768/productid/92/default.aspx) is real easy to get a hold of and use, but because it uses sound I'm not quite sure how it would be perform with such an irregular object like a mech warfare bot. (What do you guys call them just mechs?)

Anyway, when I get back in town from my vacation I'm going to wire up a breadboard with a pair of servos and my ping sensor and see if I can get it to track my hand, then I'll mess around with more ugly shaped objects to see what happens.

Has anyone else played with this idea at all?

jwatte
07-24-2013, 11:17 AM
There are mechs with articulated side-mounted guns; I don't know whether they use a distance sensor.
I'd want an optics-based one, as the Ping sensor is not focused enough and would likely pick up walls of buildings or the arena.
I have two guns on mine, too, but they are mounted with a fixed toe-in. Instead, I have two lasers (one on each gun) so I can tell about where each shot will land.
I've considered correlating the laser dot in the camera's field of view for a rough LIDAR-like distance measurement based on parallax, but I don't think I'll actually need it.

ArduTank
07-24-2013, 11:23 AM
Ntopper, I would personally use IR rangefinders. They'll sense a much more focused spot. You'll be aiming at a flat target panel, anyways.

ntopper
07-24-2013, 11:38 AM
I imagine the panels are near the camera's on most setups. would an optical rangefinder blind a camera? I imagine the cameras don't like having IR beamed right into the lenses.

ArduTank
07-24-2013, 01:16 PM
99% of them would have an IR filter in them so that it doesn't blind them. pointing an IR rangefinder at a camera would be like looking at a TV remote through a camera, except a little brighter.

YoMarchYo
07-24-2013, 06:42 PM
I've bought myself a ping sensor and IR ranger for this too. Haven't tested yet.

I can see problems with both set ups: With IR the range of detection can be somewhat limited. With ping the window of detection can be pretty broad. I've thought about making a tube with sound deadening material to place over the receiver of the ping to see if it might help with only allowing sound waves nearly perpendicular to the sensor to come through, hoping to narrow the window of detection. However, it's a pressure wave not a light wave so I'm not sure how well it could actually work. It worth a test though, I'll probably try wiring it up this week.

Edit: Also worth mention is the possibility of IR rangers being confused by arena lighting, especially if there's a good deal of natural light. Could just be worth it to use both sensors.

ArduTank
07-24-2013, 06:49 PM
Or a laser ranger. That would not be fooled by natural light, or it's detection window. The only problem might be if the spot that the laser is hitting is too dark to reflect enough of the laser back.

YoMarchYo
07-24-2013, 06:54 PM
There you go. I don't have experience with laser rangers though, but I can only imagine that a laser ranger in a package that's small enough and has easy interface to a microcontroller would be pretty expensive.

ArduTank
07-24-2013, 08:39 PM
Granted. Or, if you could get the processing power to do it, do a stereoscopic camera setup, aka, two cameras with a fixed distance.

YoMarchYo
07-24-2013, 11:05 PM
Haha. You almost read my mind. Except I was thinking of it the other way around. 1 Camera, 2 lasers and computer vision. Measuring the distance between the lasers points to find distance. Could definitely be problems with the 2 laser points landing on surfaces that aren't contiguous but both concepts might find use elsewhere.

jwatte
07-25-2013, 12:40 AM
You could do it with a single camera and a single laser and mounting the laser parallax to the camera. Just measure which dot in the cameras field of vision has the highest brightness (== hit by laser) and you can calculate the rest by trigonometry. (This is how the Neato LIDAR works, for example.)

If the camera is horizontal with the laser, and pointed straight forward in the same direction as the laser, and the laser is parallel with the camera (or even if it isn't!) then the point will be far out to the side when the hit surface is close to the camera, and close to the center when it is far away. In effect, it's like the suggestion with two lasers, except implicitly use the center of the camera as one of the "beams."

ArduTank
07-25-2013, 08:23 AM
That could work too. Funny thing is, I looked up cheap laser rangefinders yesterday, and came across the Neato LIDAR.

ntopper
07-25-2013, 10:26 AM
How are guys with dual guns doing it now? Iv'e noticed some of them doing even pan. I'm guessing just getting a high number of pellets in the general direction is pretty effective. But the auto-panning has a major coolness factor.

ArduTank
07-25-2013, 10:41 AM
They either have them close enough to set a slight toe-in or they have an adjustable toe-in. You could do something similar by having two laser pointers, one for each gun, if you have them on the same pan/tilt setup, and then just adjust the toe-in to get the two dots to overlap.

ntopper
07-29-2013, 09:34 AM
I was going to write a tiny C++ library that did the trigonometry to find the toe-in angle. But I didn't think it was necessary, because it's pretty much a one liner.

It goes something like:
atan(distance()/radius) * (PI / 180)

Where distance() returns the distance value measured by whatever sensor is used, radius is the position relative to the sensor (I say position, not distance, because the right hand side should be positive and the left hand side should be negative). (PI/180) is just the rad to degree conversion.

That should give the toe-in angle, where 0 degrees is no toe in. When I'm back from vacation I'm going to build a little rig with a pair of servos and see if the therory works in pratice

jwatte
07-29-2013, 11:58 AM
Idea: Put a red and a green laser on. Use the camera. If the green dot is to the right, more toe-in, else less toe-in. Repeat forever :-)

ntopper
07-29-2013, 01:37 PM
Idea: Put a red and a green laser on. Use the camera. If the green dot is to the right, more toe-in, else less toe-in. Repeat forever :-)

Until I face my one weakness: a green or a red robot.

That being said, a harry robot would do a good job hiding from ultrasonic and photoelectric distance sensors.

CogswellCogs
07-29-2013, 02:34 PM
No green lasers allowed, I believe.

And who wants a mech that sheds, anyway ?

jwatte
07-29-2013, 03:06 PM
No green lasers allowed, I believe.

The last I saw was "class III lasers suggested not allowed" and most green lasers are 5 mW, and thus class III. I think that was mostly for "try not to blind the other guy" reasons.
Are there 1 mW green lasers?
Could you use blue instead?
Could you use red lasers with different shapes?

Also: You're allowed to put a post-it note or frame on the target panel of your enemy, so a black (or red, or green) target panel can be partially worked around that way.

CogswellCogs
07-29-2013, 05:12 PM
The green laser thing came up at RoboGames this year. I think I remember Tyberius saying no to green. It may have been a power issue.

ArduTank
07-31-2013, 09:36 PM
Cogs, a solution to that would be two red lasers, and you looking at the video feed. if they are apart, adjust the toe-in until they meet.

tician
08-01-2013, 12:25 AM
For some reason, I was just thinking of three laser pointers in a fixed mount around each barrel ala predator. Not only gives you the center of each barrel, but can also be used to approximate distance to target depending on the known angle between the laser mounts and the lengths of the edges of the triangle formed by the laser dots (or use three line-type laser pointers instead of dot pointers). Yet another project that I might start and then promptly abandon...

ArduTank
08-01-2013, 07:35 AM
Tician, that's how I'm planning on designing the lasers on HS Walker's single gun.

byi
10-13-2013, 02:56 PM
I've bought myself a ping sensor and IR ranger for this too. Haven't tested yet.

With ping the window of detection can be pretty broad. I've thought about making a tube with sound deadening material to place over the receiver of the ping to see if it might help with only allowing sound waves nearly perpendicular to the sensor to come through, hoping to narrow the window of detection. However, it's a pressure wave not a light wave so I'm not sure how well it could actually work. It worth a test though, I'll probably try wiring it up this week.


I have had success with the sound dampening foam used in studios for this sort of thing. A piece about an inch thick with a hole cut to the size of the sensor worked surprisingly well on a rangefinder for an FRC bot. Sort of late on this, but I figured it was worth mentioning.