项目作者: Gereon99

项目描述 :
LSM9DS1 Java driver
高级语言: Java
项目地址: git://github.com/Gereon99/LSM9DS1-Java.git
创建时间: 2020-02-10T08:35:07Z
项目社区:https://github.com/Gereon99/LSM9DS1-Java

开源协议:

下载


LSM9DS1 for Java

This repository provides you with an easy to use driver for the LSM9DS1 Inertial Measurement Unit (IMU) written in Java,
focused to be used on a Raspberry Pi.
The sensor includes an accelerometer, gyroscope, magnetometer and a temperature sensor.

The driver allows you to read data from the IMU, but also supplies more complex methods for calculating the
Euler angles (pitch, roll and yaw) while using low-pass and complementary filters.

1. Preparation

Make sure you have wiringpi installed on your Pi. If not, install it with apt-get install wiringpi.
Add the Pi4J library to your projects build path. (You might have to change a few imports)

2. Example

To use this driver, you just have to create a new instance of the LSM9DS1 class. Afterwards you can start reading data.

  1. // Create an instance
  2. LSM9DS1 imu = new LSM9DS1();
  3. // Read and save current data (also calculates Euler angles)
  4. imu.read();
  5. // Get acceleration data
  6. float accelerometerX = imu.getAccelerometerData()[0];
  7. float accelerometerY = imu.getAccelerometerData()[1];
  8. float accelerometerZ = imu.getAccelerometerData()[2];
  9. // Get gyroscope data
  10. float gyroscopeX = imu.getGyroscopeData()[0];
  11. float gyroscopeY = imu.getGyroscopeData()[1];
  12. float gyroscopeZ = imu.getGyroscopeData()[2];
  13. // Get magnetometer data
  14. float magnetometerX = imu.getMagnetometerData()[0];
  15. float magnetometerY = imu.getMagnetometerData()[1];
  16. float magnetometerZ = imu.getMagnetometerData()[2];
  17. // Get temperature
  18. int temperature = imu.getTemperature();
  19. // Calculating and obtaining the Euler angles
  20. double pitch = imu.getPitch();
  21. double roll = imu.getRoll();
  22. double yaw = imu.getYaw();

3. Other

This driver was more or less a conversion from the driver written in C by Adafruit (https://github.com/adafruit/Adafruit_LSM9DS1)
This driver will most likely be updated in the near future. (Primarily implementing yaw calculation)