getYawPitchRoll()

描述

以偏摆(Yaw)、俯仰(Pitch)、翻滚(Roll)角度回传目前感测到的惯性姿态,其中偏摆角是以地球北方为轴心,俯仰角和翻滚角是以地平面为轴心。

语法


FreeIMU1.getYawPitchRoll(ypr)

参数

FreeIMU1FreeIMU1 型别的变数

yprypr 是一个指向浮点数阵列或双精度浮点数阵列的指标,该阵列应该至少有可以存放三个浮点数或双精度浮点数元素的空间。在 getYawPitchRoll() 执行完后,该阵列将会依序存放表示目前惯性姿态的偏摆(Yaw)、俯仰(Pitch)、翻滚(Roll)角

回传

范例

#include <FreeIMU1.h> 
#include <Wire.h>
    
FreeIMU1 myIMU;
    
void setup()
{
  Serial.begin(115200);
  Wire.begin();
  delay(500);
    
  myIMU.init();
  delay(500);
}
    
void loop()
{
  double ypr[3];
  char str[512];
    
  myIMU.getYawPitchRoll(ypr);
  sprintf(str, "%f\t%f\t%f\t", ypr[0], ypr[1], ypr[2]);
  Serial.print(str);
  Serial.print('\n');
  delay(20);
}

See also

getYawPitchRollRad()


函式库参考主页面

The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.