This blog's soundtrack comes from the sci-fi future of TMNT turtles in time. Cowabunga dudes.
So I need to get an idea off of my chest... and even though this one may be lengthy, the best way for me to do it is to teach it.
Lately, with all of my work on neural networks and stuffs, I've thought a lot about what I can do with it.
Of course, there's a lot, but of course, I'd pick a robot.
Robots are pretty complex, so for this post I'm going to focus on the math, mostly to get it out of the way so we get get to the fun stuff.
So get out your (insert smart people stuff here) and let's build a robot!
So what I want this robot to do is turn to face noisy objects (including your self/mouth/other), and look at them curiously.
Yea, that's it. But this is a lot more complicated then it seems...
When I implement neural networks into the system, it would hopefully be able to pick out what's making the sound out of a few objects. Maybe I'll include stereoscopic vision to help it out.
But I need to have a base to build all this onto, and the base will be a simple robot that turns in a two dimensional plane to face the direction that the loudest noise it can hear is coming from.
Simply put, the base of it will be an immobile head with ears that just turns.
So how do you find the direction that a sound is coming from? Let me ask that again, how do
you find the direction a sound is coming from?
It actually comes down to what's between your ears... a gap! (that's a no-brainer ha-hahahaaaaaagh...)
Sound only travels so fast, and because of the distance between your two ears, sound from an off-facing angle hits one of your ears before the other.
That amazing thing (that fills that gap between your ears) called your brain does the work of calculating the direction based on that little difference of time.
But how do we get a robot to know where a sound came from?
The only thing it will receive is sound in both ears, most likely with a short delay between the two ears. So we have a short difference in time, and the sound itself. To help keep things simple, we're going to only deal with the difference in time.
The time difference is greatest when the ears are furthest apart, meaning when they are perpendicular or at a 90 degree angle to the sound source. The difference would be essentially zero when they are are facing the direction of the sound.
Just to clarify, let's look at some directions really quick...
The direction of the ears in this case would be forward. If it helps, think of little arrows coming from your ears and pointing to whatever you're looking at (a little like
this guy). These arrows, or vectors, represent the direction of facing for your ears. Similarly, the sound can also be thought of as an vector.
So now that we have some directions established, here's a trick to get a feel for what's going on...
Let's take one of the ears off of the robot.
If you were to look at the robot from above and it were spinning in circles, you'd see the one ear creating a circle with its movement.
Then look at the 'face' of the robot, your eyes level with it's ears while it's still spinning.
You'll see the ear going back and forth in an oscillatory pattern. The ear would go to one side, then the other, and back and forth etc. This is a sinusoidal motion. Yea trig!
Now that we know it's sinusoidal, we can start building a mathematical model.
Information we know:
- The difference in time, we'll call it Dt
- Whether it's the left or the right ear that heard the sound first. Lets call it 'side', and set it to 1 for left, -1 for right
- The measured length between the ears, we'll just call it length
- The speed of sound (~340m/s), we'll use the standard c (also used for speed of light, but whatever)
Information we want:
- The angle, we'll call it theta
So with this information, we would get something that looks like this:
Dt*side = (length)*sin(theta)/c.
A little bit of algebra leads to:
arcsin(side*Dt*c/(length)) = theta
If you notice, this only gets us
an angle. But is it the angle we need? Lets go back and look at what we have/need again...
What we have is an angle that represents the angle between the sound vector and the current position vector of the ears. The important factor that we introduced was that of the side. This gives us the total angle that needs to be travelled and the direction to go.
So yes! This is the angle we want.
Note that this will not be able to differentiate between sounds that come from the front of the robot and sounds that come from the back. Your brain is able to recognize the difference based on a few factors, such as other sensory cues and reverberations of the sound in the environment, but let's just keep our model simple for now.
Now that all the boring stuff is out of the way, it's time for a terrible cliffhanger!! Oh no!!
...
That's all for this post!
Thanks for reading!
#robots #engineering #maker