neXenio / BLE-Indoor-Positioning

Multilateration using bluetooth beacons
Apache License 2.0
430 stars 129 forks source link

Floor plan is not visible #172

Closed jasirjasir closed 4 years ago

jasirjasir commented 4 years ago

Floor plan is not visible in the map fragment UI . I have updated my floor plan in this line Bitmap backgroundImage = BitmapFactory.decodeResource(getResources(), R.drawable.room100_241, options); What could be the reason? Also How to set two reference point and location ?

Steppschuh commented 4 years ago

To get the reference points, refer to our wiki. Also check out #152

MEnnabah commented 2 years ago

Thank you @Steppschuh for the wiki ref and other issues as well regarding the reference point (and for the entire project obv 🙂)

We changed the map image into a custom one, and now trying to show the map in the correct position on the screen. I tried to play around with random values of the ref points, but as you can guess, the map zooming isn't accurate.

Point firstReferencePoint = new Point(953, 1830);
Point secondReferencePoint = new Point(1926, 1830);

We also looked at the wiki page, but we're in doubt on how to convert the output Location to Point and use it as a ref point. In the wiki page, it says we need first to find a reference location (GPS Coordinates)..

// Step 1: Outdoor reference location
double measuredLatitude = 52.512292;
double measuredLongitude = 13.3909021;
Location outdoorReferenceLocation = new Location(measuredLatitude, measuredLongitude);

.. and then, it generates a beacon location given an angle and a distance:

// Step 2: Indoor reference or beacon location
double distance = 13.435; // in meters
double angle = 353.84; // in degrees (0° is North)
Location indoorReferenceLocation = outdoorReferenceLocation.getShiftedLocation(distance, angle);

We still wonder how can we have Point objects as reference points. When we read the wiki page, we thought there would be a way to convert indoorReferenceLocation to Point object. Many thanks.

TLDR: How can we generate Point objects given a Location generated by getShiftedLocation(distance, angle)?

Steppschuh commented 2 years ago

Hey Mohammed, you're almost ready to go. Getting the Location is the tricky part. A Point is just the X and Y coordinate on your 2D map image that represents the beacon location that you measured the GPS coordinates for. So if you have a 2000 x 1500 pixel floor plan and you have a beacon right in the center that you measured the geo coordinates for, the reference point for that beacon would be Point(1000, 750).

MEnnabah commented 2 years ago

Hi @Steppschuh

Many thanks for your quick response!

We tried getting 2 reference locations and getting the points of those locations on the map, but we think there's something odd especially with the bearing of the map image.

I'll explain exactly what's happening. We have this as our map (It's a park walk with devices placed as a zig-zag left and right of the walk 🙂)

Park Map

Our first reference location is exactly at the center:

Location centerReferenceLocation = new Location(25.07408297077951, 55.14524025976267);
Point centerReferencePoint = new Point(733, 1577);

And our second reference location is exactly at the top left:

Location originReferenceLocation = new Location(25.073793982630438, 55.14454278293151);
Point originReferencePoint = new Point(0, 0);

This won't show the image at all (even with the devices detected and placed on the canvas). Then, we thought the canvas might have a different origin coordinate system, so we changed the second reference point to:

Point originReferencePoint = new Point(0, 3154); // full image height

but that only resulted in incorrect rotation and translation of the map on the canvas.

Park Map

Note: The devices should be placed along the grey walking area of the park. I'll stick the GPS coordinates of the devices below in case.

The last thing we tried is generating an exact square image map, where the coordinate system wouldn't matter for one of the points, but that also didn't help 😞

One part that caught my eyes was the top-left location to find the translation of the map, when I placed the coordinates on Google Maps, it showed incorrect location.

matrixTranslationPoint = getPointFromLocation(mapBackground.getTopLeftLocation());
BLE Devices Locations ```java switch (iBeacon.getMinor()) { case 1: { beaconLocation.setLatitude(25.074002); beaconLocation.setLongitude(55.145647); beaconLocation.setAltitude(1); break; } case 2: { beaconLocation.setLatitude(25.074087); beaconLocation.setLongitude(55.145544); beaconLocation.setAltitude(1); break; } case 3: { beaconLocation.setLatitude(25.074031); beaconLocation.setLongitude(55.145392); beaconLocation.setAltitude(1); break; } case 4: { beaconLocation.setLatitude(25.074108); beaconLocation.setLongitude(55.145358); beaconLocation.setAltitude(1); break; } case 5: { beaconLocation.setLatitude(25.074041); beaconLocation.setLongitude(55.145261); beaconLocation.setAltitude(1); break; } case 6: { beaconLocation.setLatitude(25.074138); beaconLocation.setLongitude(55.145086); beaconLocation.setAltitude(1); break; } case 7: { beaconLocation.setLatitude(25.074072); beaconLocation.setLongitude(55.145026); beaconLocation.setAltitude(1); break; } ```
Steppschuh commented 2 years ago

I too think that something is wrong with the bearing here. The beacons seem to be placed correctly with geographic north being towards the top. Keep in mind that this could simply be a bug in our implementation, I'm unaware of anyone trying to use a background image that is not aligned with north towards the top. Maybe you can try to use a rotated map image to check if that's causing the issue.

Unfortunately we currently don't have the time to work on this project, sorry that I can't provide more details on this...

MEnnabah commented 2 years ago

No problem! I think your comment is helpful. I'll try with the north towards the top image. Or try to take the bearing angle into consideration and submit a PR. Many thanks again for your help.