搜索
bottom↓
回复: 5

请教各位大神关于MPU6050读取DMP加速度的问题。

[复制链接]

出0入0汤圆

发表于 2014-6-29 23:22:51 | 显示全部楼层 |阅读模式
最近学习MPU6050看到群里各位大神分享的DMP例子,感觉十分受用,可能是大家都做四轴飞行器的缘故大多都只做到了航向识别如下面的程序。如果需要读取角速度和加速度该如何处理数据呢,请问各位如何处理读取到的加速度呢?




  1.          short gyro[3], accel[3];
  2.             long quat[4];
  3.         dmp_read_fifo(gyro, accel, quat, &sensor_timestamp, &sensors,&more);
  4.          q0=quat[0] / q30;       
  5.         q1=quat[1] / q30;
  6.          q2=quat[2] / q30;
  7.          q3=quat[3] / q30;
  8.          Pitch  = asin(2 * q1 * q3 - 2 * q0* q2)* 57.3+180;       
  9.          Roll = atan2(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2* q2 + 1)* 57.3+180;
  10.          Yaw =         atan2(2*(q1*q2 + q0*q3),q0*q0+q1*q1-q2*q2-q3*q3) * 57.3+180;
复制代码

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入0汤圆

 楼主| 发表于 2014-6-30 00:03:03 | 显示全部楼层
麻烦大家了~

出0入0汤圆

 楼主| 发表于 2014-6-30 09:08:58 | 显示全部楼层
帖子不要沉呀`求各位大神帮忙。

出0入0汤圆

发表于 2014-6-30 13:11:53 | 显示全部楼层
看dmp_read_fifo函数的注释

出0入0汤圆

 楼主| 发表于 2014-6-30 13:44:06 | 显示全部楼层
qzrzq 发表于 2014-6-30 13:11
看dmp_read_fifo函数的注释

我这边没有啊~您那里有吗?

出0入0汤圆

发表于 2014-6-30 14:01:46 | 显示全部楼层
/**
*  @brief      Get one packet from the FIFO.
*  If @e sensors does not contain a particular sensor, disregard the data
*  returned to that pointer.
*  \n @e sensors can contain a combination of the following flags:
*  \n INV_X_GYRO, INV_Y_GYRO, INV_Z_GYRO
*  \n INV_XYZ_GYRO
*  \n INV_XYZ_ACCEL
*  \n INV_WXYZ_QUAT
*  \n If the FIFO has no new data, @e sensors will be zero.
*  \n If the FIFO is disabled, @e sensors will be zero and this function will
*  return a non-zero error code.
*  @param[out] gyro        Gyro data in hardware units.
*  @param[out] accel       Accel data in hardware units.
*  @param[out] quat        3-axis quaternion data in hardware units.
*  @param[out] timestamp   Timestamp in milliseconds.
*  @param[out] sensors     Mask of sensors read from FIFO.
*  @param[out] more        Number of remaining packets.
*  @return     0 if successful.
*/
int dmp_read_fifo(short *gyro, short *accel, long *quat,
    unsigned long *timestamp, short *sensors, unsigned char *more)
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-4 02:23

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

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