Friday, July 28, 2017

Is it possible to detect Android devices laying side by side

Leave a Comment

I am developing an Android application that requires devices to be laid side by side and/or above and below each other.

I know I can use the Nearby API to detect devices "Nearby" however I need something a little more "Finer Grained".

My app needs to be able to identify a device laying either on the left side, above, right side or below. While all devices are laying flat on a table (for instance).

I can find nothing on the web that describes this use case.

Is it possible?

UPDATE

My use case is that I want Android devices to be able to detect any number of "Other Devices" laying either to their left or right. The devices will be laid out horizontally with a "small" gap between each one.

In the same way that you might layout children's lettered blocks to spell out a word or phrase, or numbered blocks to make a sum.

not only should the line of devices be able to detect their immediate neighbours to their left and right the two devices at either end should be able to detect they they are the start and end (reading left to right) of the line.

7 Answers

Answers 1

Using proximity sensors is a likely way to solve your question. TYPE_PROXIMITY will gives the distance from a near by object. TYPE_MAGNETIC_FIELD gives the geomagnetic field strength on x/y/z.

For more read Position Sensors.

Answers 2

An idea, in case it's relevant for your use case:

  • Setup phase
    • start your app on each device in "pairing mode".
    • Each device will show a QR code containing the key required for communicating with the device (for example via Firebase), and screen details: size in pixels. It will also draw a rectangle at the screen boundaries.
    • A different phone, external to this layout will run your app as a "master", taking a picture of the phones from above.
    • Now you need to write an algorithm to identify the screens and their locations, orientation and extract the QR codes for analysis. Not easy, but doable.
  • Interaction phase
    • now all the phones (this should work on more than two phones) can collaborate screens to show parts of the same movie, for example.

Answers 3

  1. Making your own Mock GPS (Local PS to be exact). I don't have a link for this but its definitely possible. Check out how GPS works to get an idea. Wifi and Bluetooth are signals. but you know what else is a signal?

A: SOUND

make each phone make a large beep in turn and measure audio strength using receivers. This might work better than wifi/bluetooth. once you measure relative distances between every pair of phones, it only takes a good algorithm to find relative positions

  1. A Possible Alternative Solution : use image processing. Get something like OpenCV for Android and setup one phone as a master. This will work only for a 2D Layout.

  2. Another "idea" - use the cameras. Stick A board on top of your surface with 4 QR codes in each corner. (This will help identify the edges and orientation of your phone). If you're looking for a 3D layout and the phones have sufficient in-between space, you could stick a QR behind every phone and show a QR on the screen of every phone.

All of these are solutions. Maybe you can use individual ones. Maybe you can use a combination. who knows.

Answers 4

Seems not, if You have only 2 devices, but if You have external sources (with known position) of any signal (audio, vibrate, BT or WiFi radio, etc.), which can be detected by devices with adequate accuracy, and devices time is synchronized, You can do this comparing time of signal start (or signal strength) on both devices like on this picture:

Example

Or, if You can add some sensors to one of devices, You can create "other device locator", for example like this sound locator.

UPDATE

In a updated formulation, the issue is also not solvable: it's possible to determine which two devices are at the edge, but you can not determine which one is on the left and which is on the right side. It is necessary that at least one device knows that it, for example, is leftmost - then other devices, for example, generates a sound, the others receive it and determine their order according to the difference in arrival time. But the anchor point and synchronization of time are necessary.

Answers 5

By understating your use case, it is possible to find number of devices surrounded by host device, using Nearby Api, other techniques. But find how many devices each side!!! I don't think it is possible with the current mobile hardware and technology. Because, by considering all factors, magnetic sensors are only the least possible solution. But the current mobiles have no such capability.

The following point I made based on above answers. TYPE_ACCELEROMETER, TYPE_LINEAR_ACCELERATION, TYPE_MAGNETIC_FIELD, TYPE_ORIENTATION these sensors are react to the magnetic field around the device (compass react to the magnet). You can try an app using TYPE_MAGNETIC_FIELD, test how it will react to other device when close to it (I think it will react).

But the point I am trying to make here is, if you put three devices to once side and 4 devices to other side, the MAGNETIC_FIELD sensor reads relative magnetic field. So we can't identify how may devices each side, Until unless you have made some scientific calculations.

The second point is, some one suggested TYPE_PROXIMITY sensor, but it is not meant to serve this purpose. Current mobiles, measures the proximity of an object in cm relative to the view screen of a device. This sensor is typically used to determine whether a handset is being held up to a person's ear.

Another least possibility is using location sensor, it can identify the coordinates relative to your device coordinates, you communicate between each device coordinates with host using NFC. But the problem is, your use case says those devices are very close to each other, so it is not measurable distance using location service.

To conclude, it is not possible to identify number of each devices each side of a host device, with the current mobile hardware. It will can archived by using external sensor that will extends the mobile capability. For example, a phone case that equipped with such a capability, this will open window to other use-cases and application as well.

Answers 6

I think a way but it may require a a bit work. First check if 2 devices are laying by getting device orientation and using accelerometer or rotation vector to check pitch, roll, etc.

When you are sure that they are laying send data from one device from one to another using BT or wifi. Data should include send time. Check retreive time on other device also you should check for latency for sending and retreiving data. If you can have a noticible time differences in ms for small distance differences between devices it would be easy to check how approximately close they are. Also you may ask users to hold their device 1 meter or fixed distance from each other to get a time of travel for BT or wifi signal you send to other.

Answers 7

If you could choose an 'object of reference', perhaps you can solve this. Since left, right, top and bottom are relative, devices should be aware of something that is locally stationary. The devices will try to locate this 'object of reference' and once they know where they are with respect to the latter, they could share this data with each other to figure out their orientation with each other. Just like GPS tries to find a satellite, and then figures out its location, in the same manner, if a device tries to find itself with respect to a locally stationary object(by the means of image processing for example), your use case could be achieved.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment