查看“MPU6050.getYawPitchRoll()”的源代码
←
MPU6050.getYawPitchRoll()
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
<p style="color: #666666;font-size:220%">'''mpu.getYawPitchRoll(ypr);'''</p> <br> <p style="color: #E87E05;font-size:135%">'''作用'''</p> 得到姿态传感器的俯仰,翻滚,偏航 <p style="color: #E87E05;font-size:135%">'''参数'''</p> float ypr[3]:三个浮点小数,分别存储 俯仰,翻滚,偏航 <p style="color: #E87E05;font-size:135%">'''示例'''</p> <source lang="cpp"> #include <MPU6050_6Axis_Microduino.h> //#include "MPU6050.h" // not necessary if using MotionApps include file // class default I2C address is 0x68 // specific I2C addresses may be passed as a parameter here // AD0 low = 0x68 (default for SparkFun breakout and InvenSense evaluation board) // AD0 high = 0x69 MPU6050 mpu; // uncomment "OUTPUT_READABLE_QUATERNION" if you want to see the actual // quaternion components in a [w, x, y, z] format (not best for parsing // on a remote host such as Processing or something though) //#define OUTPUT_READABLE_QUATERNION // uncomment "OUTPUT_READABLE_YAWPITCHROLL" if you want to see the yaw/ // pitch/roll angles (in degrees) calculated from the quaternions coming // from the FIFO. Note this also requires gravity vector calculations. // Also note that yaw/pitch/roll angles suffer from gimbal lock (for // more info, see: http://en.wikipedia.org/wiki/Gimbal_lock) #define OUTPUT_READABLE_YAWPITCHROLL // orientation/motion vars Quaternion q; // [w, x, y, z] quaternion container float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector uint8_t mpuMode; bool mpuReady; // ================================================================ // === INITIAL SETUP === // ================================================================ void setup() { // initialize serial communication // (115200 chosen because it is required for Teapot Demo output, but it's // really up to you depending on your project) Serial.begin(115200); while (!Serial); // wait for Leonardo enumeration, others continue immediately //set MPU mode mpuMode = MODE_DMP; //MODE_DMP/MODE_SW // verify connection // load and configure the MPU Serial.println(F("Initializing MPU...")); mpuReady = mpu.begin(mpuMode); if (!mpuReady) { // ERROR! // 1 = initial memory load failed // 2 = DMP configuration updates failed // (if it's going to break, usually the code will be 1) Serial.print(F("MPU Initialization failed!")); } } // ================================================================ // === MAIN PROGRAM LOOP === // ================================================================ void loop() { // if programming failed, don't try to do anything if (!mpuReady) return; #ifdef OUTPUT_READABLE_QUATERNION // display quaternion values in easy matrix form: w x y z mpu.getQuaternion(&q); Serial.print("quat\t"); Serial.print(q.w); Serial.print("\t"); Serial.print(q.x); Serial.print("\t"); Serial.print(q.y); Serial.print("\t"); Serial.println(q.z); #endif #ifdef OUTPUT_READABLE_YAWPITCHROLL // display Euler angles in degrees mpu.getYawPitchRoll(ypr); Serial.print("ypr\t"); Serial.print(ypr[0]); Serial.print("\t"); Serial.print(ypr[1]); Serial.print("\t"); Serial.println(ypr[2]); #endif } </source> [[MCookie-Motion_Reference|返回MCookie-Motion_Reference界面]]
返回至
MPU6050.getYawPitchRoll()
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
Welcome
首页
创客大赛
大赛详情
3D打印
安装月球车
图形化编程
操控月球车
升级月球车
编程工具下载
软件下载
Arduino
Processing
Mixly
Scratch
模块套件
Microduino 102
mCookie 102
mCookie 202
mCookie 302
IBC
其他
应用套件
四轴飞行器
平衡车
小车CUBE
音乐播放器
刷卡音乐播放器
wifi气象站
彩虹音乐触摸灯
分贝检测仪
迎门汇报
LED点阵时钟
LED点阵屏幕
硬件
mCookie
Sensor
Microduino
MicroWrt
MicroNux
MicroRobot-Core
MicroRobot-CoreESP
ideaBoard
ideaBox
MicroMV
MicroAI
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息