我正在尝试使用BNO055传感器作为罗盘,使用Arduino uno。数据表表明BNO055传感器具有COMPASS模式。根据数据表,这种模式是一种融合模式,它结合了来自2个传感器,陀螺仪和磁力计传感器的数据,并根据设置计算测量值以返回数据。
所以我想通过使用这个代码,我可以在360度
中获得设备的绝对定位 if(!bno.begin(bno.OPERATION_MODE_COMPASS))
< ---我添加了此行以启动罗盘模式。
sensors_event_t event; bno.getEvent(&event);
< ----我以为我可以得到像这样的融合模式传感器数据。
我想知道我的代码是否有问题。
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
Adafruit_BNO055 bno = Adafruit_BNO055(55);
signed char gyro, accel, mag;
void setup(void)
{
Serial.begin(9600);
Serial.println("Orientation Sensor Test"); Serial.println("");
/* Initialise the sensor */
if(!bno.begin(bno.OPERATION_MODE_COMPASS))
{
/* There was a problem detecting the BNO055 ... check your connections */
Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
while(1);
}
/* Display the current temperature */
int8_t temp = bno.getTemp();
signed char tempe;
Serial.print("Current Temperature: ");
Serial.print(temp);
Serial.println(" C");
Serial.println("");
while(!bno.isFullyCalibrated());
Serial.println("calibration finished!");
delay(1000);
//bno.setMode();
bno.setExtCrystalUse(true);
}
void loop(void)
{
/* Get a new sensor event */
sensors_event_t event;
bno.getEvent(&event);
Serial.print("x : ");
Serial.print(event.orientation.x);
Serial.print("\ty : ");
Serial.print(event.orientation.y);
Serial.print("\tz : ");
Serial.println(event.orientation.z);
/* Display calibration status for each sensor. */
uint8_t system, gyro, accel, mag = 0;
bno.getCalibration(&system, &gyro, &accel, &mag);
Serial.print("CALIBRATION: Sys=");
Serial.print(system, DEC);
Serial.print(" Gyro=");
Serial.print(gyro, DEC);
Serial.print(" Accel=");
Serial.print(accel, DEC);
Serial.print(" Mag=");
Serial.println(mag, DEC);
delay(300);
}
使用此代码,我得到了这样的结果,但我不确定每个轴的含义是什么。
我认为x轴值描述了基准方向与传感器前进方向之间的角度,假设站在北极上。 我想知道我的想法是否正确。如果没有,请告诉我什么是不对的。谢谢。