Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Errors in moving tilt measurement
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Errors in moving tilt measurement

by Adomaino on Fri Jan 31, 2020 2:03 pm

Hello everyone

I hope it's understood because I don't master English and I'm using the translator. In addition, I am a novice in the world of electronics, so I chose this absolute sensor with the intention that I solved the problem of programming filters incomprehensible to me, so I ask please for the simplest explanation possible.
The problem I'm going to expose is this:

I am undertaking a project in which two servo motors installed on a motorcycle must be moved depending on the inclination of the motorcycle when taking the curves. The material used is as follows:
- Arduino's original Arduino nano board
- Sensor original Adafruit BNO055
- 2 12kg torque motors
The problem I have is that if I perform the tilt movements in static the servo motors move correctly, but dynamically, installed everything on the motorcycle, what happens is that the movements are exaggerated or excessive towards one of the senses of inclination and short as leaning in the opposite direction. Put another way; if the motorcycle tilts 20 degrees to the left the servos are tilted 35 or 40 degrees, but if I then lean another 20 degrees to the right the servo motors move 5 or 10 degrees. Similarly, it is common for the motor to reach the vertical position of equilibrium the servo motors do not position themselves in their central starting position, but are tilted to the side where the movement has been excessive, not being corrected this position until the motorcycle stops or the system restarts by turning it off and back on.
I've tried to isolate the vibration sensor to attenuate the noise. In addition, I have isolated the sensor, control board and wiring from possible interference, covering everything with aluminum foil with GND connection.
The sensor is installed under the motorcycle headlight and the calibration is the manufacturing one.
The errors in the movements are similar to those of using a gyroscope alone without the combination with an accelerometer and complementary filter or Kalman filter, a practice on which, as I have read, a drift or "drift" occurs that accumulates errors in calculations.
I hope the information provided will help you look for the problem. Thank you very much and a greeting.

Code:
Code: Select all | TOGGLE FULL SIZE
Adafruit_BNO055 bno = Adafruit_BNO055(55);

void setup(void)
{
  Serial.begin(9600);
  Serial.println("Orientation Sensor Test"); Serial.println("");
 
  /* Initialise the sensor */
  if(!bno.begin())
  {
    /* There was a problem detecting the BNO055 ... check your connections */
    Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
    while(1);
  }
 
  delay(1000);
   
  bno.setExtCrystalUse(true);
 
}

void loop(void)
{
  /* Get a new sensor event */
  sensors_event_t event;
 
  servo_1.attach(servo_pin);
  servo_2.attach(servo_pin_2);
 
  bno.getEvent(&event);
 
  /* Display the floating point data */
  Serial.print("X: ");
  Serial.print(event.orientation.x, 4);
  Serial.print("\tY: ");
  Serial.print(event.orientation.y, 4);
  Serial.print("\tZ: ");
  Serial.print(event.orientation.z, 4);
  Serial.println("");

  event.orientation.y = map(event.orientation.y, -73, 73, 0, 180);
 
  servo_1.write(event.orientation.y);
  servo_2.write(event.orientation.y);
 
  delay(10);
}
Last edited by adafruit_support_bill on Fri Jan 31, 2020 2:53 pm, edited 1 time in total.
Reason: Please use [code] tags when submitting code to the forums

Adomaino
 
Posts: 13
Joined: Fri Jan 31, 2020 1:32 pm

Re: Errors in moving tilt measurement

by adafruit_support_bill on Fri Jan 31, 2020 2:56 pm

The problem I have is that if I perform the tilt movements in static the servo motors move correctly, but dynamically, installed everything on the motorcycle, what happens is that the movements are exaggerated or excessive towards one of the senses of inclination and short as leaning in the opposite direction.

This is normal. When the motorcycle is not moving and tilted, the only acceleration is due to gravity. When the motorcycle is moving while tilted, it must also be turning. And when turning, there is acceleration due to centripetal force as well as due to gravity. The accelerometer cannot distinguish between the two types of acceleration.

adafruit_support_bill
 
Posts: 79109
Joined: Sat Feb 07, 2009 10:11 am

Re: Errors in moving tilt measurement

by Adomaino on Sat Feb 01, 2020 8:03 am

What you are telling me, therefore, is that this sensor is not suitable for tilt measurements when the sensor is in motion, due precisely to the intervention of external forces other than gravity. Sorry for my ignorance, I ask because currently IMUs are used in many devices and vehicles, such as motorcycles, to perform many functions and I do not understand how this can be done without a real reading of the inclination of the sensor. Will another type of sensor be necessary? If so, do you market it and can you tell me which one to buy? Or perhaps what I am proposing is an engineering work that is too complex to be answered in an internet forum. Thank you very much for serving me so kindly. I congratulate you for your customer service infrastructure

Adomaino
 
Posts: 13
Joined: Fri Jan 31, 2020 1:32 pm

Re: Errors in moving tilt measurement

by adafruit_support_bill on Sat Feb 01, 2020 8:18 am

Measuring only acceleration is not sufficient for determining orientation in a moving object. Generally an IMU contains gyroscopic and magnetic sensors as well as accelerometers. The combined output of the 3 types of sensors can be used to estimate the current orientation of the IMU.

This guide has an example:
https://learn.adafruit.com/ahrs-for-ada ... troduction

adafruit_support_bill
 
Posts: 79109
Joined: Sat Feb 07, 2009 10:11 am

Re: Errors in moving tilt measurement

by gammaburst on Sat Feb 01, 2020 6:16 pm

Hi adafruit_support_bill,
He didn't say he's measuring only acceleration.
His code reads Euler angles from a BNO055.
I think I know the answer, but I'd like to hear Adafruit's answer.

gammaburst
 
Posts: 496
Joined: Thu Dec 31, 2015 12:06 pm

Re: Errors in moving tilt measurement

by adafruit_support_bill on Sat Feb 01, 2020 7:52 pm

@gammaburst - My response was based on the description of the problem. If you see an issue in the code, please let us know.

adafruit_support_bill
 
Posts: 79109
Joined: Sat Feb 07, 2009 10:11 am

Re: Errors in moving tilt measurement

by gammaburst on Sun Feb 02, 2020 7:12 am

Hi adafruit_support_bill,
You said, "The accelerometer cannot distinguish between the two types of acceleration."
True, but Adomaino isn't reading the acceleration, he's reading the BNO055 fusion orientation.
BNO055 data sheet says, "In fusion modes it is possible to separate the two acceleration sources..."

gammaburst
 
Posts: 496
Joined: Thu Dec 31, 2015 12:06 pm

Re: Errors in moving tilt measurement

by adafruit_support_bill on Sun Feb 02, 2020 8:13 am

@gammaburst - Thanks, I see now that he is using the BNO055 orientation data.

@Adomaino - Is the excessive movement always to the same side? Have you calibrated the sensor?
https://learn.adafruit.com/adafruit-bno ... alibration

adafruit_support_bill
 
Posts: 79109
Joined: Sat Feb 07, 2009 10:11 am

Re: Errors in moving tilt measurement

by Adomaino on Sun Feb 02, 2020 2:23 pm

Hi, Gammaburst, thanks for the note. Indeed, what I have done is to use the Adafruit sample code to read absolute data and I have simply added two servomotors and a mapping line that serves to establish the rotation relationship between the "Y" axis of the sensor (which is the only axis that I need to use) and the rotation of the servomotors. This rotation ratio is intended to be approximately 1 to 1'3 (each degree of the sensor will order 1.3 degrees of rotation of the servomotors. The project is that simple and works perfectly in static, but when adding different acceleration forces to those of the gravity due to the accelerations, decelerations and centrifugal forces when taking the curves the thing is complicated. I am reading the specification sheet and looking for information (I remind you that I am a newbie and I thought that the sensor would do everything practically alone) , but I would appreciate any help, links, manuals or videos that direct me to the exact problem. As I have read, there are five different fusion modes of use (page 20) but I need to know which would be the most suitable for this project. know how to change mode and do tests, as I say, I am striving for information but I have not yet found a way to switch between these five modes of combined use. In response to your question, no, I have not calibrated the sensor because, according to Adafruit, the factory calibration provides data with acceptable accuracy for most uses. And I don't know which of the five fusion modes uses the Adafruit sample code that I used as a basis to adapt it to my project. Regarding your other question, no, there is not always excessive movement to the same side. Sometimes the movement is excessive to the right and short to the left and sometimes the opposite, as if the center of balance shifts a few degrees to the right or to the left. Then, as I said in my first message, when the servomotors are deviated, if I stop the motorcycle, the system seems to self-correct in about 5 in a row and little by little the servomotors return to the central position. Thank you.

Adomaino
 
Posts: 13
Joined: Fri Jan 31, 2020 1:32 pm

Re: Errors in moving tilt measurement

by gammaburst on Mon Feb 03, 2020 3:29 pm

Adomaino, I think you intended your question for adafruit_support_bill, not for me.

gammaburst
 
Posts: 496
Joined: Thu Dec 31, 2015 12:06 pm

Re: Errors in moving tilt measurement

by adafruit_support_bill on Mon Feb 03, 2020 3:44 pm

Uncalibrated IMUs will tend to show more drift than calibrated ones. But I'd expect the direction of drift to be consistent.

The default operating mode in the library for the BNO055 is NDOF, which should be appropriate for your application. I don't have any hands-on experience with the BNO055in a moving vehicle. Perhaps Gammaburst can offer some more insight?

adafruit_support_bill
 
Posts: 79109
Joined: Sat Feb 07, 2009 10:11 am

Re: Errors in moving tilt measurement

by gammaburst on Mon Feb 03, 2020 8:01 pm

I have no experience with BNO055 in a moving vehicle. Sorry.

gammaburst
 
Posts: 496
Joined: Thu Dec 31, 2015 12:06 pm

Re: Errors in moving tilt measurement

by adafruit_support_bill on Mon Feb 03, 2020 8:29 pm

Try calibrating the device and see if the results improve any: https://learn.adafruit.com/adafruit-bno ... alibration

adafruit_support_bill
 
Posts: 79109
Joined: Sat Feb 07, 2009 10:11 am

Re: Errors in moving tilt measurement

by Adomaino on Tue Feb 04, 2020 6:12 am

So I will agree. I will start with the calibration because from what I have read in the manual the NDOF fusion mode would have to serve my purpose, but it uses the magnetometer to perform the calculations, and from what I have read, the magnetometer needs to be calibrated in place in the It is going to be used. So it is best to start at the beginning and calibrate it first. Thank you. I will inform you of the results.

Adomaino
 
Posts: 13
Joined: Fri Jan 31, 2020 1:32 pm

Re: Errors in moving tilt measurement

by Adomaino on Tue Feb 04, 2020 4:05 pm

Hello
I tried to load the calibration Sketch on the board, but when compiling it gives me "compiled error for Arduino Nano card". I've tried changing for the Arduino One and others, but it still gives the same mistake. If anyone knows what the problem might be I'd appreciate it if you'd let me know.
Code: Select all | TOGGLE FULL SIZE
/**************************************************************************/
/*
    Display sensor calibration status
*/
/**************************************************************************/
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
Adafruit_BNO055 bno = Adafruit_BNO055(55);

void displayCalStatus(void)
{
  /* Get the four calibration values (0..3) */
  /* Any sensor data reporting 0 should be ignored, */
  /* 3 means 'fully calibrated" */
  uint8_t system, gyro, accel, mag;
  system = gyro = accel = mag = 0;
  bno.getCalibration(&system, &gyro, &accel, &mag);

  /* The data should be ignored until the system calibration is > 0 */
  Serial.print("\t");
  if (!system)
  {
    Serial.print("! ");
  }

  /* Display the individual values */
  Serial.print("Sys:");
  Serial.print(system, DEC);
  Serial.print(" G:");
  Serial.print(gyro, DEC);
  Serial.print(" A:");
  Serial.print(accel, DEC);
  Serial.print(" M:");
  Serial.println(mag, DEC);
}
Last edited by adafruit_support_bill on Tue Feb 04, 2020 4:40 pm, edited 1 time in total.
Reason: fixed [code] tags

Adomaino
 
Posts: 13
Joined: Fri Jan 31, 2020 1:32 pm

Please be positive and constructive with your questions and comments.