Open mataldomen opened 4 years ago
https://github.com/kriswiner/LSM9DS1/blob/master/LSM9DS1_MS5611_BasicAHRS_t3.ino
On Sun, Feb 16, 2020 at 2:41 PM mataldomen notifications@github.com wrote:
Hey Kris,
I am writing to You becouse I have big problem with my Arduino board and I can't resolve this from week.
I want to implement Madgwick filter and quaternions into my Arduino Nano 33 BLE board. After that i receive a lot of really crazy numbers without any sense.
I configured My board with ArduinoLSM9DS1 libary ( https://www.arduino.cc/en/Reference/ArduinoLSM9DS1) it's really simply part of code in comparison into yours. For me is perfect beacouse I am beginner.
In my first use of this board I used data from sensors and I calculated Eulers angles to receive pitch,roll and yaw. I received preety good numbers.
Nextly I want to implement madgwick from here( https://x-io.co.uk/open-source-imu-and-ahrs-algorithms/)
Maybe You know with Your experience why I still cant use Madgwick on my board ? Maybe You done someting before on this board ?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14?email_source=notifications&email_token=ABTDLKT4IQWS4W7FJ7UK27TRDG6I7A5CNFSM4KWHMCK2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IN4HDRQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKTHWB3ZTXW2VQFE5CDRDG6I7ANCNFSM4KWHMCKQ .
Hi Kris
How did you go translating the example for the nano 33? I am also struggling a little getting accurate results with the new boards.
Did you want to share some code maybe we can figure it out together?
I did not translate the sketch for the Nano33, I have never used the Nano33.
Did you calibrate the sensors? How?
On Sun, Feb 23, 2020 at 8:05 AM Michael Bell notifications@github.com wrote:
Hi Kris
How did you go translating the example for the nano 33? I am also struggling a little getting accurate results with the new boards.
Did you want to share some code maybe we can figure it out together?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14?email_source=notifications&email_token=ABTDLKW35FR4GD7HRDGFZIDREKNCXA5CNFSM4KWHMCK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMV7SEA#issuecomment-590084368, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKXTAG7R7VXTELLH4FLREKNCXANCNFSM4KWHMCKQ .
Ah sorry I meant @mataldomen :)
I've managed to get some calibration data from motioncal but reapplying the offsets has been a little difficult. I was hoping to have some realtime calibration methods when the device starts up.
I'll try your methods to see if I can implement it. Cheers
@mataldomen
You can try this version of the Madgwick lib for the nano 33 ble. I still need to figure out the calibration step, but might help getting you somewhere if you dont need calibrated data.
#include <ArduinoBLE.h>
#include <Arduino_LSM9DS1.h>
#include <MadgwickAHRS.h>
// Madgwick
Madgwick filter;
// sensor's sample rate is fixed at 119 Hz:
const float sensorRate = 119;
float roll, pitch, heading;
// BLE Service
BLEService imuService("917649A0-D98E-11E5-9EEC-0002A5D5C51B"); // Custom UUID
// BLE Characteristic
BLECharacteristic imuCharacteristic("917649A1-D98E-11E5-9EEC-0002A5D5C51B", BLERead | BLENotify, 12);
long previousMillis = 0; // last timechecked, in ms
unsigned long micros_per_reading, micros_previous;
void setup() {
Serial.begin(115200); // initialize serial communication
pinMode(LED_BUILTIN, OUTPUT); // initialize the built-in LED pin to indicate when a central is connected
// begin initialization
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
while (1);
}
// Setup bluetooth
BLE.setLocalName("ArduinoIMU");
BLE.setAdvertisedService(imuService);
imuService.addCharacteristic(imuCharacteristic);
BLE.addService(imuService);
// start advertising
BLE.advertise();
Serial.println("Bluetooth device active, waiting for connections...");
// start the filter to run at the sample rate:
filter.begin(119);
delay(10000);
Serial.print("Accelerometer sample rate = ");
Serial.print(IMU.accelerationSampleRate());
Serial.println(" Hz");
Serial.println();
Serial.println("Acceleration in G's");
Serial.println("X\tY\tZ");
Serial.print("Gyroscope sample rate = ");
Serial.print(IMU.gyroscopeSampleRate());
Serial.println(" Hz");
Serial.println();
Serial.println("Gyroscope in degrees/second");
Serial.println("X\tY\tZ");
Serial.print("Magnetic field sample rate = ");
Serial.print(IMU.magneticFieldSampleRate());
Serial.println(" uT");
Serial.println();
Serial.println("Magnetic Field in uT");
Serial.println("X\tY\tZ");
micros_per_reading = 1000000 / 119;
micros_previous = micros();
}
// send IMU data
void sendSensorData() {
float ax, ay, az; // Acceleration
float gx, gy, gz; // Gyroscope
float mx, my, mz; // Magnometer
// read orientation x, y and z eulers
IMU.readAcceleration(ax, ay, az);
IMU.readGyroscope(gx, gy, gz);
IMU.readMagneticField(mx, my, mz);
filter.update(gx, gy, gz, ax, ay, az, -mx, my, mz); //for all 3
roll = filter.getRoll();
pitch = filter.getPitch();
heading = filter.getYaw();
Serial.print("Orientation: ");
Serial.print(heading);
Serial.print(" ");
Serial.print(pitch);
Serial.print(" ");
Serial.println(roll);
// Send 3x eulers over bluetooth as 1x byte array
float data[3];
data[0] = heading;
data[1] = pitch;
data[2] = roll;
imuCharacteristic.setValue((byte *) &data, 12);
}
void loop() {
// wait for a BLE central
BLEDevice central = BLE.central();
// if a BLE central is connected to the peripheral:
if (central) {
Serial.print("Connected to central: ");
// print the central's BT address:
Serial.println(central.address());
// turn on the LED to indicate the connection:
digitalWrite(LED_BUILTIN, HIGH);
// while the central is connected:
while (central.connected()) {
unsigned long micros_now;
micros_now = micros();
if (micros_now - micros_previous >= micros_per_reading) {
if (IMU.accelerationAvailable() && IMU.gyroscopeAvailable() && IMU.magneticFieldAvailable()) { // XX
sendSensorData();
micros_previous = micros_previous + micros_per_reading;
}
}
}
// when the central disconnects, turn off the LED:
digitalWrite(LED_BUILTIN, LOW);
Serial.print("Disconnected from central: ");
Serial.println(central.address());
}
}
Hi @MichaelFBA Thank You for your help and code. Code looks and work really similar which my. I was sure about that numbers which We receive from Arduino are faulty beacuse I bad use Madgwick libary. I didnt think before about that sensors without calibration in real time can create so big mistake. Probably You are right.
Do You have any ideas how calibrate them properly ?
This repo has examples of how to calibrate the sensor at runtime, we would need to modify it to conform with the Arduino imu API.
I had a quick look at trying to migrate the code but haven't managed to finish it yet. There is a lot going on.
As I was researching this topic, I discovered this message on the Arduino forum that could provide additional insights: https://forum.arduino.cc/index.php?topic=663160.msg4467543#msg4467543
Accoding to the illustration presented, magnetometer axis are flippped from the ones on accelerometerand gyroscopes. It also seems that rotation is left handed!
Yes, this is all in the data sheet which everone who is using this sensor should read completely, perhaps any times. The specific orientation of the sensor axes has to be taken into account in the Madgwick or Mahony fusion call.
On Mon, Apr 20, 2020 at 2:57 AM César García notifications@github.com wrote:
As I was researching this topic, I discover this topic on the Arduino forum that could provide additional insights: https://forum.arduino.cc/index.php?topic=663160.msg4467543#msg4467543
Accoding to the illustriation presented, magnetometer axis are flippped from the ones on accelerometerand gyroscopes. It also seems that rotation is left handed!
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-616441781, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKTQ5XVS6JQ2FAXZTFLRNQMA3ANCNFSM4KWHMCKQ .
Thanks @kriswiner for your response!
Hello @MichaelFBA and @mataldomen , were either of you able to calibrate this sensor for the Arduino Nano 33 BLE? I have been stuck on this for a few days now. I tried changing the sensor axis and still cannot get it to work.
Hello, Unfortunately I quit my project without solved this problem. When I read about my wrong setup of the axis two weeks ago I tried to do this properly again and nothing improves.
I cant help You. If You have to set orientation based on quaternions maybe You should buy another sensor which calculating quaternions without madgwick library. On market is big choice but these sensors are more expensive than this in our Arduinos :D
https://www.youtube.com/watch?v=T9jXoG0QYIA
@mataldomen @MichaelFBA @Jeremiah1327 @elsatch I hope I'm not too late for you guys but I've recently have been working on the same problem and I've found some resources. As you can see from this video it's possible to calibrate the magnetometer without any libraries in a sort of brute force manner by taking a bunch of measurements in different places over a period of time, finding the median x y and z values and shifting them to 0 where 0 - median would be the offset that you could then add to every magnetometer reading and achieve calibration. I haven't looked just yet but I bet there are some 3D plotting libraries to help with this as well. It also seemed implied by the video that accelerometer values and gyroscope values were okay and didn't need to be calibrated, but I'm not sure if that is the case. I have noticed that the accelerometer and gyroscope read a little bit of noise when at rest and I think that disregarding values below some noise threshold might be enough.
I've also looked into motion cal https://learn.adafruit.com/adafruit-sensorlab-magnetometer-calibration/magnetic-calibration-with-motioncal but I'm struggling to get the sketches to work on the Nano 33 BLE Sense, if some of you guys want to try them, let me know if you can get them to work.
I've also experimented with using this algorithm: https://x-io.co.uk/open-source-imu-and-ahrs-algorithms/ in my receiver program to calculate a quaternion of rotation given the raw sensor data over bluetooth from my arduino, but the end result seems to be very inacurate and some of the axes seem to be wrong. I haven't calibrated yet so that might be part of my issue, also I have been randomly experimenting with the beta and sample period parameters since I'm not really sure what they're supposed to be, so that also might be a contributing factor lol
but that's where I've gotten so far, let me know if anyone has more information, thanks!
Basic accel/gyro, and mag calibration as well as quaternions are implemented here https://github.com/kriswiner/LSM9DS1/blob/master/LSM9DS1_MS5611_BasicAHRS_t3.ino. Just need to make some small changes for your platforms. Not sure why this is such a mystery....
On Sun, May 31, 2020 at 9:26 PM Cole Lashley notifications@github.com wrote:
https://www.youtube.com/watch?v=T9jXoG0QYIA
@mataldomen https://github.com/mataldomen @MichaelFBA https://github.com/MichaelFBA @Jeremiah1327 https://github.com/Jeremiah1327 @elsatch https://github.com/elsatch I hope I'm not too late for you guys but I've recently have been working on the same problem and I've found some resources. As you can see from this video it's possible to calibrate the magnetometer without any libraries in a sort of brute force manner by taking a bunch of measurements in different places over a period of time, finding the median x y and z values and shifting them to 0 where median - 0 would be the offset that you could then add to every magnetometer reading and achieve calibration. I haven't looked just yet but I bet there are some 3D plotting libraries to help with this as well. It also seemed implied by the video that accelerometer values and gyroscope values were okay and didn't need to be calibrated, but I'm not sure if that is the case. I have noticed that the accelerometer and gyroscope read a little bit of noise when at rest and I think that disregarding values below some noise threshold might be enough.
I've also looked into motion cal https://learn.adafruit.com/adafruit-sensorlab-magnetometer-calibration/magnetic-calibration-with-motioncal but I'm struggling to get the sketches to work on the Nano 33 BLE Sense, if some of you guys want to try them, let me know if you can get them to work.
I've also experimented with using this algorithm: https://x-io.co.uk/open-source-imu-and-ahrs-algorithms/ in my receiver program to calculate a quaternion of rotation given the raw sensor data over bluetooth from my arduino, but the end result seems to be very inacurate and some of the axes seem to be wrong. I haven't calibrated yet so that might be part of my issue, also I have been randomly experimenting with the beta and sample period parameters since I'm not really sure what they're supposed to be, so that also might be a contributing factor lol
but that's where I've gotten so far, let me know if anyone has more information, thanks!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-636605757, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKS6DWBPAG3M7OG6NCDRUMUWHANCNFSM4KWHMCKQ .
Apologies, I’m a bit new to this. I saw that but I was a bit deterred because there was a lot of code that I didn’t understand. Is this a library that you can get from the arduino store or at least import into the arduino editor? And what would we need to change to make it compatible with the arduino nano 33 ble sense?
Probably just need to change the Wire methods since i2c_t3.h is Teensy only.
But you can certainly copy the methods for accel/gyro calibration, mag calibration, and quaternion determination. This sketch is not meant to be a black box that you can plug into your Nano but rather an illustration of methods that can be used.
On Mon, Jun 1, 2020 at 8:17 AM Cole Lashley notifications@github.com wrote:
Apologies, I’m a bit new to this. I saw that but I was a bit deterred because there was a lot of code that I didn’t understand. Is this a library that you can get from the arduino store or at least import into the arduino editor? And what would we need to change to make it compatible with the arduino nano 33 ble sense?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-636917540, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKQRAZ4DANGEFA6OH23RUPA7NANCNFSM4KWHMCKQ .
@MrStashley I spent many hours a day for over a week trying to get it to work. I watched a lot of YouTube videos about IMU calibration methods and tried to modify the numerous LSM9DS1 codes. I tried to modify @kriswiner 's code but still could not get it figured out. I bought the Arduino Nano BlE Sense for the purpose of having a built in IMU that would be easy to use. I decided to just try out different IMU/Microcontrollers with working libraries. I simply do not have the time and coding experience to do get it working with the BLE Sense and am not willing to sacrifice more time to get it to work, as I have deadlines for my project. If you end up figuring it out though, that would be awesome.
@Jeremiah1327 ah okay. I'm still doing research and I haven't yet gotten around to trying to get @kriswiner 's code to work, but I have looked at and I see some stuff that seems promising, and getting another IMU is a last resort for me because I need the ble chip, but it might come to that for me as well. Which IMU did you end up buying that worked for you?
@kriswiner do you know how I could implement the writeByte method in a way that would work on my nano 33 ble sense?
This works on the ESP8252 and is pretty generic:
// I2C read/write functions
void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { Wire.beginTransmission(address); // Initialize the Tx buffer Wire.write(subAddress); // Put slave register address in Tx buffer Wire.write(data); // Put data in Tx buffer Wire.endTransmission(); // Send the Tx buffer }
uint8_t readByte(uint8_t address, uint8_t subAddress)
{
uint8_t data; // data
will store the register data
Wire.beginTransmission(address); // Initialize the Tx buffer
Wire.write(subAddress); // Put slave register address in Tx buffer
Wire.endTransmission(false); // Send the Tx buffer, but send a restart to
keep connection alive
Wire.requestFrom(address, 1); // Read one byte from slave register address
data = Wire.read(); // Fill Rx buffer with result
return data; // Return data read from slave register
}
void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t
dest) { Wire.beginTransmission(address); // Initialize the Tx buffer Wire.write(subAddress); // Put slave register address in Tx buffer Wire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive uint8_t i = 0; Wire.requestFrom(address, count); // Read bytes from slave register address while (Wire.available()) { dest[i++] = Wire.read(); } // Put read results in the Rx buffer }
On Mon, Jun 1, 2020 at 6:43 PM Cole Lashley notifications@github.com wrote:
@kriswiner https://github.com/kriswiner do you know how I could implement the writeByte method in a way that would work on my nano 33 ble sense?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-637217502, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKSSRY5WGPM3PIA4VY3RURKL7ANCNFSM4KWHMCKQ .
Ah okay. I thought Wire was a library that I might have to replace but my editor seems to think it's fine. The error I'm getting now is that I2C_NOSTOP was not declared in this scope and it seems that it wasn't declared in your code either. Is this a constant that I can define or something native to a certain kind of board?
This is for i2c_t3.h only, replace with false as in the code snippets I sent you.
On Mon, Jun 1, 2020 at 7:06 PM Cole Lashley notifications@github.com wrote:
Ah okay. I thought Wire was a library that I might have to replace but my editor seems to think it's fine. The error I'm getting now is that I2C_NOSTOP was not declared in this scope and it seems that it wasn't declared in your code either. Is this a constant that I can define or something native to a certain kind of board?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-637224155, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKVJX3SPE2IESI4EDF3RURNDVANCNFSM4KWHMCKQ .
ahh okay my bad I didn't notice. Thanks a ton :)
So the writeByte method causes the Mbed OS to crash. It could be an issue with the actual registers used in the calls but the first writeByte call in accelgyrocal and in magcal crashes the OS. I'm sure this problem is way out of my expertise league, and it might just be a compatibility issue that's impossible to fix, but can you think of anything that might be related to the issue that I could look into?
Run! Run away as fast as you can from MBED....
On Mon, Jun 1, 2020 at 8:02 PM Cole Lashley notifications@github.com wrote:
So the writeByte method causes the Mbed OS to crash. It could be an issue with the actual registers used in the calls but the first writeByte call in accelgyrocal and in magcal crashes the OS. I'm sure this problem is way out of my expertise league, and it might just be a compatibility issue that's impossible to fix, but can you think of anything that might be related to the issue that I could look into?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-637241360, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKXSZ2D3VBEPXLSCMUDRURTV7ANCNFSM4KWHMCKQ .
Ah okay that's what I'm finding out lol. It sucks because the Nano 33 ble sense has everything I need for my project in terms of sensors and ble capability. Do you know of any other boards that have similar capabilities but don't have the annoying issue of being compatible with nothing?
Is there not an Arduino core for the Nano33?
https://www.arduino.cc/en/Guide/NANO33BLESense
On Mon, Jun 1, 2020 at 8:29 PM Cole Lashley notifications@github.com wrote:
Ah okay that's what I'm finding out lol. It sucks because the Nano 33 ble sense has everything I need for my project in terms of sensors and ble capability. Do you know of any other boards that have similar capabilities but don't have the annoying issue of being compatible with nothing?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-637248714, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKX2SBS6QFTLUPJ4HWLRURWYNANCNFSM4KWHMCKQ .
There is, it's just that none of the calibration libraries are compatible with the board so I haven't been able to calibrate the sensors and I can't get the AHRS algorithm to spit out numbers that makes even close to sense. I've heard that the sensors on the nano 33 ble sense have coordinate planes in wierd directions and that the accelerometer and gyroscope have left handed coordinate planes and I think that might be contributing to my error as well, but I'm not really sure how to fix it.
The Madgwick fusion algorithm required the sensors data be fed in in NED convention.
Besides, if using the Arduino IDE, you can just run my sketch (with slight modification) and get all of this.
On Mon, Jun 1, 2020 at 9:43 PM Cole Lashley notifications@github.com wrote:
There is, it's just that none of the calibration libraries are compatible with the board so I haven't been able to calibrate the sensors and I can't get the AHRS algorithm to spit out numbers that makes even close to sense. I've heard that the sensors on the nano 33 ble sense have coordinate planes in wierd directions and that the accelerometer and gyroscope have left handed coordinate planes and I think that might be contributing to my error as well, but I'm not really sure how to fix it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-637268324, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKWG744QS644CH2YNS3RUR7OXANCNFSM4KWHMCKQ .
ah okay thank you for that. I'll look into which axes I need to switch to get NED.
well except that the writeByte function causes the Mbed OS to crash. Do you think that it's an issue with the location of the registers on my board or an issue with the Wire functions?
The Wire functions are written in C++ and are suitable for use with the Arduino IDE, not C-based MBed.
On Tue, Jun 2, 2020 at 8:34 AM Cole Lashley notifications@github.com wrote:
ah okay thank you for that. I'll look into which axes I need to switch to get NED.
well except that the writeByte function causes the Mbed OS to crash. Do you think that it's an issue with the location of the registers on my board or an issue with the Wire functions?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-637627077, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKXTES3CLMOGTPFC6BTRUULWRANCNFSM4KWHMCKQ .
Well I'm using the arduino IDE to upload programs, but then running them on my ble sense which is running Mbed OS. I guess that's the problem. That seems like such an oversight on the part of the Mbed developers lol, like who uses C-? Is there an alternative to Wire, or is my best option to get another board?
I don't know anything about your platform so can't really say. But the link I sent seems to indicate that there is an LSM6DS1 library for the Aduino IDE for this Nano33 so I am wondering why you are having anything to do with MBed at all.
Anyway, the trouble you are having is due to the Nano33 and its programming environment and not the LSM6DS1, so I don;t expect anything I tell you will help at this pint.
On Tue, Jun 2, 2020 at 8:43 AM Cole Lashley notifications@github.com wrote:
Well I'm using the arduino IDE to upload programs, but then running them on my ble sense which is running Mbed OS. I guess that's the problem. That seems like such an oversight on the part of the Mbed developers lol, like who uses C-? Is there an alternative to Wire, or is my best option to get another board?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-637636173, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKT2YWEBITU3QG4F6HDRUUM3TANCNFSM4KWHMCKQ .
after making all the accel and gyro axes negative as well as the mz axis in an attempt to get NED convention, I suddenly get vastly different numbers. They're still inaccurate, but they're much closer and I still can play with the gyro scale. Calibration is still going to be a problem but this is promising. Thanks for your help! :)
There is an lsm9ds1 library but it doesn't deal with calibration or anything, it's pretty basic and all it does is read values. I might be able to rig up a calibration in unity tho if I'm lucky. Thanks for your help and I hope I didn't take up too much of your time.
aN, aE, aD, gN, gE, gD, mN, mE, mD is the order the madgwick filter expects the sensor data. Once you select which board edge is to be North, you should be able to determine the correspondence between the actual axes values and NED rather than using trial and error.
On Tue, Jun 2, 2020 at 8:53 AM Cole Lashley notifications@github.com wrote:
after making all the accel and gyro axes negative as well as the mz axis in an attempt to get NED convention, I suddenly get vastly different numbers. They're still inaccurate, but they're much closer and I still can play with the gyro scale. Calibration is still going to be a problem but this is promising. Thanks for your help! :)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-637641850, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKTJPK37SEAH3JVDHFTRUUN6JANCNFSM4KWHMCKQ .
There is an LSM6DS1 sketch in my repository that has calibration methods in it. Not sure why you are not using this...
On Tue, Jun 2, 2020 at 8:56 AM Cole Lashley notifications@github.com wrote:
There is an lsm9ds1 library but it doesn't deal with calibration or anything, it's pretty basic and all it does is read values. I might be able to rig up a calibration in unity tho if I'm lucky. Thanks for your help and I hope I didn't take up too much of your time.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-637644069, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKWLUUZ7PX3S3EF63WDRUUOL3ANCNFSM4KWHMCKQ .
So I have this diagram:
that I believe is from the lsm9ds1 data sheet and I'm not sure how to figure out which side is north on the actual board, but I decided to align the accelerometer and gyroscope with the magnetometer because someone on a forum said that the way the magnetometer was aligned was better, so I used all negative accel and gyro values and -z of the magnetometer to get down. Does that seem reasonable? It made my ahrs values a lot better
okay, thanks. I'll check it out
" I decided to align the accelerometer and gyroscope with the magnetometer"
Is the accel x-axis ligne with the mag x-axis????
No wonder you are getting nonsensical results.
Why not just try NED?
On Tue, Jun 2, 2020 at 9:05 AM Cole Lashley notifications@github.com wrote:
okay, thanks. I'll check it out
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-637649240, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKXPY7XDALKBFH3VK3LRUUPLRANCNFSM4KWHMCKQ .
Well how do I get NED? I apologize, I'm very new to this and I thought that I was getting NED by aligning all of the axes and pointing z down. But I see now that the accel and gyro x is aligned with mag y and accel and gyro x is aligned with mag y. Could I account for this by putting gy and ay in place of ax and ay in the update call and vice versa?
accel and gyro y is aligned with mag x**
1) Pick a board edge to point North
2) which accel axis is aligned with this board edge?
3) This is the axis that goes into the first Madgwick sensor data slot, aN.
4) repeat for East and Down, to fill second and third data slots.
5) repeat for gyro and mag
On Tue, Jun 2, 2020 at 9:28 AM Cole Lashley notifications@github.com wrote:
accel and gyro y is aligned with mag x**
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-637665312, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKWMO6EW5LQMFPWKW5TRUUSDHANCNFSM4KWHMCKQ .
So what I'm struggling with is how to figure out where the lsm9ds1 is on the board and where the axes align
Hi all,
I hope my comment helps you @MrStashley @mataldomen
I have been playing around today with the Arduino nano 33 BLE sense and I followed @kriswiner instructions, which are standard when using a new IMU. The following image shows the coordinate system that I used which I confirm is according to the datasheet. You can also check it yourselves by reading the accelerometer, gyroscope, and magnetometer individually. Example: at rest you should read az = 1 and ax=ay=0, Bz = -uT, and so on for other orientations.
Thus, you should assume that: aN = ax, aE = ay, aD = -az gN = gx, aE = gy, aD = -gz mN = -mx, aE =my, aD = -mz
After calibrating the magnetometer for the soft and hard iron distortions and applying the Madgwick filter using beta = 0.033 (optimal value according to Madgwick internal report) I was obtaining the Euler angles as they should.
Try it out and see if it works for you.
Best regards to all
Can you provide a repo with an example @MigSanc?
@MigSanc ooh nice work and thanks for that awesome diagram. I was able to get my euler angles to be approximately accurate using similar methods but I am still suffering from drift and the algorithm seems to take a very long time to converge unless I use a beta of greater than .1. How were you able to calibrate the magnetometer? Is there a library that you used? Thanks and great work!
I am still working on it @MichaelFBA. It may take some time though due to work. but let you know when I have something.
@MrStashley I am also experiencing some drift, it may be due to gyroscope drift errors (since I have not compensated the gyro readings). Still looking at it. Regarding the magnetometer calibration, I read the raw magnetometer values, not the converted to mG or uT, and then apply the same algorithm as @kriswiner does, or any other method standard:
Theory: https://www.vectornav.com/support/library/magnetometer
HOW TO CALIBRATE A MAGNETOMETER (LINK1): https://appelsiini.net/2018/calibrate-magnetometer/ Simple and Effective Magnetometer Calibration (LINK2) https://github.com/kriswiner/MPU6050/wiki/Simple-and-Effective-Magnetometer-Calibration Easy Hard and Soft Iron Magnetometer Calibration (LINK3): https://www.instructables.com/id/Easy-hard-and-soft-iron-magnetometer-calibration/
@kriswiner, do you have any explanation for the drift values of the euler angles? Especially at stationary positions :( I have used other IMU's (BMX055) and when trying to implement Madgwick filter there is also a significant drift at a stationary position
Best regards to all
The sensors (all the sensors) need proper calibration in order to remove drift. If you don;t calibrate the gyro, you are going to get heading drift, big time....
On Wed, Jun 10, 2020 at 12:10 PM MigSanc notifications@github.com wrote:
I am still working on it @MichaelFBA https://github.com/MichaelFBA. It may take some time though due to work. but let you know when I have something.
@MrStashley https://github.com/MrStashley I am also experiencing some drift, it may be due to gyroscope drift errors (since I have not compensated the gyro readings). Still looking at it. Regarding the magnetometer calibration, I read the raw magnetometer values, not the converted to mG or uT, and then apply the same algorithm as @kriswiner https://github.com/kriswiner does, or any other method standard: HOW TO CALIBRATE A MAGNETOMETER (LINK1): https://appelsiini.net/2018/calibrate-magnetometer/ Simple and Effective Magnetometer Calibration (LINK2) https://github.com/kriswiner/MPU6050/wiki/Simple-and-Effective-Magnetometer-Calibration Easy Hard and Soft Iron Magnetometer Calibration (LINK3): https://www.instructables.com/id/Easy-hard-and-soft-iron-magnetometer-calibration/
@kriswiner https://github.com/kriswiner, do you have any explanation for the drift values of the euler angles? Especially at stationary positions :( I have used other IMU's (BMX055) and when trying to implement Madgwick filter there is also a significant drift at a stationary position
Best regards to all
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriswiner/LSM9DS1/issues/14#issuecomment-642202106, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKUILL6IQLR5KGRZWETRV7LAVANCNFSM4KWHMCKQ .
@kriswiner that seems in agreement with my data. Do you have any reference for why gyro drift actuates especially on the heading value? Or any reference to how calibrate/compensate gyro? Is it only a temperature compensation: https://www.vectornav.com/support/library/gyroscope ? or should it have anything more to stabilize the value?
Thanks in advance
Hey Kris,
I am writing to You becouse I have big problem with my Arduino board and I can't resolve this from week.
I want to implement Madgwick filter and quaternions into my Arduino Nano 33 BLE board. After that i receive a lot of really crazy numbers without any sense.
I configured My board with ArduinoLSM9DS1 libary (https://www.arduino.cc/en/Reference/ArduinoLSM9DS1) it's really simply part of code in comparison into yours. For me is perfect beacouse I am beginner.
In my first use of this board I used data from sensors and I calculated Eulers angles to receive pitch,roll and yaw. I received preety good numbers.
Nextly I want to implement madgwick from here(https://x-io.co.uk/open-source-imu-and-ahrs-algorithms/)
Maybe You know with Your experience why I still cant use Madgwick on my board ? Maybe You done someting before on this board ?