cancel
Showing results for 
Search instead for 
Did you mean: 

Indoor location GPS tracking using LSM6DSR sensor

burak_Guzeller
Associate II

Greetings to everyone, I would like to ask you for help. I want to track GPS in a closed position. I get latitude and longitude information from GPS in an open area. In a closed position, I want to get location information with the accelerometer and speedometer. When the object is going straight, the data coming from the sensor is very healthy. I can't get accurate results from time to time, so I'm sending you a part of the code. Does this make sense? I also examined the documentation of the sensor, but I couldn't get much results. Thank you in advance.

 

 
kordinat_t farkLocation(offlineParam_t *param){
 
lastLocation_t sürer;
nowLocat_t nowLocations;
    statik uint32_t saniyeTimeSquared = 0;
    kordinat_t startKordinat = {40.922305,29.317727};
    kordinat_t lastKordinat;
   statik kordinat_t yeniKonum;
 
static uint32_t saniyeTime=0;
 
 
saniyeTime=zamansayacı/SECONDS_PER_MINUTE;
 
 
saniyeTimeSquared = saniyeTime *saniyeTime;
 
 
nowLocations.nowX = 0.5 * param->acceleration_mg[0] * (saniyeTimeSquared )/EARTH_RADIUS_DIVISOR; //100 e bolmetre için
nowLocations.nowY = 0.5 * param->acceleration_mg[1] * (saniyeTimeSquared )/EARTH_RADIUS_DIVISOR;
nowLocations.nowZ = 0.5 * param->acceleration_mg[2] * (saniyeTimeSquared )/EARTH_RADIUS_DIVISOR;
 
lasts.lastX=nowLocations.nowX;
lasts.lastY=nowLocations.nowY;
lasts.lastZ=nowLocations.nowZ;
 
 
 
 
    // Radyanların açık hesabıyla
    double enlemRadyan = startKordinat.enlem * M_PI / 180.0;
    double boylamRadyan = startKordinat.boylam * M_PI / 180.0;
    double yonAcisiRadyan = atan2(sensorParam.data_raw_angular_rate[1], sensörParam.data_raw_angular_rate[0]);
 
    // Hedef noktanın enlemi
    double yeniEnlemRadyan = asin(sin(enlemRadyan) * cos(lasts.lastX / EARTH_RADIUS) +
                                   cos(enlemRadyan) * sin(lasts.lastX / EARTH_RADIUS) * cos(yonAcisiRadyan));
 
    // Hedef noktanın boylamı
    double yeniBoylamRadyan = boylamRadyan + atan2(sin(yonAcisiRadyan) * sin(lasts.lastY / EARTH_RADIUS) * cos(enlemRadyan),
                                                    cos(lasts.lastY / EARTH_RADIUS) - sin(enlemRadyan) * sin(yeniEnlemRadyan));
 
    // Radyanının değerlerinin değerini çevir
    lastKordinat.enlem = yeniEnlemRadyan * 180.0 / M_PI;
    lastKordinat.boylam = yeniBoylamRadyan * 180.0 / M_PI;
 
    yeniKonum = sonKordinat;
 
       yeniKonuma dön;
 
 }
@
4 REPLIES 4
TDK
Guru

The readings from accelerometers and gyros are not perfect. Even infinitesimally small errors in these values, which all sensors have, will cause enormous errors at the position level over relatively short amounts of time. If you only need 1-2 second of data, you might be able to do something like this, but at 10+ seconds the shortcomings will start to show, especially if the movement is dynamic.

There are devices which can do this accurately, but they are enormous in both size and expense due to the accuracy required.

https://en.wikipedia.org/wiki/Inertial_measurement_unit

 

If you feel a post has answered your question, please click "Accept as Solution".

Generally you'd also want to get some kind of sensor fusion externally with GPS/GNSS you can carry over into the building. Where you characterize the offset and drift of the 6 or 9-DOF sensor.

There's also schemes using BT 5.1 anchor/beacons, and angle-of-arrival / direction-finding receivers/sensors that would allow you to map indoor spaces.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

First of all, thank you for your answer. As far as I understand, I should make my evaluations and transactions with the 10-second intervals you mentioned and I would also like to point out that I was going to use it for vehicle tracking in the closed position, so the movement is dynamic, yes. By the way, if you examine the codes, is the perspective approach correct? I got the algorithm form from this site https://stackoverflow.com/questions/19727298/my-algorithm-to-calculate-position-of-smartphone-gps-and-sensors/19764828# 19764828 I bought it from this site. Have I made a mistake or is there something different for the LSM6DSR sensor? Could you please let me know?

 

 

Federica Bossi
ST Employee

Hi @burak_Guzeller ,

You can use this code for your application but note that if you need help e can't support you because it is not developed by ST. We do not have a dedicated library.

 

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.