极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 14535|回复: 1

MPU6050人体姿势跌倒报警(O急救!急救)

[复制链接]
发表于 2016-10-22 19:55:44 | 显示全部楼层 |阅读模式
利用MPU6050,我现在已经可以得到pitch roll yaw三个方向的加速度,以及旋转角。通过模拟演示也总结出来了当人体跌倒时的条件.
人体跌倒的条件:
1.通过合加速度,可以判断是否发生剧烈撞击,发生剧烈撞击可能是疑似跌倒(一次判断)
2.通过条件1后采集3秒的角度数据判断旋转角是否发生较大的变化,以此判定是否跌倒。
但是算法不知道怎么写?各位大神急救啊 !!!!!!!!



这是现在的代码:
unsigned char Re_buf[11],counter=0;
unsigned char sign=0;
float a[3],w[3],angle[3],T;
void setup() {
  Serial.begin(115200);
}

void loop() {
  if(sign)
  {  
     sign=0;
     if(Re_buf[0]==0x55)      //检查帧头
     {  
        switch(Re_buf [1])
        {
        case 0x51:
                a[0] = (short(Re_buf [3]<<8| Re_buf [2]))/32768.0*16;
                a[1] = (short(Re_buf [5]<<8| Re_buf [4]))/32768.0*16;
                a[2] = (short(Re_buf [7]<<8| Re_buf [6]))/32768.0*16;
                T = (short(Re_buf [9]<<8| Re_buf [8]))/340.0+36.25;
                break;
        case 0x52:
                w[0] = (short(Re_buf [3]<<8| Re_buf [2]))/32768.0*2000;
                w[1] = (short(Re_buf [5]<<8| Re_buf [4]))/32768.0*2000;
                w[2] = (short(Re_buf [7]<<8| Re_buf [6]))/32768.0*2000;
                T = (short(Re_buf [9]<<8| Re_buf [8]))/340.0+36.25;
                break;
        case 0x53:
                angle[0] = (short(Re_buf [3]<<8| Re_buf [2]))/32768.0*180;
                angle[1] = (short(Re_buf [5]<<8| Re_buf [4]))/32768.0*180;
                angle[2] = (short(Re_buf [7]<<8| Re_buf [6]))/32768.0*180;
                T = (short(Re_buf [9]<<8| Re_buf [8]))/340.0+36.25;
                Serial.print("a:");
                Serial.print(a[0]);Serial.print(" ");
                Serial.print(a[1]);Serial.print(" ");
                Serial.print(a[2]);Serial.print(" ");
                Serial.print("w:");
                Serial.print(w[0]);Serial.print(" ");
                Serial.print(w[1]);Serial.print(" ");
                Serial.print(a[2]);Serial.print(" ");
                Serial.print("angle:");
                Serial.print(angle[0]);Serial.print(" ");
                Serial.print(angle[1]);Serial.print(" ");
                Serial.print(angle[2]);Serial.print(" ");
                Serial.print("T:");
                Serial.println(T);
                break;
        }
    }
  }
}

void serialEvent() {
  while (Serial.available()) {
    Re_buf[counter]=(unsigned char)Serial.read();
    if(counter==0&&Re_buf[0]!=0x55) return;      //第0号数据不是帧头              
    counter++;      
    if(counter==11)             //接收到11个数据
    {   
       counter=0;               //重新赋值,准备下一帧数据的接收
       sign=1;
    }
  }
}



包括串口截图

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2016-11-23 15:28:12 | 显示全部楼层
我觉得你上面直接那样计算旋转角是不准确的
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-20 07:37 , Processed in 0.045507 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表