iphone 陀螺仪 测试软件,iPhone-如何查找陀螺仪和加速度计的行进距离?
我对此表示怀疑并放弃了(晚上晚了,似乎什么都没得到)。 这用于Unity3d项目。
如果有人想在我离开的地方接机,我将很乐于详细介绍所有这些东西。
基本上在发现某些误报之后,我想我会尝试使用低通滤波器对其进行过滤,然后尝试通过查找趋势来消除反弹,然后(acc_x [i-1] + acc_x [i] )/ 2。
看来误报仍然来自倾斜,我尝试将其消除。
如果此代码有用或将您引向某个地方,请告诉我!
using UnityEngine;
using System.Collections.Generic;
///
/// rbi.noli@gmail.com
///
public class AccelerometerInput : MonoBehaviour
{
Transform myTransform;
Gyroscope gyro;
GyroCam gyroCam;
void Awake()
{
gyroCam= FindObjectOfType ();
myTransform = transform;
if (SystemInfo.supportsGyroscope) {
gyro = Input.gyro;
gyro.enabled = true;
}
}
bool shouldBeInitialized = false;
void Update ()
{
transform.Translate (GetAccelerometer ());// * Time.deltaTime * speed);
//GetComponent ().AddForce (GetAccelerometer ());
}
public float speed = 10.0F;
public Vector3 dir;
public float f;
Vector3 GetAccelerometer()
{
dir = Input.acceleration;
dir.x *= gyro.attitude.x;
dir.z *= gyro.attitude.z;
if (Mathf.Abs (dir.x) < .001f)
dir.x = 0;
dir.y = 0;
if (Mathf.Abs (dir.z) < .001f)
dir.z = 0;
RecordPointsForFilter (dir);
//print ("Direction : " + dir.ToString("F7"));
return TestPointsForVelocity();
}
Vector3[] points = new Vector3[20];
int index;
void RecordPointsForFilter(Vector3 recentPoint)
{
if (index >= 20)
index = 0;
points [index] = EvaluateTrend (recentPoint);;
index++;
}
//try to remove bounces
float xTrend = 0;
float zTrend = 0;
float lastTrendyX = 0;
float lastTrendyZ = 0;
Vector3 EvaluateTrend(Vector3 recentPoint)
{
//if the last few points were positive, and this point is negative, don't pass it along
//accumulate points into a trend
if (recentPoint.x > 0)
xTrend += .01f;
else
xTrend -= .1f;
if (recentPoint.z > 0)
zTrend += .1f;
else
zTrend -= .1f;
//if point matches trend, keep it
if (xTrend > 0) {
if (recentPoint.x > 0)
lastTrendyX = recentPoint.x;
} else // xTrend < 0
if (recentPoint.x < 0)
lastTrendyX = recentPoint.x;
if (zTrend > 0) {
if (recentPoint.z > 0)
lastTrendyZ = recentPoint.z;
} else // xTrend < 0
if (recentPoint.z < 0)
lastTrendyZ = recentPoint.z;
return new Vector3( lastTrendyX, 0, lastTrendyZ);
}
Vector3 TestPointsForVelocity()
{
float x = 0;
float z = 0;
float xAcc = 0;
float zAcc = 0;
int successfulHits = 0;
for(int i = 0; i < points.Length; i++)
{
if(points[i]!=null)
{
successfulHits ++;
xAcc += points[i].x;
zAcc += points[i].z;
}
}
x = xAcc / successfulHits;
z = zAcc / successfulHits;
return new Vector3 (x, 0, z);
}
}
iphone 陀螺仪 测试软件,iPhone-如何查找陀螺仪和加速度计的行进距离?相关推荐
- 车rc陀螺仪测试软件,利用加速度计和陀螺仪测量车辆运动
0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; FONT: 14px/25px 宋体, arial; WHITE-SPACE: normal; ORPHANS: ...
- iphone功率测试软件,iPhone充电功率检测方法
前言 自从iPhone8以后机型已经全部支持无线充电功能,但目前为止无线充电并不支持快充,需要快速充电还需要使用线缆才可以完成,虽然现有设备已经支持快速充电,也有很多小伙伴购买了苹果官方的快速充电器, ...
- iphone功率测试软件,iPhone原装5W充电头充电功率测试
原标题: iPhone原装5W充电头充电功率测试 首先我们测试iPhone原装5W的充电头,额定充电电压/电流为5V/1A,对五款Lightning to USB分别进行充电功率测试. 苹果原装Lig ...
- Iphone内存测试软件,教你免越狱一次性查出iPhone 6内存型号
之前有外媒报道的iPhone 6和6 Plus的 128GB高容量版本出现死机和循环重启的问题,那是因为这部分iPhone 6是使用较低成本.寿命较短 TLC NAND Flash 内存. TLC N ...
- 苹果x美版信号测试软件,iPhone X和iPhone XS的基带不同,信号就差别真这么大吗?还真的是有很大的区别!...
iPhone X和iPhone XS的基带不同,信号就差别真这么大吗?还真的是有很大的区别! 2020-11-27 15:48:34 13点赞 10收藏 13评论 创作立场声明:所写原创内容均为属实, ...
- Iphone内存测试软件,免越狱一次性查出iPhone6内存型号的方法
TLC NAND Flash 虽然较 MLC NAND Flash 成本低上不少,但它有着寿命较短.存取数据速度慢的缺点,变相令你手上的iPhone 6使用寿命变短了.那要怎样才能知道自己购买的iPh ...
- iphone 续航 测试 软件,历代iPhone续航能力测试:猜猜iPhone11排第几?
原标题:历代iPhone续航能力测试:猜猜iPhone11排第几? 关注下图公众号,鉴定苹果手机真假↓↓↓ iPhone系列手机的电池续航能力一直被外界诟病,iPhone的电池续航能力非常弱,也曾经变 ...
- 苹果7闪存速度测试软件,iPhone 6 Plus闪存检测教程
前些天,大容量的iPhone 6 和 iPhone 6 Plus 闪存爆出故障,有众多用户反映称 64和128GB的iPhone 6和iPhone 6 Plus如果安装太多的App之后会导致手机频繁死 ...
- 苹果8屏幕测试软件,iPhone 8 Plus防摔测试:屏幕很硬 背面较弱
2017-9-23 15:01 [天极网手机频道]iPhone 8和iPhone 8 Plus在外观上和上一代iPhone 7系列的最大不同之处在于其背面采用了玻璃材质.很多人就开始焦虑了,以前只是担 ...
最新文章
- 刷爆技术圈的《知识图谱》终于补货了,最后 968 份,低至 2 折,抢完不补!...
- 基于STC8G8K64U三通道高速ADC采集板
- php redis hsetnx,Redis Hsetnx 命令
- 基于Java语言构建区块链(五)—— 地址(钱包)
- win7映射linux硬盘_win7下安装Linux实现双系统全攻略
- zendguard php5.4,ZendGuardLoader6.0.0支持PHP5.4.x系列
- HDU1284——钱币兑换问题【dp】
- uboot环境变量及常用命令
- thinkjs——空对象判断
- 上线不到两年 腾讯“小鹅拼拼”被曝即将关停
- leelen可视对讲怎么接线_对讲门铃怎么安装
- JavaScript可变参数个数
- linux内存源码分析 - 伙伴系统(释放页框)
- 小乌龟Git工具使用
- 美瞳微商如何引流?微商卖美瞳怎么宣传?美瞳微商如何引流人脉
- Oracle JDK究竟从哪个版本开始收费?
- php中怎样添加文字水印,php给图片添加文字水印
- 关于飞思卡尔MSCAN滤波器的理解
- PPT图片别再直接插入,这样处理一下,让你的PPT秒变高逼格
- 产品经理那些事:产品经理成长的有利因素