maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   General (https://talk.maemo.org/forumdisplay.php?f=7)
-   -   [SCRIPT] Using the N900 as Sonar (https://talk.maemo.org/showthread.php?t=93435)

Encypruon 2014-07-11 13:03

[SCRIPT] Using the N900 as Sonar
 
Hey all,

I hope this is the right place to post this :) I've somehow managed to make my N900 detect movements (and their distances) by checking how the echo of a sound is altered with a Python script that's rather dirty than quick. The way It's recording and playing audio is more a hack than a proper solution, but for some reason it's working. It requires python-numpy and alsa-utils to be installed.

EDIT: It seems like Python is not always taking care of the two subprocesses this script is spawning. The right solution might be wrapping the whole thing in a try-catch-block and cleaning up yourself. I prefer the lazy solution: Starting it with "python echo.py; killall arecord; killall aplay;" If the subprocess module doesn't do it's job properly, killall can take care of it :D

EDIT2: As Vento suggested, I've added "Script" to the title.

Please tell me if there's a way to embed the video that I've missed. Just in case :)

Demo Video
The script on pastebin

nokiabot 2014-07-11 13:10

Re: Using the N900 as Sonar
 
omg !

{10 characters}

endsormeans 2014-07-11 13:11

Re: Using the N900 as Sonar
 
Hahaha
Too frickin'-freakishly-coollio-weird man!
Welcome to the new-guy!
And you bring presents to the party!
A new toy!

Gotta come up with a cool name for it though...
sonar for n900 ...makes me think the n900 needs to be waterproofed for submersible diving. :D

Hmm...how's this for a name..."The Unsneakable App".."UnSneak-A-App"...or "Kato"

.thinkin 'bout the vid there...with you waving your hand behind it and all...tryin to sneak up on it so-to-speak :D...
reminded me of Kato from the pink panther movies always trying to surprise attack Inspector Clouseau.

Hmm...what is the distance on the sucker? How far?
Can it be tweaked to say...cancel out your movements (very tricky that I would imagine) so you wouldn't get your own feedback ?...so to speak.

On a more humourous note...
Can it detect movement say...in another room?
Could it warn me to get under my mistresses bed before her husband comes in the door? :D

Better...could it warn me of a planet- invading alien's heavy-breathing while I hide in the closet? At least I'd die then with major points for dying and going out in better than Hollywood sci-fi movie style. :D

Hmmm very-way cool ....
hmmm... the applications...

Y'know ....it just reiterates yet again...
maemo ain't dead...
the n900 isn't anymore irrelevant than it was when it 1st came out...
Not to mention the frickin' way-cool factor of our devices and of the mad innovations of this community...
stuff stupidphones and their communities just don't have...

The "Other Guys" should be taking notes...want crazy-fast and wild innovations? Open their platforms up for the public to play with them...best and cheapest corporate method of r+d is to let everyone else pool their brain-pans and do it for them. You'd think they would have figured out that cost saving method by now.

Hats off to you man....that is...by far one of the most interesting and bizarre innovations...now how to integrate it with some ideas I got....

ndhikaa 2014-07-11 14:21

Re: Using the N900 as Sonar
 
i gotta say thanks!

gianko 2014-07-11 16:22

Re: Using the N900 as Sonar
 
Amazing stuff!

nokiabot 2014-07-11 18:05

Re: Using the N900 as Sonar
 
well how a simple game or a fun app be put up with this as the input ? think of a ball to put in a hole without touching any sides of the screen or jush make it jump insanley :D a plugin for the photos app that can zoom in or a plugin for omp to forward rewind or play with the volume or any crazy idea that can be implemented:)

endsormeans 2014-07-11 18:15

Re: Using the N900 as Sonar
 
mahgawd nokiabot...yeah..man...hell....just the tip of the iceberg ....of stuff that could be implemented with this...

hmm...kinda like the xbox kinect interface...that monitors visual input and implements a response in the running prog or game.
Better I think...this is crazy sensitive...and unlike the kinect...it isn't limited to direct line of camera sight...you could run an prog/ game/ music... whatever... with the n900 sitting on your desk/ nightstand/ bookshelf...possibly across the room ....BEHIND you..... for all it matters :D

hmmm...OP'er can you give a rough guesstimate as to the distance the sonar receives before the signal becomes ...umm..deterioratingly inadequate (for measurements to be applied to possible applications) ?

Roughly.... how many feet from device before sonar signal degeneration?

Oh my...oh yes....I most definitely could see direct applications

OP.....more possible applications are thrown around...the more I'm super-duper impressed

nokiabot 2014-07-11 18:47

Re: Using the N900 as Sonar
 
humm it feels like it can detect movements two way it cannot sense direction lol :D but as the op says its quick and dirty it seems it can be taliored a bit to cerate some fun things or better a script or a app that can be used to intregate whatever one wants like we use shortcutd or camera half press to map any function:)

Vento 2014-07-11 19:49

Re: Using the N900 as Sonar
 
http://www.indianfunpic.com/wp-conte...an-a-Medal.jpg

Btw, it will be nice an little UI app to know the distance of the nearest moving object. No fancy button or strange things... just a number in center of the screen. Okay maybe some settings would be useful like sample numbers... I'm thinking about a simple menu that popup when you press the number.

Estel 2014-07-11 20:33

Re: Using the N900 as Sonar
 
Interesting, gotta check the accuracy. I wonder if it would more effectively underwater, for obvious reasons (after altering calculations, of course)? No pun, I mean waterproof bag and underwater-tailored receiver/emitter part connected to headphone socket.

Could become a cool part of RC submarine model, too ;)

/Estel

Vento 2014-07-12 06:59

Re: Using the N900 as Sonar
 
Little suggestion. Maybe you should change the title... Add [SCRIPT],[POC], [ANNUNCE] or [WIP] before the name

Estel 2014-07-12 10:23

Re: Using the N900 as Sonar
 
Announce is good idea. Otherwise, most people may think it's some...one asking, if his N900 can act as a sonar. Which may result in whole array of reactions - moving along without reading is just one of them ;)

SHARP66 2014-07-13 01:10

Re: [SCRIPT] Using the N900 as Sonar
 
I think It can detect direction to, if you alter the sound in channels.

taixzo 2014-07-13 03:41

Re: [SCRIPT] Using the N900 as Sonar
 
Quote:

Originally Posted by SHARP66 (Post 1432581)
I think It can detect direction to, if you alter the sound in channels.

So, like the way our ears work, but in reverse? (two sounds/one microphone rather than two microphones/one sound)

Velian 2014-07-13 19:01

Re: [SCRIPT] Using the N900 as Sonar
 
It would be a great idea to take some developer eh did this idea of ​​a real theremin n900

lexik 2014-07-13 22:31

Re: [SCRIPT] Using the N900 as Sonar
 
Quote:

Originally Posted by Velian (Post 1432635)
It would be a great idea to take some developer eh did this idea of ​​a real theremin n900

You need two 'lines' for theremin, maybe proximity sensor near front cam could be the second one? (pretty crazy)

rotoflex 2014-07-14 06:25

Re: [SCRIPT] Using the N900 as Sonar
 
If it's emitting clicks for sonar, they might not be very musical for a theremin.

A theremin could be fun, though.

Maybe you could use the front camera to calculate distance by the monocular depth cue apparent size of a hand: smaller as it's farther away, larger as it's closer, and whether it's at nearer the left, right, top or bottom.

peterleinchen 2014-07-14 07:21

Re: [SCRIPT] Using the N900 as Sonar
 
Quote:

Originally Posted by rotoflex (Post 1432664)
If it's emitting clicks for sonar, ...

Do you mean this kind of clicks?
Then we possibly may achieve it via espeak?

sulu 2014-07-14 14:00

Re: Using the N900 as Sonar
 
Quote:

Originally Posted by Estel (Post 1432512)
Interesting, gotta check the accuracy. I wonder if it would more effectively underwater, for obvious reasons (after altering calculations, of course)?

As a rough estimate, the maximum range should increase by factor 9 due to the better sound propagation quality of water compared to air, but the accuracy will drop by about factor 4.3 due to the higher speed of sound (and therefore smaller delay).

The details depend on signal frequency as well as medium temperature and pressure.
I assumed something in the range of 1-2kHz, 25°C and sea level.

chill 2014-07-17 22:23

Re: [SCRIPT] Using the N900 as Sonar
 
Could range and/or accuracy be increased by attaching more powerful speakers and/or a better microphone?

One could detect movement in another room that way, too (which would certainly be a range increase) ;).

SHARP66 2014-07-18 00:41

Re: [SCRIPT] Using the N900 as Sonar
 
Quote:

Originally Posted by chill (Post 1433194)
Could range and/or accuracy be increased by attaching more powerful speakers and/or a better microphone?

One could detect movement in another room that way, too (which would certainly be a range increase) ;).

maybe placing a radio in the next room and using the FM transmiter with this script or without.

sulu 2014-07-18 07:25

Re: [SCRIPT] Using the N900 as Sonar
 
Quote:

Originally Posted by chill (Post 1433194)
Could range and/or accuracy be increased by attaching more powerful speakers and/or a better microphone?

Increasing range by attaching louder speakers and/or a more sensitive microphone could be reached.
For accuracy it's much harder. The key would be to measure signal delays more precisely.

Quote:

Originally Posted by chill (Post 1433194)
One could detect movement in another room that way, too (which would certainly be a range increase) ;).

That's at least doubtful. Assuming your makeshift sonar is able to manage the range, there's still the problem of obstacles like walls, door frames, furniture and so on which will cause multipath effects (i.e. signals might be reflected indirectly, causing you to measure a too long distance). The higher the distance, the worse it gets.
For a precise sonar you need a highly focused speaker and a highly focused microphone. Otherwise your sonar would be more or less omnidirectional and you won't be able to figure out where a signal came from.

biketool 2014-07-18 08:04

Re: [SCRIPT] Using the N900 as Sonar
 
Not sure how granular and real time the digitized sound is but it would be entirely possible to connect a ausio port, USB, or Bluetooth sound card or device for DIY sonar applications, acutally this would also work by converting the audio to RF for radar. For example a sonar transducer and receiver can be found for the small fish and depth finder devices for boats. It may require up and down conversion between our typical audio devices to the higher frequencies needed for good penetration and resolution but that is also pretty easy to do.
The question them becomes is the bandwidth provided by audio devices internal or connected sufficient to do something useful with the N900.
Going way off topic but there is no reason the audio output of one of those toy Doppler radar guns couldn't be put through bluetooth and the RF in/output run on a vertical polarized antenna with on a regulated stepper rotator reflector to make a short range real sweep scope readout radar on the N900. If only I had a real use of a small radar set.

pichlo 2014-07-18 10:18

Re: [SCRIPT] Using the N900 as Sonar
 
Quote:

Originally Posted by sulu (Post 1433228)
Quote:

Originally Posted by chill (Post 1433194)
One could detect movement in another room that way, too (which would certainly be a range increase) ;).

That's at least doubtful.

I may be wrong but I think he meant placing both the speaker and the microphone in another room :)

Quote:

Originally Posted by SHARP66 (Post 1433206)
maybe placing a radio in the next room and using the FM transmiter with this script or without.

That is an interesting idea. May require some calibrating. If nothing else, then at least the measured distance would need to be doubled since the sound would travel only half the distance (i.e. not there and back).

Actually, the whole thing may require some calibrating one way or another. I would love to see this made into a nice GUI app with calibrating options etc.

biketool 2014-07-18 10:55

Re: [SCRIPT] Using the N900 as Sonar
 
In an acoustically absorptive environment like an audio recording studio with one or two hard metal or stone targets would do the trick to calibrate the sonar. An audio frequency upconverter gets you into the more useful hundreds of megahertz or even GHz frequencies, up there the resolution is higher due to the wavelength being smaller to detect small objects and doppler shift is much greater then down convert back to something common sound equipment can use.

chill 2014-07-18 18:39

Re: [SCRIPT] Using the N900 as Sonar
 
Quote:

Originally Posted by pichlo (Post 1433245)
I may be wrong but I think he meant placing both the speaker and the microphone in another room :)

Yes. :-) The increased "range" here is still the distance from the detectable object to the N900, it's just that objects very near the N900 would not be detected. One possible application is a home alarm system.

nokiabot 2014-07-18 20:26

Re: [SCRIPT] Using the N900 as Sonar
 
Why people are getting crazy ?? It wont be of much practical use aside from some fun and utlity apps games ?
currently we dont even have a app/game that uses the script as input

pichlo 2014-07-18 22:32

Re: [SCRIPT] Using the N900 as Sonar
 
Quote:

Originally Posted by nokiabot (Post 1433305)
Why people are getting crazy ??

I wouldn't use the word "crazy". "Carried away" seems more appropriate. I do not find it surprising at all, the possibilities are virtually endless.

Quote:

Originally Posted by chill (Post 1433294)
One possible application is a home alarm system.

That, however, may not be as practical as it sounds, at least not without some external modifications. An ideal alarm system should be inaudible to both the normal inhabitants and the intruder. Although hearing regular pings might work as a deterrent, but then it does not even need to work as a detector :)

sulu 2014-07-23 08:54

Re: [SCRIPT] Using the N900 as Sonar
 
Quote:

Originally Posted by pichlo (Post 1433324)
An ideal alarm system should be inaudible to both the normal inhabitants and the intruder. Although hearing regular pings might work as a deterrent, but then it does not even need to work as a detector :)

You'd simply have to shift the pings to inaudible frequencies.
I don't know if infrasound is manageable with consumer electronics (it's definitely not healthy for the N900's speakers), but ultrasound is certainly possible.
Most people aren't able to hear anything beyond 16kHz and from 21kHz you should be on the safe side.
As a teenager I was able to hear frequencies between 18 and 19kHz and I could make my regular PC speaker emit these frequencies via a simple turbo pascal program.

So it should be possible to build a secret alarm system based on this sonar script - unless there's a dog nearby going crazy due to the ultrasound pings. ;)

pichlo 2014-07-23 09:19

Re: [SCRIPT] Using the N900 as Sonar
 
Quote:

Originally Posted by sulu (Post 1433689)
You'd simply have to shift the pings to inaudible frequencies.

Assuming the entire N900's audio chain (D/A, amplifiers, speakers...) can handle it, which I doubt. Hence "external modifications". Not to mention that the script as it is emits 16 kHz, but in a way that one can hear the low frequency "clicks" as it turns on and off. That will also require some modifications.

BTW, what happened to the OP? He turned up out of nowhere, posted one extremely useful script and disappeared without a trace.

disappear 2014-09-03 12:54

Re: [SCRIPT] Using the N900 as Sonar
 
Hi to all,I try use this script,so what i did?
Install python-numpy and alsa-utils(that package i already have) and python2.7,also i created emty file with leafpad(also i try to created file using windows but result it was the same)and rename him echo.py,then copy sonar script from pastebin and paste in echo.py
but when type python2.7 echo.py the output from console is:
Quote:

~ $ python2.7 echo.py
Traceback (most recent call last):
File "echo.py", line 9, in <module>
import numpy as npy
File "/opt/python27/local/lib/python2.7/dist-packages/numpy/__init__.py", line 132, in <module>
import add_newdocs
File "/opt/python27/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 9, in <module>
from lib import add_newdoc
File "/opt/python27/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/opt/python27/local/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/opt/python27/local/lib/python2.7/dist-packages/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError: No module named multiarray
I made quick search and found this http://askubuntu.com/questions/23090...med-multiarray
although than,i follow advice from above link,that mistake show me again,anyone from you has experience with this script

regards
edit:finally i manage to run this script(after several time i created and deleted folder numpy and the end i left that folder in /usr/local/lib/python2.7/site-packages/)
but for big regret my sonar on n900,won't detected any movement
but this time i type python echo.py
what the F*******

rcolistete 2014-09-05 20:14

Re: [SCRIPT] Using the N900 as Sonar
 
Use default Python (2.5). NumPy in Maemo-Extras is compiled for Python 2.5, AFAIK.


All times are GMT. The time now is 09:08.

vBulletin® Version 3.8.8