我正在开发一个Android应用程序来根据传感器的数据计算位置
加速度计 - >计算线性加速度
磁力计+加速度计 - >运动方向
初始位置将取自GPS(纬度+经度)。
现在根据传感器的读数,我需要计算智能手机的新位置:
我的算法遵循 - (但不计算准确位置):请帮我改进它。
注意: 我的算法代码在C#中(我将传感器数据发送到服务器 - 数据存储在数据库中。我正在计算服务器上的位置)
所有DateTime对象都是使用TimeStamps计算的 - 从01-01-1970
var prevLocation = ServerHandler.getLatestPosition(IMEI);
var newLocation = new ReceivedDataDTO()
{
LocationDataDto = new LocationDataDTO(),
UsersDto = new UsersDTO(),
DeviceDto = new DeviceDTO(),
SensorDataDto = new SensorDataDTO()
};
//First Reading
if (prevLocation.Latitude == null)
{
//Save GPS Readings
newLocation.LocationDataDto.DeviceId = ServerHandler.GetDeviceIdByIMEI(IMEI);
newLocation.LocationDataDto.Latitude = Latitude;
newLocation.LocationDataDto.Longitude = Longitude;
newLocation.LocationDataDto.Acceleration = float.Parse(currentAcceleration);
newLocation.LocationDataDto.Direction = float.Parse(currentDirection);
newLocation.LocationDataDto.Speed = (float) 0.0;
newLocation.LocationDataDto.ReadingDateTime = date;
newLocation.DeviceDto.IMEI = IMEI;
// saving to database
ServerHandler.SaveReceivedData(newLocation);
return;
}
//If Previous Position not NULL --> Calculate New Position
**//Algorithm Starts HERE**
var oldLatitude = Double.Parse(prevLocation.Latitude);
var oldLongitude = Double.Parse(prevLocation.Longitude);
var direction = Double.Parse(currentDirection);
Double initialVelocity = prevLocation.Speed;
//Get Current Time to calculate time Travelling - In seconds
var secondsTravelling = date - tripStartTime;
var t = secondsTravelling.TotalSeconds;
这是我得到的结果 - >电话没有移动。你可以看到速度是27.3263111114502 所以计算速度有问题,但我不知道是什么
临摹微笑
相关分类